I am using a macro annotation from Spotify's Scio library. I would like to define a variable of String
type and annotate like this:
val schemaString = """schema here"""
@BigQueryType.fromSchema(outputString) class BigQuery
This does not compile, however, if I annotate the String
directly, it works:
@BigQueryType.fromSchema("""schema here""") class BigQuery
Looking at the code, this matching is done here, essentially the code is as follows:
def str(tree: c.Tree) = tree match {
// "string literal"
case Literal(Constant(s: String)) => s
// "string literal".stripMargin
case Select(Literal(Constant(s: String)), TermName("stripMargin")) => s.stripMargin
case _ => c.abort(c.enclosingPosition, errorMessage)
}
The question is why this does not match the variable, but does the string? And if there is any way to make the first example work?