Skip to content

Commit a946148

Browse files
committed
Disable test failing
Currently type inference for `Expr` of union types is not precise enough as reported in #4867. This implies that currently we cannot have macros of the form ```scala inline def foo(x: T) <: X | Y = ${ ... } ``` but we can always default back to the less informative alternative ```scala inline def foo(x: T) <: Any = ${ ... } ``` Both form will refine the type to the type of the expression returned by the macro.
1 parent 55546eb commit a946148

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
import scala.quoted._
3+
4+
object Macro {
5+
6+
inline def charOrString(inline str: String) <: Any = ${ impl(str) }
7+
8+
def impl(str: String) = if (str.length == 1) str.charAt(0).toExpr else str.toExpr
9+
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Macro._
2+
3+
object Test {
4+
5+
val x: Char = charOrString("1")
6+
val y: String = charOrString("123")
7+
8+
}

0 commit comments

Comments
 (0)