Skip to content

Commit e721c66

Browse files
authored
Merge pull request #10952 from albertpchen/selectDynamic-type-param-fix
Fix #10951: update typedDynamicSelect
2 parents 1ae8c01 + 13624d5 commit e721c66

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ trait Applications extends Compatibility {
10761076
case _ =>
10771077
}
10781078
def tryDynamicTypeApply(): Tree = typedFn match {
1079-
case typedFn: Select if !pt.isInstanceOf[FunProto] => typedDynamicSelect(typedFn, typedArgs, pt)
1079+
case typedFn: Select if !pt.isInstanceOf[FunProto] => typedDynamicSelect(typedFn, typedArgs.map(untpd.TypedSplice(_)), pt)
10801080
case _ => tree.withType(TryDynamicCallType)
10811081
}
10821082
if (typedFn.tpe eq TryDynamicCallType) tryDynamicTypeApply()

compiler/src/dotty/tools/dotc/typer/Dynamic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ trait Dynamic {
106106
* Note: inner part of translation foo.bar(baz) = quux ~~> foo.selectDynamic(bar).update(baz, quux) is achieved
107107
* through an existing transformation of in typedAssign [foo.bar(baz) = quux ~~> foo.bar.update(baz, quux)].
108108
*/
109-
def typedDynamicSelect(tree: untpd.Select, targs: List[Tree], pt: Type)(using Context): Tree =
109+
def typedDynamicSelect(tree: untpd.Select, targs: List[untpd.Tree], pt: Type)(using Context): Tree =
110110
typedApply(coreDynamic(tree.qualifier, nme.selectDynamic, tree.name, tree.span, targs), pt)
111111

112112
/** Translate selection that does not typecheck according to the normal rules into a updateDynamic.

tests/pos/i10951.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.language.dynamics
2+
3+
object Dyn extends Dynamic:
4+
def selectDynamic[T](name: String): Option[T] = None
5+
6+
val a: Option[(Int, Int)] = Dyn.asdf[Tuple2[Int, Int]]
7+
val b: Option[(Int, Int)] = Dyn.selectDynamic[(Int, Int)]("asdf")
8+
val c: Option[(Int, Int)] = Dyn.asdf[(Int, Int)]

0 commit comments

Comments
 (0)