Skip to content

Commit f67882d

Browse files
committed
Add regression test
Closes #14001
1 parent 86b4db3 commit f67882d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/neg-macros/i14001/Macro_1.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package test
2+
import scala.quoted.*
3+
object Y {
4+
inline def testStuff[T]: T =
5+
${testStuffImpl} // problem: T inferred to Nothing
6+
// solution add T explicitly
7+
8+
def testStuffImpl[T: Type](using Quotes): Expr[T] = {
9+
import quotes.reflect.*
10+
11+
Apply(
12+
Ref(Symbol.requiredMethod("test.A.C.apply")),
13+
List(Literal(IntConstant(1)))
14+
).asExprOf[T]
15+
}
16+
}

tests/neg-macros/i14001/Test_2.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test
2+
trait B {
3+
case class C(i: Int)
4+
}
5+
6+
object A extends B
7+
8+
object X {
9+
val z = Y.testStuff[A.C] // error: Expr cast exception
10+
}

0 commit comments

Comments
 (0)