We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b17deea commit dd21107Copy full SHA for dd21107
tests/pos/quote-whitebox/Macro_1.scala
@@ -0,0 +1,10 @@
1
+
2
+import scala.quoted._
3
4
+object Macro {
5
6
+ inline def charOrString(inline str: String) <: Char | String = ${ impl(str) }
7
8
+ def impl(str: String) = if (str.length == 1) str.charAt(0).toExpr else str.toExpr
9
10
+}
tests/pos/quote-whitebox/Test_2.scala
@@ -0,0 +1,8 @@
+import Macro._
+object Test {
+ val x: Char = charOrString("1")
+ val y: String = charOrString("123")
0 commit comments