@@ -13,8 +13,6 @@ import transform.ContextFunctionResults.*
13
13
import unpickleScala2 .Scala2Erasure
14
14
import Decorators .*
15
15
import Definitions .MaxImplementedFunctionArity
16
- import dotty .tools .dotc .reporting .trace
17
-
18
16
import scala .annotation .tailrec
19
17
20
18
/** The language in which the definition being erased was written. */
@@ -822,7 +820,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
822
820
case tp1 =>
823
821
this (tp1)
824
822
825
- private def eraseDerivedValueClass (tp : Type )(using Context ): Type = trace.force( i " eraseDerivedValueClass $tp " ) {
823
+ private def eraseDerivedValueClass (tp : Type )(using Context ): Type = {
826
824
val cls = tp.classSymbol.asClass
827
825
val unbox = valueClassUnbox(cls)
828
826
if unbox.exists then
@@ -832,33 +830,30 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
832
830
// The underlying part of an ErasedValueType cannot be an ErasedValueType itself
833
831
val erase = erasureFn(sourceLanguage, semiEraseVCs = false , isConstructor, isSymbol, inSigName)
834
832
val erasedUnderlying = erase(underlying)
835
- if erasedUnderlying.isInstanceOf [WildcardType ] then WildcardType
836
- else {
837
-
838
- // Ideally, we would just use `erasedUnderlying` as the erasure of `tp`, but to
839
- // be binary-compatible with Scala 2 we need two special cases for polymorphic
840
- // value classes:
841
- // - Given `class Foo[A](x: A) extends AnyVal`, `Foo[X]` should erase like
842
- // `X`, except if its a primitive in which case it erases to the boxed
843
- // version of this primitive.
844
- // - Given `class Bar[A](x: Array[A]) extends AnyVal`, `Bar[X]` will be
845
- // erased like `Array[A]` as seen from its definition site, no matter
846
- // the `X` (same if `A` is bounded).
847
- //
848
- // The binary compatibility is checked by sbt-test/scala2-compat/i8001
849
- val erasedValueClass = trace.force(i " erasedValueClass of erasedUnderlying $erasedUnderlying and genericUnderlying $genericUnderlying" ) {
850
- if erasedUnderlying.isPrimitiveValueType && ! genericUnderlying.isPrimitiveValueType then
851
- defn.boxedType(erasedUnderlying)
852
- else if genericUnderlying.derivesFrom(defn.ArrayClass ) then
853
- erasure(genericUnderlying)
854
- else erasedUnderlying
855
- }
856
-
857
- if erasedValueClass.exists then ErasedValueType (cls.typeRef, erasedValueClass)
858
- else
859
- assert(ctx.reporter.errorsReported, i " no erasure for $underlying" )
860
- NoType
861
- }
833
+ if erasedUnderlying.isInstanceOf [WildcardType ] then return WildcardType
834
+
835
+ // Ideally, we would just use `erasedUnderlying` as the erasure of `tp`, but to
836
+ // be binary-compatible with Scala 2 we need two special cases for polymorphic
837
+ // value classes:
838
+ // - Given `class Foo[A](x: A) extends AnyVal`, `Foo[X]` should erase like
839
+ // `X`, except if its a primitive in which case it erases to the boxed
840
+ // version of this primitive.
841
+ // - Given `class Bar[A](x: Array[A]) extends AnyVal`, `Bar[X]` will be
842
+ // erased like `Array[A]` as seen from its definition site, no matter
843
+ // the `X` (same if `A` is bounded).
844
+ //
845
+ // The binary compatibility is checked by sbt-test/scala2-compat/i8001
846
+ val erasedValueClass =
847
+ if erasedUnderlying.isPrimitiveValueType && ! genericUnderlying.isPrimitiveValueType then
848
+ defn.boxedType(erasedUnderlying)
849
+ else if genericUnderlying.derivesFrom(defn.ArrayClass ) then
850
+ erasure(genericUnderlying)
851
+ else erasedUnderlying
852
+
853
+ if erasedValueClass.exists then ErasedValueType (cls.typeRef, erasedValueClass)
854
+ else
855
+ assert(ctx.reporter.errorsReported, i " no erasure for $underlying" )
856
+ NoType
862
857
else NoType
863
858
}
864
859
0 commit comments