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

StackOverflow in importers when a symbol has an existential info #8833

Closed
scabug opened this issue Sep 2, 2014 · 5 comments
Closed

StackOverflow in importers when a symbol has an existential info #8833

scabug opened this issue Sep 2, 2014 · 5 comments
Assignees

Comments

@scabug
Copy link

scabug commented Sep 2, 2014

import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}
import scala.tools.reflect.ToolBox

case class C[T](i: T)

object Test extends App {
  calculate(C(2))
  def calculate(c: C[_]): Unit = {
    val tree = q"${reify(c).tree}.i"
    cm.mkToolBox().eval(tree)
  }
}
...
	at scala.reflect.internal.Symbols$Symbol.orElse(Symbols.scala:2498)
	at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:193)
	at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
	at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
	at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
	at scala.reflect.internal.Importers$StandardImporter$$anonfun$recreateType$6.apply(Importers.scala:253)
	at scala.reflect.internal.Importers$StandardImporter$$anonfun$recreateType$6.apply(Importers.scala:253)
	at scala.collection.immutable.List.map(List.scala:272)
	at scala.reflect.internal.Importers$StandardImporter.recreateType(Importers.scala:253)
	at scala.reflect.internal.Importers$StandardImporter.importType(Importers.scala:284)
	at scala.reflect.internal.Importers$StandardImporter.recreateSymbol(Importers.scala:107)
	at scala.reflect.internal.Importers$StandardImporter.scala$reflect$internal$Importers$StandardImporter$$cachedRecreateSymbol$1(Importers.scala:145)
	at scala.reflect.internal.Importers$StandardImporter$$anonfun$recreateOrRelink$1$1.apply(Importers.scala:194)
	at scala.reflect.internal.Importers$StandardImporter$$anonfun$recreateOrRelink$1$1.apply(Importers.scala:193)
	at scala.reflect.internal.Symbols$Symbol.orElse(Symbols.scala:2498)
	at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:193)
	at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
	at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
	at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
	at scala.reflect.internal.Importers$StandardImporter$$anonfun$recreateType$6.apply(Importers.scala:253)
...
@scabug
Copy link
Author

scabug commented Sep 2, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8833?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.4, 2.11.2

@scabug
Copy link
Author

scabug commented Sep 2, 2014

@xeno-by said:
The problem is caused by the existential skolem used in the info of the FreeTermSymbol that represents the captured parameter c. This skolem has the free term as its owner, and that leads to a SO. Importing the free term recurs into importing the info, which recurs into importing all parts of the type, which recurs into importing the skolem, which recurs into importing its owner, etc ad infinitum.

@scabug
Copy link
Author

scabug commented Sep 2, 2014

@xeno-by said (edited on Sep 2, 2014 9:06:13 AM UTC):
The workaround is to dissociate the skolem from the free term, e.g. by creating the info for the free term manually like this.

2.10.x:

-val tree = q"${reify(c).tree}"
+val csym = build.newFreeTerm("c", c)
+build.setTypeSignature(csym, typeOf[C[_]])
+val tree = q"$csym.i"

2.11.x:

-val tree = q"${reify(c).tree}"
+val csym = internal.reificationSupport.newFreeTerm("c", c)
+internal.reificationSupport.setInfo(csym, typeOf[C[_]])
+val tree = q"$csym.i"

@SethTisue
Copy link
Member

closing all quasiquotes tickets; see #10755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants