Skip to content

Commit 7dad71c

Browse files
committed
added tests for hidden type errors
1 parent f382936 commit 7dad71c

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/hidden-type-errors/Test.scala:6:24 --------------------------------
2+
6 | val x = X.doSomething("XXX")
3+
| ^^^^^^^^^^^^^^^^^^^^
4+
| Found: String
5+
| Required: Int
6+
| This location contains code that was inlined from Test.scala:6
7+
8+
inlined at Test.scala:6:
9+
10+
1 error found
11+
12+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package t12717
2+
3+
import scala.quoted._
4+
5+
object A:
6+
7+
def foo(x:Int): Int = ???
8+
9+
def bar(x:String): String = ???
10+
11+
12+
object X:
13+
14+
inline def doSomething[T](inline x:T):Any = ${
15+
doSomethingImpl('x)
16+
}
17+
18+
def doSomethingImpl[T:Type](x:Expr[T])(using Quotes):Expr[Any] =
19+
import quotes.reflect._
20+
val aTerm = '{A}.asTerm
21+
val xBar = Apply(Select.unique(aTerm,"bar"),List(x.asTerm))
22+
Apply(Select.unique(aTerm,"foo"), List(xBar)).asExpr
23+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package t12717
2+
3+
4+
object Test:
5+
6+
val x = X.doSomething("XXX") // error

0 commit comments

Comments
 (0)