Skip to content

Fix #10951: update typedDynamicSelect #10952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ trait Applications extends Compatibility {
case _ =>
}
def tryDynamicTypeApply(): Tree = typedFn match {
case typedFn: Select if !pt.isInstanceOf[FunProto] => typedDynamicSelect(typedFn, typedArgs, pt)
case typedFn: Select if !pt.isInstanceOf[FunProto] => typedDynamicSelect(typedFn, typedArgs.map(untpd.TypedSplice(_)), pt)
case _ => tree.withType(TryDynamicCallType)
}
if (typedFn.tpe eq TryDynamicCallType) tryDynamicTypeApply()
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Dynamic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ trait Dynamic {
* Note: inner part of translation foo.bar(baz) = quux ~~> foo.selectDynamic(bar).update(baz, quux) is achieved
* through an existing transformation of in typedAssign [foo.bar(baz) = quux ~~> foo.bar.update(baz, quux)].
*/
def typedDynamicSelect(tree: untpd.Select, targs: List[Tree], pt: Type)(using Context): Tree =
def typedDynamicSelect(tree: untpd.Select, targs: List[untpd.Tree], pt: Type)(using Context): Tree =
typedApply(coreDynamic(tree.qualifier, nme.selectDynamic, tree.name, tree.span, targs), pt)

/** Translate selection that does not typecheck according to the normal rules into a updateDynamic.
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i10951.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.language.dynamics

object Dyn extends Dynamic:
def selectDynamic[T](name: String): Option[T] = None

val a: Option[(Int, Int)] = Dyn.asdf[Tuple2[Int, Int]]
val b: Option[(Int, Int)] = Dyn.selectDynamic[(Int, Int)]("asdf")
val c: Option[(Int, Int)] = Dyn.asdf[(Int, Int)]