@@ -315,12 +315,17 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
315
315
316
316
def typedSelect (tree : untpd.Select , pt : Type )(implicit ctx : Context ): Tree = track(" typedSelect" ) {
317
317
def asSelect (implicit ctx : Context ): Tree = {
318
- val qual1 = typedExpr(tree.qualifier, selectionProto(tree.name, pt, this ))(ctx.retractMode( Mode . IgnoreNextDynamic ))
318
+ val qual1 = typedExpr(tree.qualifier, selectionProto(tree.name, pt, this ))
319
319
if (tree.name.isTypeName) checkStable(qual1.tpe, qual1.pos)
320
320
val select = typedSelect(tree, pt, qual1)
321
- if (select.tpe == TryDynamicCallType && ! ctx.mode.is(Mode .IgnoreNextDynamic )) {
322
- typedDynamicSelect(tree, pt)
323
- } else select
321
+ if (select.tpe != TryDynamicCallType ) {
322
+ select
323
+ } else {
324
+ pt match {
325
+ case _ : FunProto | _ : AssignProto => select
326
+ case _ => typedDynamicSelect(tree, pt)
327
+ }
328
+ }
324
329
}
325
330
326
331
def asJavaSelectFromTypeTree (implicit ctx : Context ): Tree = {
@@ -475,14 +480,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
475
480
def typedAssign (tree : untpd.Assign , pt : Type )(implicit ctx : Context ) = track(" typedAssign" ) {
476
481
tree.lhs match {
477
482
case lhs @ Apply (fn, args) =>
478
- /* We type using Mode.IgnoreNextDynamic because fn might be a Select(foo, bar) where foo is of type
479
- * scala.Dynamic and bar is not one of its members. In which case the following transformation will be tried:
480
- * foo.bar(baz) = quux ~~> foo.selectDynamic("bar").update(baz, quux)
481
- * Mode.IgnoreNextDynamic will ensure that Apply(Select(fn, update), args) is not transformed
482
- * into fn.applyDynamic(update)(args) and will only transform the contents of fn if needed.
483
- * See: Dynamic.scala
484
- */
485
- typed(cpy.Apply (lhs)(untpd.Select (fn, nme.update), args :+ tree.rhs), pt)(ctx.addMode(Mode .IgnoreNextDynamic ))
483
+ typed(cpy.Apply (lhs)(untpd.Select (fn, nme.update), args :+ tree.rhs), pt)
486
484
case untpd.TypedSplice (Apply (MaybePoly (Select (fn, app), targs), args)) if app == nme.apply =>
487
485
val rawUpdate : untpd.Tree = untpd.Select (untpd.TypedSplice (fn), nme.update)
488
486
val wrappedUpdate =
@@ -491,13 +489,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
491
489
val appliedUpdate = cpy.Apply (fn)(wrappedUpdate, (args map untpd.TypedSplice ) :+ tree.rhs)
492
490
typed(appliedUpdate, pt)
493
491
case lhs =>
494
- /* We type using Mode.IgnoreNextDynamic because this tree might be transformed with:
495
- * foo.bar = baz ~~> foo.updateDynamic("bar")(baz)
496
- * Mode.IgnoreNextDynamic will ensure that Assign(Select(foo, bar), baz) will not be transformed
497
- * into foo.selectDynamic(bar) = baz during the typing of the lhs.
498
- * See: Dynamic.scala
499
- */
500
- val lhsCore = typedUnadapted(lhs)(ctx.addMode(Mode .IgnoreNextDynamic ))
492
+ val proto = new AssignProto (tree.lhs, pt, this )(argCtx(tree))
493
+ val lhsCore = typedUnadapted(lhs, proto)
501
494
def lhs1 = typed(untpd.TypedSplice (lhsCore))
502
495
def canAssign (sym : Symbol ) = // allow assignments from the primary constructor to class fields
503
496
sym.is(Mutable , butNot = Accessor ) ||
0 commit comments