Closed scabug closed 6 years ago
Imported From: https://issues.scala-lang.org/browse/SI-8384?orig=1 Reporter: @densh Affected Versions: 2.11.0
@soc said: Would any of this be different if classOf was a macro?
@xeno-by said: Yes, I think so. We have MacroExpansionAttachment that allows us to correlate macro expansions and their originals, so we could theoretically pull this off.
Another question is whether we want quasiquotes to match originals or expansions. I can see arguments for both approaches. Denys, wdyt?
@densh said: Quasiquotes already match TypeTree originals albeit not consistently (plan to fix it soon).
I 'm not sure that matching macro originals by default is a good idea though.
@densh said: Workaround:
typecheck(q"classOf[Int]") match {
case q"${const: Constant}" if const.value.isInstanceOf[Type] =>
println(const.asInstanceOf[Type].value)
}
@soc said:
What happens if classOf[X]
doesn't result in a Constant?
@densh said: Can you give an example? I had an impression that it was always represented as constant.
closing all quasiquotes tickets; see https://github.com/scala/bug/issues/10755
Due to change in the shape of classOf tree after typechecking one can't match it:
We also can't really implement syntactic abstraction over this without referential transparency as untyped classOf tree might or might not become a type literal depending on definitions in scope: