Skip to content

Commit bbe2dde

Browse files
mbovelhamzaremmalHarrisL2ajafri2001
committed
Fix Constant tag of Expr(null: String)
Co-authored-by: Hamza Remmal <[email protected]> Co-authored-by: HarrisL2 <[email protected]> Co-authored-by: Abdullah Arif Jafri <[email protected]>
1 parent fb6cc9b commit bbe2dde

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
25292529
end StringConstantTypeTest
25302530

25312531
object StringConstant extends StringConstantModule:
2532-
def apply(x: String): StringConstant = dotc.core.Constants.Constant(x)
2532+
def apply(x: String): StringConstant = dotc.core.Constants.Constant(x: Any)
25332533
def unapply(constant: StringConstant): Some[String] = Some(constant.stringValue)
25342534
end StringConstant
25352535

tests/run-macros/i23008.check

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
null
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.quoted.*
2+
3+
object Macros {
4+
inline def buildString = ${buildStringCode}
5+
6+
def buildStringCode(using Quotes): Expr[String] = {
7+
import quotes.reflect.*
8+
val str: String = null
9+
val exprString = Expr(str)
10+
Expr(exprString.show)
11+
}
12+
}

tests/run-macros/i23008/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@main def Test =
2+
println(Macros.buildString)

0 commit comments

Comments
 (0)