Skip to content

Commit

Permalink
Adds special treatment to Predef.classOf (#21523)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
EnzeXing and EnzeXing authored Sep 1, 2024
1 parent 5e83606 commit 8527a9b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/init/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 8527a9b

Please sign in to comment.