Skip to content

Commit 940e0f5

Browse files
committed
Don't transform infos of classes that get eliminated at erasure
Some classes get mapped to other classes at erasure. There's no need to transform their info. Fixes #19506
1 parent 1716bcd commit 940e0f5

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeErasure.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,10 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
814814
eraseResult(tp1.resultType) match
815815
case rt: MethodType => rt
816816
case rt => MethodType(Nil, Nil, rt)
817-
case tp1 => this(tp1)
817+
case tp1: ClassInfo if defn.specialErasure.contains(tp1.cls) =>
818+
tp1
819+
case tp1 =>
820+
this(tp1)
818821

819822
private def eraseDerivedValueClass(tp: Type)(using Context): Type = {
820823
val cls = tp.classSymbol.asClass

tests/neg/i19506.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options "-source:3.4-migration",
1+
//> using options -source 3.4-migration
22

33
trait Reader[T]
44
def read[T: Reader](s: String, trace: Boolean = false): T = ???

tests/pos/i19530.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object A {
2+
def x = classOf[scala.Singleton]
3+
}

0 commit comments

Comments
 (0)