diff options
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/ReTyper.scala | 8 |
3 files changed, 17 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index a126db1ad..ff465ea2f 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -476,10 +476,8 @@ trait Applications extends Compatibility { self: Typer => } case _ => fun1.tpe match { - case ErrorType => - tree.withType(ErrorType) - case tp => - throw new Error(s"unexpected type.\n fun1 = $fun1,\n methPart(fun1) = ${methPart(fun1)},\n methPart(fun1).tpe = ${methPart(fun1).tpe},\n tpe = $tp") + case ErrorType => tree.withType(ErrorType) + case tp => handleUnexpectedFunType(tree, fun1) } } } @@ -515,6 +513,10 @@ trait Applications extends Compatibility { self: Typer => else realApply } + /** Overridden in ReTyper to handle primitive operations that can be generated after erasure */ + protected def handleUnexpectedFunType(tree: untpd.Apply, fun: Tree)(implicit ctx: Context): Tree = + throw new Error(s"unexpected type.\n fun = $fun,\n methPart(fun) = ${methPart(fun)},\n methPart(fun).tpe = ${methPart(fun).tpe},\n tpe = ${fun.tpe}") + def typedTypeApply(tree: untpd.TypeApply, pt: Type)(implicit ctx: Context): Tree = track("typedTypeApply") { var typedArgs = tree.args mapconserve (typedType(_)) val typedFn = typedExpr(tree.fun, PolyProto(typedArgs.tpes, pt)) diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala index 6ecfee4e3..ab6514507 100644 --- a/src/dotty/tools/dotc/typer/Checking.scala +++ b/src/dotty/tools/dotc/typer/Checking.scala @@ -213,9 +213,9 @@ trait Checking { if (ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, pos) if (traitReq && !(tref.symbol is Trait)) ctx.error(d"$tref is not a trait", pos) tp - case _ => - ctx.error(d"$tp is not a class type", pos) - defn.ObjectClass.typeRef + case _ => + ctx.error(d"$tp is not a class type", pos) + defn.ObjectClass.typeRef } /** Check that a non-implicit parameter making up the first parameter section of an diff --git a/src/dotty/tools/dotc/typer/ReTyper.scala b/src/dotty/tools/dotc/typer/ReTyper.scala index 230788cc1..4014aa202 100644 --- a/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/src/dotty/tools/dotc/typer/ReTyper.scala @@ -70,5 +70,13 @@ class ReTyper extends Typer { override def encodeName(tree: untpd.NameTree)(implicit ctx: Context) = tree + override def handleUnexpectedFunType(tree: untpd.Apply, fun: Tree)(implicit ctx: Context): Tree = fun.tpe match { + case mt @ MethodType(_, formals) => + val args: List[Tree] = tree.args.zipWithConserve(formals)(typedExpr(_, _)).asInstanceOf[List[Tree]] + assignType(untpd.cpy.Apply(tree)(fun, args), fun, args) + case _ => + super.handleUnexpectedFunType(tree, fun) + } + override def checkVariance(tree: Tree)(implicit ctx: Context) = () }
\ No newline at end of file |