Details

      Description

      this code should compile, but doesn't:
      (from http://stackoverflow.com/questions/11110409/scala-path-dependent-return-type-from-parameter)

      class Test {
        def newComponent(u: Universe): u.Component = ???
      
        class Universe { self =>
          class Component
      
          newComponent(this): this.Component // error, but should be fine since this is a stable reference
          newComponent(self): self.Component // error, but should be fine since this is a stable reference
          newComponent(self): this.Component // error, but should be fine since this is a stable reference
          newComponent(this): self.Component // error, but should be fine since this is a stable reference
      
          val u = this
          newComponent(u): u.Component // ok
        }
      }
      

        Issue Links

          Activity

          Hide
          Rich Oliver added a comment - - edited

          When the bug is fixed could we have a clarification of what functionality self types support in terms of path dependant types. The self in the above examples is a simple this alias. But say we have:

          class Outer

          { val myInner: Inner class Inner }

          class OtherA

          { selfA: Outer => }

          class OtherB

          { selfB: Outer.myInner => }

          class OtherC

          { selfC: Outer#Inner }

          What should compile and if it will, can the compiler track the path dependant self references?

          Show
          Rich Oliver added a comment - - edited When the bug is fixed could we have a clarification of what functionality self types support in terms of path dependant types. The self in the above examples is a simple this alias. But say we have: class Outer { val myInner: Inner class Inner } class OtherA { selfA: Outer => } class OtherB { selfB: Outer.myInner => } class OtherC { selfC: Outer#Inner } What should compile and if it will, can the compiler track the path dependant self references?
          Hide
          Adriaan Moors added a comment -

          please take clarification questions to scala-language, where everybody benefits (and you benefit from a bigger pool of potential answerererers)

          Show
          Adriaan Moors added a comment - please take clarification questions to scala-language, where everybody benefits (and you benefit from a bigger pool of potential answerererers)
          Show
          Adriaan Moors added a comment - https://github.com/scala/scala/pull/991
          Hide
          Adriaan Moors added a comment - - edited
          Show
          Adriaan Moors added a comment - - edited https://github.com/scala/scala/pull/1764

            People

            • Assignee:
              Adriaan Moors
              Reporter:
              Adriaan Moors
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development