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

Symbols that come from knownDirectSubclasses aren't initialized #7755

Closed
scabug opened this issue Aug 16, 2013 · 3 comments
Closed

Symbols that come from knownDirectSubclasses aren't initialized #7755

scabug opened this issue Aug 16, 2013 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Aug 16, 2013

import scala.reflect.macros.Context
import language.experimental.macros

object Macros {
  def impl[T: c.WeakTypeTag](c: Context) = {
    import c.universe._
    val sym = weakTypeOf[T].typeSymbol.asClass
    val left = sym.knownDirectSubclasses.toList.find(_.name.toString == "Left").get.asClass
    println(left.isCaseClass)
    c.literalUnit
  }

  def foo[T] = macro impl[T]
}
object Test extends App {
  Macros.foo[Either[String, Int]]
}

This code incorrectly prints false. If one inserts a call to "left.typeSignature" before the print, the code will correctly print true.

@scabug
Copy link
Author

scabug commented Aug 16, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7755?orig=1
Reporter: @milessabin
Affected Versions: 2.10.2, 2.11.0-M4
See #7046

@scabug
Copy link
Author

scabug commented Jan 29, 2014

@xeno-by said:
Fixing this would be a challenge of a magnitude similar to #7046, because both of these issues are about lazy completers. In this particular case we're a bit more lucky, since we could auto-force symbols returned by knownDirectSubclasses, but that might lead to spurious cyclic reference errors, but I would prefer not to do that inside the reflection framework.

@scabug
Copy link
Author

scabug commented Feb 21, 2014

@retronym said:
Changing resolution to Wont Fix after reading the comments and related ticket.

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

2 participants