diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 10f770f6ce42..89157ff7ee1b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -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() diff --git a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala index 80c41bbe772f..9ee5b43f9c93 100644 --- a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala +++ b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala @@ -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. diff --git a/tests/pos/i10951.scala b/tests/pos/i10951.scala new file mode 100644 index 000000000000..2520536a491c --- /dev/null +++ b/tests/pos/i10951.scala @@ -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)]