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

Cannot get symbol for trait's implementation class

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      This code says it all:

      
      /** 
       * Tries to load a symbol for the `Foo$class` using Scala reflection.  
       * Since trait implementation classes do not get pickling information
       * symbol for them should be created using fallback mechanism
       * that exposes Java reflection information dressed up in
       * a Scala symbol.
       **/
      object Test extends App {
        import scala.reflect.mirror
        val name = manifest[Foo].erasure.getName + "$class"
        val implClass = Class.forName(name)
        val symbol = mirror.classToSymbol(implClass)
        assert(symbol != mirror.NoSymbol)
      }
      
      trait Foo {
        def bar = 1
      }
      

      It fails at the moment for mysterious reason. Trying to investigate it.

        Activity

        Hide
        Commit Message Bot added a comment -

        (grek in r25982) Allow to load $class classes using Scala reflection.

        Tweaked implementation of invalidClassName method
        to exclude *$class clasess from the set of invalid
        names. It's not exactly clear what was the intent
        of this method in first place so I'm not sure if
        it's the best way to fix SI-5176. Added test-case
        that covers this issue.

        Fixes SI-5176. Review by odersky.

        Show
        Commit Message Bot added a comment - (grek in r25982 ) Allow to load $class classes using Scala reflection. Tweaked implementation of invalidClassName method to exclude *$class clasess from the set of invalid names. It's not exactly clear what was the intent of this method in first place so I'm not sure if it's the best way to fix SI-5176 . Added test-case that covers this issue. Fixes SI-5176 . Review by odersky.

          People

          • Assignee:
            Grzegorz Kossakowski
            Reporter:
            Grzegorz Kossakowski
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development