diff --git a/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala b/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala index fb1dd04bd6ad..55b26d89b5a0 100644 --- a/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala +++ b/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala @@ -7,6 +7,7 @@ import core.* import Contexts.*, Trees.*, Types.* import DenotTransformers.*, MegaPhase.* import ExtensionMethods.*, ValueClasses.* +import Decorators.* /** This phase inlines calls to methods of value classes. @@ -58,12 +59,18 @@ class VCInlineMethods extends MiniPhase with IdentityDenotTransformer { */ private def rewire(tree: Tree, mtArgs: List[Tree] = Nil, mArgss: List[List[Tree]] = Nil) (using Context): Tree = + def noTypeApplyIn(tree: Tree): Boolean = tree match + case _: TypeApply => false + case Apply(fn, _) => noTypeApplyIn(fn) + case _ => true tree match { case Apply(qual, mArgs) => rewire(qual, mtArgs, mArgs :: mArgss) case TypeApply(qual, mtArgs2) => - assert(mtArgs == Nil) - rewire(qual, mtArgs2, mArgss) + if noTypeApplyIn(qual) then + rewire(qual, mtArgs2, mArgss) + else + rewire(qual, mtArgs, mtArgs2 :: mArgss) case sel @ Select(qual, _) => val origMeth = sel.symbol val origCls = origMeth.enclosingClass diff --git a/compiler/test/dotc/pos-test-pickling.excludelist b/compiler/test/dotc/pos-test-pickling.excludelist index 1a0be6f66183..9706f95cdfb9 100644 --- a/compiler/test/dotc/pos-test-pickling.excludelist +++ b/compiler/test/dotc/pos-test-pickling.excludelist @@ -139,7 +139,7 @@ parsercombinators-new-syntax.scala hylolib-deferred-given hylolib-cb hylolib -i23266.scala +i23299.scala # typecheckErrors method unpickling i21415.scala diff --git a/tests/pos/i23266.scala b/tests/pos/i23266.scala index bc643ac7215d..3ff104c65cd7 100644 --- a/tests/pos/i23266.scala +++ b/tests/pos/i23266.scala @@ -1,17 +1,8 @@ +//> using scala 3.7.0 -def kek(t: Table, ids: t.Id*) = ??? +class Foo(v: Any) extends AnyVal: + def bar[X](bar: X)[Y]: Any = v -trait Table { - type Id = String -} - -object Table1 extends Table { - val id: Id = "table1_id" -} - -class Table2() extends Table { - val id: Id = "table2_id" -} - -val x = kek(Table1, Table1.id) -val y = kek(Table2(), Table2().id) \ No newline at end of file +@main def run: Unit = + val f = new Foo("lol") + println(f.bar[String]("")[Boolean]) \ No newline at end of file diff --git a/tests/pos/i23299.scala b/tests/pos/i23299.scala new file mode 100644 index 000000000000..bc643ac7215d --- /dev/null +++ b/tests/pos/i23299.scala @@ -0,0 +1,17 @@ + +def kek(t: Table, ids: t.Id*) = ??? + +trait Table { + type Id = String +} + +object Table1 extends Table { + val id: Id = "table1_id" +} + +class Table2() extends Table { + val id: Id = "table2_id" +} + +val x = kek(Table1, Table1.id) +val y = kek(Table2(), Table2().id) \ No newline at end of file