Skip to content

Commit 8246cb9

Browse files
committed
Use base types to compute classOf args of applyDynamic
As suggested in #11043 (comment) Fixes #11043
1 parent 2e3e048 commit 8246cb9

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ trait Dynamic {
268268
if tpe.paramInfoss.nestedExists(!TypeErasure.hasStableErasure(_)) then
269269
fail(i"has a parameter type with an unstable erasure") :: Nil
270270
else
271-
TypeErasure.erasure(tpe).asInstanceOf[MethodType].paramInfos.map(clsOf(_))
271+
tpe.paramInfoss.flatten.map(tp => clsOf(tp.baseType(tp.classSymbol)))
272272
structuralCall(nme.applyDynamic, classOfs).maybeBoxingCast(tpe.finalResultType)
273273
}
274274

tests/pos/i11043.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import scala.reflect.Selectable.reflectiveSelectable
2+
3+
object Test {
4+
type Runner = { def run(args: Array[String]): Unit }
5+
6+
def test(args: Array[String], runner: Runner): Unit =
7+
runner.run(args)
8+
9+
def main(args: Array[String]): Unit = {
10+
test(Array("foo", "bar"), new {
11+
def run(args: Array[String]): Unit = args foreach println
12+
})
13+
}
14+
}

tests/pos/i11043min.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.reflect.Selectable.reflectiveSelectable
2+
3+
type Runner = { def run(args: Array[String]): Unit }
4+
5+
def test(runner: Runner): Unit = runner.run(???)

0 commit comments

Comments
 (0)