Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1253,15 +1253,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def desugarIdent(tree: Ident)(implicit ctx: Context): Tree = {
val qual = desugarIdentPrefix(tree)
if (qual.isEmpty) tree
else qual.select(tree.symbol).withSpan(tree.span)
else qual.select(tree.symbol)
}

/** Recover identifier prefix (e.g. this) if it exists */
def desugarIdentPrefix(tree: Ident)(implicit ctx: Context): Tree = tree.tpe match {
case TermRef(prefix: TermRef, _) =>
ref(prefix).withSpan(tree.span)
ref(prefix)
case TermRef(prefix: ThisType, _) =>
This(prefix.cls).withSpan(tree.span)
This(prefix.cls)
case _ =>
EmptyTree
}
Expand Down
18 changes: 6 additions & 12 deletions compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ object TypeTestsCasts {
}

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

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

def inMatch =
tree.fun.symbol == defn.Any_typeTest || // new scheme
fun.symbol == defn.Any_typeTest || // new scheme
expr.symbol.is(Case) // old scheme

def transformIsInstanceOf(expr: Tree, testType: Type, flagUnrelated: Boolean): Tree = {
Expand Down Expand Up @@ -308,13 +306,9 @@ object TypeTestsCasts {
else if (sym.isTypeCast)
transformAsInstanceOf(erasure(tree.args.head.tpe))
else tree
}
}
val expr = tree.fun match {
case Select(expr, _) => expr
case i: Ident => desugarIdentPrefix(i)
case _ => EmptyTree

case _ =>
tree
}
interceptWith(expr)
}
}
11 changes: 0 additions & 11 deletions tests/pos/i5006.scala

This file was deleted.