Skip to content

Commit 1e8428d

Browse files
committed
Handle multiple type parameter lists in value class methods
VCInlineMethods needed to be extended to this case. Fixes #23266 Also rename previous i23266.scala to i23299.scala to reflect the proper issue for it.
1 parent 01447df commit 1e8428d

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import core.*
77
import Contexts.*, Trees.*, Types.*
88
import DenotTransformers.*, MegaPhase.*
99
import ExtensionMethods.*, ValueClasses.*
10+
import Decorators.*
1011

1112

1213
/** This phase inlines calls to methods of value classes.
@@ -58,12 +59,18 @@ class VCInlineMethods extends MiniPhase with IdentityDenotTransformer {
5859
*/
5960
private def rewire(tree: Tree, mtArgs: List[Tree] = Nil, mArgss: List[List[Tree]] = Nil)
6061
(using Context): Tree =
62+
def noTypeApplyIn(tree: Tree): Boolean = tree match
63+
case _: TypeApply => false
64+
case Apply(fn, _) => noTypeApplyIn(fn)
65+
case _ => true
6166
tree match {
6267
case Apply(qual, mArgs) =>
6368
rewire(qual, mtArgs, mArgs :: mArgss)
6469
case TypeApply(qual, mtArgs2) =>
65-
assert(mtArgs == Nil)
66-
rewire(qual, mtArgs2, mArgss)
70+
if noTypeApplyIn(qual) then
71+
rewire(qual, mtArgs2, mArgss)
72+
else
73+
rewire(qual, mtArgs, mtArgs2 :: mArgss)
6774
case sel @ Select(qual, _) =>
6875
val origMeth = sel.symbol
6976
val origCls = origMeth.enclosingClass

compiler/test/dotc/pos-test-pickling.excludelist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ parsercombinators-new-syntax.scala
139139
hylolib-deferred-given
140140
hylolib-cb
141141
hylolib
142-
i23266.scala
142+
i23299.scala
143143

144144
# typecheckErrors method unpickling
145145
i21415.scala

tests/pos/i23266.scala

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1+
//> using scala 3.7.0
12

2-
def kek(t: Table, ids: t.Id*) = ???
3+
class Foo(v: Any) extends AnyVal:
4+
def bar[X](bar: X)[Y]: Any = v
35

4-
trait Table {
5-
type Id = String
6-
}
7-
8-
object Table1 extends Table {
9-
val id: Id = "table1_id"
10-
}
11-
12-
class Table2() extends Table {
13-
val id: Id = "table2_id"
14-
}
15-
16-
val x = kek(Table1, Table1.id)
17-
val y = kek(Table2(), Table2().id)
6+
@main def run: Unit =
7+
val f = new Foo("lol")
8+
println(f.bar[String]("")[Boolean])

tests/pos/i23299.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
def kek(t: Table, ids: t.Id*) = ???
3+
4+
trait Table {
5+
type Id = String
6+
}
7+
8+
object Table1 extends Table {
9+
val id: Id = "table1_id"
10+
}
11+
12+
class Table2() extends Table {
13+
val id: Id = "table2_id"
14+
}
15+
16+
val x = kek(Table1, Table1.id)
17+
val y = kek(Table2(), Table2().id)

0 commit comments

Comments
 (0)