You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala>defName[T:TypeTag](name:String):T= implicitly[TypeTag[T]] match {
|case t => newTypeName(name).asInstanceOf[T]
| }
warning: there were 1 deprecation warning(s); re-run with-deprecation for details
Name: [T](name: String)(implicitevidence$1: reflect.runtime.universe.TypeTag[T])T
scala>valX="ASDF"X:String=ASDF
scala> println(q"class ${Name(X)}{ }")
<console>:32:error: exception during macro expansion:
java.util.NoSuchElementException: head of empty list
at scala.collection.immutable.Nil$.head(List.scala:337)
at scala.collection.immutable.Nil$.head(List.scala:334)
at scala.tools.reflect.quasiquotes.Holes$class.parseCardinality(Holes.scala:183)
at scala.tools.reflect.quasiquotes.Quasiquotes.parseCardinality(Quasiquotes.scala:6)
at scala.tools.reflect.quasiquotes.Holes$Hole$.apply(Holes.scala:158)
at scala.tools.reflect.quasiquotes.Placeholders$class.appendHole$1(Placeholders.scala:36)
at scala.tools.reflect.quasiquotes.Placeholders$$anonfun$code$1.apply(Placeholders.scala:48)
at scala.tools.reflect.quasiquotes.Placeholders$$anonfun$code$1.apply(Placeholders.scala:45)
at scala.reflect.internal.util.Collections$class.foreach2(Collections.scala:190)
at scala.reflect.internal.SymbolTable.foreach2(SymbolTable.scala:14)
at scala.tools.reflect.quasiquotes.Placeholders$class.code(Placeholders.scala:45)
at scala.tools.reflect.quasiquotes.Quasiquotes.code$lzycompute(Quasiquotes.scala:6)
at scala.tools.reflect.quasiquotes.Quasiquotes.code(Quasiquotes.scala:6)
at scala.tools.reflect.quasiquotes.Quasiquotes.expandQuasiquote(Quasiquotes.scala:47)
at scala.tools.reflect.FastTrack$$anonfun$1$$anonfun$apply$7$$anonfun$applyOrElse$7.apply(FastTrack.scala:51)
at scala.tools.reflect.FastTrack$$anonfun$1$$anonfun$apply$7$$anonfun$applyOrElse$7.apply(FastTrack.scala:51)
at scala.tools.reflect.FastTrack$FastTrackEntry.apply(FastTrack.scala:35)
at scala.tools.reflect.FastTrack$FastTrackEntry.apply(FastTrack.scala:30)
at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroExpandWithRuntime(Macros.scala:735)
println(q"class ${Name(X)}{ }")
The text was updated successfully, but these errors were encountered:
@densh said:
The real problem here was inference of Nothing as return type of the Name function and quasiquotes' inability to handle that type. The bug in parseCardinality wasn't the real cause of failure here. Both of them are fixed now in my wip branch.
The text was updated successfully, but these errors were encountered: