From 75da0358fd7866f3dccdfcf4fbeae9af8ccc69f3 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 30 May 2016 09:20:21 +0200 Subject: Fix #657: Add scala.Dynamic support. --- src/dotty/tools/dotc/typer/Typer.scala | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 268020ec5..019c460e8 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -58,11 +58,12 @@ object Typer { assert(tree.pos.exists, s"position not set for $tree # ${tree.uniqueId}") } -class Typer extends Namer with TypeAssigner with Applications with Implicits with Checking { +class Typer extends Namer with TypeAssigner with Applications with Implicits with Dynamic with Checking { import Typer._ import tpd.{cpy => _, _} import untpd.cpy + import Dynamic.isDynamicMethod /** A temporary data item valid for a single typed ident: * The set of all root import symbols that have been @@ -316,7 +317,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def asSelect(implicit ctx: Context): Tree = { val qual1 = typedExpr(tree.qualifier, selectionProto(tree.name, pt, this)) if (tree.name.isTypeName) checkStable(qual1.tpe, qual1.pos) - typedSelect(tree, pt, qual1) + val select = typedSelect(tree, pt, qual1) + pt match { + case _: FunProto | AssignProto => select + case _ => + if (select.tpe eq TryDynamicCallType) typedDynamicSelect(tree, pt) + else select + } } def asJavaSelectFromTypeTree(implicit ctx: Context): Tree = { @@ -480,7 +487,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val appliedUpdate = cpy.Apply(fn)(wrappedUpdate, (args map untpd.TypedSplice) :+ tree.rhs) typed(appliedUpdate, pt) case lhs => - val lhsCore = typedUnadapted(lhs) + val lhsCore = typedUnadapted(lhs, AssignProto) def lhs1 = typed(untpd.TypedSplice(lhsCore)) def canAssign(sym: Symbol) = // allow assignments from the primary constructor to class fields sym.is(Mutable, butNot = Accessor) || @@ -508,6 +515,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case _ => reassignmentToVal } + case TryDynamicCallType => + tree match { + case Assign(Select(qual, name), rhs) if !isDynamicMethod(name) => + typedDynamicAssign(qual, name, rhs, pt) + case _ => reassignmentToVal + } case tpe => reassignmentToVal } @@ -1665,7 +1678,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit tree match { case _: MemberDef | _: PackageDef | _: Import | _: WithoutTypeOrPos[_] => tree case _ => tree.tpe.widen match { - case ErrorType => + case _: ErrorType => tree case ref: TermRef => pt match { -- cgit v1.2.3