diff options
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/PatternMatcher.scala | 8 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 3ea78f53e..3fa08b9c6 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -497,7 +497,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { Try(tree: Tree)(expr, handler, finalizer) } - implicit class TreeOps[ThisTree <: tpd.Tree](val tree: ThisTree)/* extends AnyVal*/ { + implicit class TreeOps[ThisTree <: tpd.Tree](val tree: ThisTree) extends AnyVal { def isValue(implicit ctx: Context): Boolean = tree.isTerm && tree.tpe.widen.isValueType @@ -565,8 +565,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { def appliedToArgss(argss: List[List[Tree]])(implicit ctx: Context): Tree = ((tree: Tree) /: argss)(Apply(_, _)) - def appliedToNone(implicit ctx: Context): Tree = { - tree.tpe.widen match { + def appliedToNone(implicit ctx: Context): Tree = appliedToArgs(Nil) + + def appliedIfMethod(implicit ctx: Context): Tree = { + tree.tpe.widen match { case fntpe: MethodType => appliedToArgs(Nil) case _ => tree } diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 4914f667a..b74506caf 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -342,7 +342,6 @@ class Definitions { def NothingType: Type = NothingClass.typeRef def NullType: Type = NullClass.typeRef def SeqType: Type = SeqClass.typeRef - def ObjectArrayType = ArrayType(ObjectType) def UnitType: Type = UnitClass.typeRef def BooleanType: Type = BooleanClass.typeRef diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala index c3dd7320c..9613fe0f0 100644 --- a/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -105,7 +105,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans def tupleSel(binder: Symbol)(i: Int): Tree = ref(binder).select(nme.productAccessorName(i)) // make tree that accesses the i'th component of the tuple referenced by binder def index(tgt: Tree)(i: Int): Tree = { if (i > 0) tgt.select(defn.Seq_apply).appliedTo(Literal(Constant(i))) - else tgt.select(defn.Seq_head).appliedToNone + else tgt.select(defn.Seq_head).appliedIfMethod } // Right now this blindly calls drop on the result of the unapplySeq @@ -232,7 +232,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans val matchFail = newSynthCaseLabel(ctx.freshName("matchFail"), MethodType(Nil, restpe)) val catchAllDefBody = DefDef(matchFail, catchAllDef) - val nextCases = (caseSyms.tail ::: List(matchFail)).map(ref(_).appliedToNone) + val nextCases = (caseSyms.tail ::: List(matchFail)).map(ref(_).appliedIfMethod) val caseDefs = (cases zip caseSyms zip nextCases).foldRight[Tree](catchAllDefBody) { // dotty deviation //case (((mkCase, sym), nextCase), acc) => @@ -243,7 +243,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans val caseBody = DefDef(sym, _ => Block(List(acc), body)) - Block(List(caseBody),ref(sym).appliedToNone) + Block(List(caseBody),ref(sym).appliedIfMethod) }} @@ -273,7 +273,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans val isDefined = extractorMemberType(prev.tpe, nme.isDefined) if ((isDefined isRef defn.BooleanClass) && getTp.exists) { - val prevValue = ref(prevSym).select("get".toTermName).appliedToNone + val prevValue = ref(prevSym).select("get".toTermName).appliedIfMethod Block( List(ValDef(prevSym, prev)), // must be isEmpty and get as we don't control the target of the call (prev is an extractor call) |