From 8527a9bb605ad8f656c949a97db14685a7cb0b42 Mon Sep 17 00:00:00 2001 From: EnzeXing <58994529+EnzeXing@users.noreply.github.com> Date: Sat, 31 Aug 2024 21:49:29 -0400 Subject: [PATCH] Adds special treatment to Predef.classOf (#21523) This is an updated PR of #20945, making the global initialization checker skips the analysis of `Predef.classOf` in scala2-library, since it is a stub method in tasty and is replaced by actual class representations in the backend. This prevents related warnings when running test_scala2_library_tasty. --------- Co-authored-by: EnzeXing --- compiler/src/dotty/tools/dotc/transform/init/Objects.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala index 1050fbe85ef2..0f96440f343f 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala @@ -702,6 +702,9 @@ class Objects(using Context @constructorOnly): val arr = OfArray(State.currentObject, summon[Regions.Data]) Heap.writeJoin(arr.addr, args.map(_.value).join) arr + else if target.equals(defn.Predef_classOf) then + // Predef.classOf is a stub method in tasty and is replaced in backend + Bottom else if target.hasSource then val cls = target.owner.enclosingClass.asClass val ddef = target.defTree.asInstanceOf[DefDef]