- Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
SpreeSuitable for a future SpreeSuitable for a future Spreearea:metaprogramming:reflectionIssues related to the quotes reflection APIIssues related to the quotes reflection APIitype:bugitype:crash
Milestone
Description
Compiler version
3.6.4
Minimized code
Macro:
import scala.quoted.* object ExprStringBugMacro { def buildStringCode(using Quotes): Expr[String] = { import quotes.reflect.* val str: String = null val exprString = Expr(str) //It throws NullPointerException println("Macro string: " + exprString.show) exprString } }
Test:
import munit.FunSuite class ExprStringBugTest extends munit.FunSuite { test("NullPoinreException") { buildString } implicit inline def buildString[T]: Unit = ${ ExprStringBugMacro.buildStringCode } }import scala.quoted.* object ExprStringBugMacro { def buildStringCode(using Quotes): Expr[String] = { import quotes.reflect.* //Test value val str: String = null val exprString = Expr(str) println("Macro string: " + exprString.show) exprString } }
Output
Expectation
Absence of the exception
Description
def stringValue: String = value.toString
just does not expect null.
It requres to implement a custom string converter to generate exp from java types.
Metadata
Metadata
Assignees
Labels
SpreeSuitable for a future SpreeSuitable for a future Spreearea:metaprogramming:reflectionIssues related to the quotes reflection APIIssues related to the quotes reflection APIitype:bugitype:crash