Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quasiquotes fail on splicee with generic type #7980

Closed
scabug opened this issue Nov 18, 2013 · 4 comments
Closed

Quasiquotes fail on splicee with generic type #7980

scabug opened this issue Nov 18, 2013 · 4 comments

Comments

@scabug
Copy link

@scabug scabug commented Nov 18, 2013

scala> def Name[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)(implicit evidence$1: reflect.runtime.universe.TypeTag[T])T

scala> val X = "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)}{  }")
@scabug
Copy link
Author

@scabug scabug commented Nov 18, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7980?orig=1
Reporter: @densh
Affected Versions: 2.11.0-M7

@scabug
Copy link
Author

@scabug scabug commented Nov 18, 2013

@densh said:
Failure seem to happen when type which is iterable doesn't have any type arguments. Need to handle that differently in parseCardinality.

@scabug
Copy link
Author

@scabug scabug commented Nov 29, 2013

@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.

@scabug
Copy link
Author

@scabug scabug commented Dec 13, 2013

@densh said:
Fixed in scala/scala#3255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants