Skip to content

Commit e9c949d

Browse files
committed
revert changes to add traces
1 parent 9b04c6d commit e9c949d

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

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

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import transform.ContextFunctionResults.*
1313
import unpickleScala2.Scala2Erasure
1414
import Decorators.*
1515
import Definitions.MaxImplementedFunctionArity
16-
import dotty.tools.dotc.reporting.trace
17-
1816
import scala.annotation.tailrec
1917

2018
/** The language in which the definition being erased was written. */
@@ -822,7 +820,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
822820
case tp1 =>
823821
this(tp1)
824822

825-
private def eraseDerivedValueClass(tp: Type)(using Context): Type = trace.force(i"eraseDerivedValueClass $tp") {
823+
private def eraseDerivedValueClass(tp: Type)(using Context): Type = {
826824
val cls = tp.classSymbol.asClass
827825
val unbox = valueClassUnbox(cls)
828826
if unbox.exists then
@@ -832,33 +830,30 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
832830
// The underlying part of an ErasedValueType cannot be an ErasedValueType itself
833831
val erase = erasureFn(sourceLanguage, semiEraseVCs = false, isConstructor, isSymbol, inSigName)
834832
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
862857
else NoType
863858
}
864859

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ object Erasure {
270270
def constant(tree: Tree, const: Tree)(using Context): Tree =
271271
(if (isPureExpr(tree)) const else Block(tree :: Nil, const)).withSpan(tree.span)
272272

273-
final def box(tree: Tree, target: => String = "")(using Context): Tree = trace.force(i"boxing ${tree.showSummary()}: ${tree.tpe} into $target") {
273+
final def box(tree: Tree, target: => String = "")(using Context): Tree = trace(i"boxing ${tree.showSummary()}: ${tree.tpe} into $target") {
274274
tree.tpe.widen match {
275275
case ErasedValueType(tycon, _) =>
276276
New(tycon, cast(tree, underlyingOfValueClass(tycon.symbol.asClass)) :: Nil) // todo: use adaptToType?
@@ -290,7 +290,7 @@ object Erasure {
290290
}
291291
}
292292

293-
def unbox(tree: Tree, pt: Type)(using Context): Tree = trace.force(i"unboxing ${tree.showSummary()}: ${tree.tpe} as a $pt") {
293+
def unbox(tree: Tree, pt: Type)(using Context): Tree = trace(i"unboxing ${tree.showSummary()}: ${tree.tpe} as a $pt") {
294294
pt match {
295295
case ErasedValueType(tycon, underlying) =>
296296
def unboxedTree(t: Tree) =

0 commit comments

Comments
 (0)