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

Method call in subclass ruins protected[this]-ness once again

    Details

      Description

      trait A {
       trait C[+T] { 
         protected[this] def f(t: T) {}
       } 
       
       trait D[T] extends C[T] {
         def g(t: T) { f(t) } 
       }
      }
      

      gives:

      a.scala:3: error: covariant type T occurs in contravariant position in type T of value t
         protected[this] def f(t: T) {}
                               ^
      one error found
      

      Compiles if `g` doesn't call `f` or if `C` and `D` are top-level traits. Seems to be related to SI-465.

        Activity

        Hide
        Paul Phillips added a comment -

        See also SI-4345, which I'm glad I didn't assume was a duplicate because the fix for that seems to have left this unaffected.

        Show
        Paul Phillips added a comment - See also SI-4345 , which I'm glad I didn't assume was a duplicate because the fix for that seems to have left this unaffected.
        Hide
        Ingo Maier added a comment -

        Is there a chance of this ever getting fixed? I keep coming up with the weirdest workarounds. If this exposes some loophole that is too hard to fix, it would be good to know.

        Show
        Ingo Maier added a comment - Is there a chance of this ever getting fixed? I keep coming up with the weirdest workarounds. If this exposes some loophole that is too hard to fix, it would be good to know.
        Hide
        Paul Phillips added a comment -

        I took a look, I think it was easy to fix. I probably have to go to the dentist before the tests finish, but maybe you will see a fix in the next couple hours.

        Show
        Paul Phillips added a comment - I took a look, I think it was easy to fix. I probably have to go to the dentist before the tests finish, but maybe you will see a fix in the next couple hours.
        Hide
        Paul Phillips added a comment -

        03f32bd22f

        Show
        Paul Phillips added a comment - 03f32bd22f
        Hide
        Ingo Maier added a comment -

        Awesome, that was quick! Thanks, Paul!

        Show
        Ingo Maier added a comment - Awesome, that was quick! Thanks, Paul!

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Ingo Maier
            TracCC:
            Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development