Skip to content

Commit 2421437

Browse files
authored
Add regression test (#16862)
Fixes #15475
2 parents 006e2e4 + 00d3079 commit 2421437

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

tests/pos-macros/i15475.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def test =
2+
transform {
3+
val a: Seq[Generic[?]] = ???
4+
a.foreach { to =>
5+
to.mthd()
6+
}
7+
}
8+
9+
transparent inline def transform[T](expr: T): T = ???
10+
11+
trait Generic[+T] {
12+
def mthd(): Generic[T] = ???
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package x
2+
3+
import scala.quoted.*
4+
5+
6+
transparent inline def xtransform[T](inline expr:T) = ${
7+
X.transform('expr)
8+
}
9+
10+
object X {
11+
12+
def transform[T:Type](x: Expr[T])(using Quotes):Expr[T] = {
13+
import quotes.reflect.*
14+
x
15+
}
16+
17+
}

tests/pos-macros/i15475a/Test_2.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package x
2+
3+
def hello = {
4+
xtransform {
5+
val a: Seq[Generic[?]] = null
6+
a
7+
.foreach { to =>
8+
to.mthd()
9+
}
10+
}
11+
}
12+
13+
trait Generic[+T] {
14+
def mthd(): Generic[T] = this
15+
}

0 commit comments

Comments
 (0)