diff options
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Constants.scala | 10 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 21 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/transform/Erasure.scala | 4 |
3 files changed, 25 insertions, 10 deletions
diff --git a/src/reflect/scala/reflect/internal/Constants.scala b/src/reflect/scala/reflect/internal/Constants.scala index 511b39b8c6..85d0efdcba 100644 --- a/src/reflect/scala/reflect/internal/Constants.scala +++ b/src/reflect/scala/reflect/internal/Constants.scala @@ -223,7 +223,15 @@ trait Constants extends api.Constants { case ClazzTag => def show(tpe: Type) = "classOf[" + signature(tpe) + "]" typeValue match { - case ErasedValueType(orig) => show(orig) + case ErasedValueType(clazz, underlying) => + // A note on tpe_* usage here: + // + // We've intentionally erased the type arguments to the value class so that different + // instantiations of a particular value class that erase to the same underlying type + // don't result in spurious bridges (e.g. run/t6385.scala). I don't think that matters; + // printing trees of `classOf[ValueClass[String]]` shows `classOf[ValueClass]` at phase + // erasure both before and after the use of `tpe_*` here. + show(clazz.tpe_*) case _ => show(typeValue) } case CharTag => "'" + escapedChar(charValue) + "'" diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 088d6bfe8e..e483fa6ba8 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -3341,18 +3341,25 @@ trait Types /** A temporary type representing the erasure of a user-defined value type. * Created during phase erasure, eliminated again in posterasure. * - * @param original The underlying type before erasure + * SI-6385 Erasure's creation of bridges considers method signatures `exitingErasure`, + * which contain `ErasedValueType`-s. In order to correctly consider the overriding + * and overriden signatures as equivalent in `run/t6385.scala`, it is critical that + * this type contains the erasure of the wrapped type, rather than the unerased type + * of the value class itself, as was originally done. + * + * @param valueClazz The value class symbol + * @param erasedUnderlying The erased type of the unboxed value */ - abstract case class ErasedValueType(original: TypeRef) extends UniqueType { - override def safeToString = "ErasedValueType("+original+")" + abstract case class ErasedValueType(valueClazz: Symbol, erasedUnderlying: Type) extends UniqueType { + override def safeToString = s"ErasedValueType($valueClazz, $erasedUnderlying)" } - final class UniqueErasedValueType(original: TypeRef) extends ErasedValueType(original) + final class UniqueErasedValueType(valueClazz: Symbol, erasedUnderlying: Type) extends ErasedValueType(valueClazz, erasedUnderlying) object ErasedValueType { - def apply(original: TypeRef): Type = { - assert(original.sym ne NoSymbol, "ErasedValueType over NoSymbol") - unique(new UniqueErasedValueType(original)) + def apply(valueClazz: Symbol, erasedUnderlying: Type): Type = { + assert(valueClazz ne NoSymbol, "ErasedValueType over NoSymbol") + unique(new UniqueErasedValueType(valueClazz, erasedUnderlying)) } } diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index 185e2c3d1e..4aefc105e3 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -257,11 +257,11 @@ trait Erasure { /** This is used as the Scala erasure during the erasure phase itself * It differs from normal erasure in that value classes are erased to ErasedValueTypes which - * are then later converted to the underlying parameter type in phase posterasure. + * are then later unwrapped to the underlying parameter type in phase posterasure. */ object specialScalaErasure extends ScalaErasureMap { override def eraseDerivedValueClassRef(tref: TypeRef): Type = - ErasedValueType(tref) + ErasedValueType(tref.sym, erasedValueClassArg(tref)) } object javaErasure extends JavaErasureMap |