Scala Programming Language
  1. Scala Programming Language
  2. SI-7046

runtime/compile time reflection doesn't see all knownDirectSubclasses

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.10.0, Scala 2.11.0
    • Fix Version/s: Scala 2.11.1-RC1
    • Component/s: None
    • Labels:

      Description

      Unlike, say, annotations or flags, knownDirectSubclasses doesn't get auto-populated and requires a symbol to be pre-initialized to work correctly.

      import scala.reflect.runtime.universe._
      import scala.reflect.runtime.{currentMirror => cm}
      
      sealed class C
      class D extends C
      class E extends C
      
      object Test extends App {
        val c = cm.staticClass("C")
        println(c.knownDirectSubclasses)
        c.typeSignature
        println(c.knownDirectSubclasses)
      }
      
      19:43 ~/Projects/Kepler_7046/sandbox (ticket/7046)$ scalac Test.scala && scala Test
      Set()
      Set(class D, class E)
      

        Issue Links

          Activity

          Hide
          Valentin Churavy added a comment - - edited

          I still run into this on 2.10.3 and the work around with calling c.typeSignature before c.knownDirectSubclasses doesn't work for the reason Adriaan noticed. Forcing a recompile on only the parts which use the macro solve this error, but that is of course not really satisfactory.

          Show
          Valentin Churavy added a comment - - edited I still run into this on 2.10.3 and the work around with calling c.typeSignature before c.knownDirectSubclasses doesn't work for the reason Adriaan noticed. Forcing a recompile on only the parts which use the macro solve this error, but that is of course not really satisfactory.
          Hide
          Adriaan Moors added a comment -

          Sorry, this is not something we can fix due the way the typechecker is implemented. The "fix" would be to remove this method from the reflection API.

          Show
          Adriaan Moors added a comment - Sorry, this is not something we can fix due the way the typechecker is implemented. The "fix" would be to remove this method from the reflection API.
          Hide
          Valentin Churavy added a comment -

          Would it be possible to reschedule the classes where the macro is used for compilation after the TypeCheck has occurred?

          Show
          Valentin Churavy added a comment - Would it be possible to reschedule the classes where the macro is used for compilation after the TypeCheck has occurred?
          Show
          Eugene Burmako added a comment - Discussion: https://groups.google.com/forum/#!topic/scala-internals/LRfKffsPxVA
          Hide
          Eugene Burmako added a comment -

          Actually, I think we can fix this for an important subset of macros: https://groups.google.com/forum/#!topic/scala-user/oJP9aqs88rM

          Show
          Eugene Burmako added a comment - Actually, I think we can fix this for an important subset of macros: https://groups.google.com/forum/#!topic/scala-user/oJP9aqs88rM

            People

            • Assignee:
              Eugene Burmako
              Reporter:
              Eugene Burmako
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:

                Development