Skip to content

Commit 230e92d

Browse files
Merge pull request #6886 from dotty-staging/revert-due-to-idempotency-fails
Revert "Fix #5006: Normalize prefixes of TypeApply in Erasure"
2 parents 358a348 + 35f31b7 commit 230e92d

File tree

5 files changed

+9
-26
lines changed

5 files changed

+9
-26
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,15 +1253,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12531253
def desugarIdent(tree: Ident)(implicit ctx: Context): Tree = {
12541254
val qual = desugarIdentPrefix(tree)
12551255
if (qual.isEmpty) tree
1256-
else qual.select(tree.symbol).withSpan(tree.span)
1256+
else qual.select(tree.symbol)
12571257
}
12581258

12591259
/** Recover identifier prefix (e.g. this) if it exists */
12601260
def desugarIdentPrefix(tree: Ident)(implicit ctx: Context): Tree = tree.tpe match {
12611261
case TermRef(prefix: TermRef, _) =>
1262-
ref(prefix).withSpan(tree.span)
1262+
ref(prefix)
12631263
case TermRef(prefix: ThisType, _) =>
1264-
This(prefix.cls).withSpan(tree.span)
1264+
This(prefix.cls)
12651265
case _ =>
12661266
EmptyTree
12671267
}

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,8 @@ object TypeTestsCasts {
156156
}
157157

158158
def interceptTypeApply(tree: TypeApply)(implicit ctx: Context): Tree = trace(s"transforming ${tree.show}", show = true) {
159-
/** Intercept `expr.xyz[XYZ]` */
160-
def interceptWith(expr: Tree): Tree = {
161-
if (expr.isEmpty) tree
162-
else {
159+
tree.fun match {
160+
case fun @ Select(expr, selector) =>
163161
val sym = tree.symbol
164162

165163
def isPrimitive(tp: Type) = tp.classSymbol.isPrimitiveValueClass
@@ -174,7 +172,7 @@ object TypeTestsCasts {
174172
def foundCls = effectiveClass(expr.tpe.widen)
175173

176174
def inMatch =
177-
tree.fun.symbol == defn.Any_typeTest || // new scheme
175+
fun.symbol == defn.Any_typeTest || // new scheme
178176
expr.symbol.is(Case) // old scheme
179177

180178
def transformIsInstanceOf(expr: Tree, testType: Type, flagUnrelated: Boolean): Tree = {
@@ -308,13 +306,9 @@ object TypeTestsCasts {
308306
else if (sym.isTypeCast)
309307
transformAsInstanceOf(erasure(tree.args.head.tpe))
310308
else tree
311-
}
312-
}
313-
val expr = tree.fun match {
314-
case Select(expr, _) => expr
315-
case i: Ident => desugarIdentPrefix(i)
316-
case _ => EmptyTree
309+
310+
case _ =>
311+
tree
317312
}
318-
interceptWith(expr)
319313
}
320314
}

tests/pos/i5006.scala

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)