diff options
author | Nicolas Stucki <nicolas.stucki@gmail.com> | 2016-05-30 09:20:21 +0200 |
---|---|---|
committer | Nicolas Stucki <nicolas.stucki@gmail.com> | 2016-07-07 11:10:44 +0200 |
commit | 75da0358fd7866f3dccdfcf4fbeae9af8ccc69f3 (patch) | |
tree | 142087645d00858f20eaead2f805afb333d2bddc /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 07fd8a357ed660ef15163efb2788928fec290fdd (diff) | |
download | dotty-75da0358fd7866f3dccdfcf4fbeae9af8ccc69f3.tar.gz dotty-75da0358fd7866f3dccdfcf4fbeae9af8ccc69f3.tar.bz2 dotty-75da0358fd7866f3dccdfcf4fbeae9af8ccc69f3.zip |
Fix #657: Add scala.Dynamic support.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 21 |
1 files changed, 17 insertions, 4 deletions
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 { |