Details

      Description

      Essentially the same problem volatility was introduced to deal with, but in this case there are never any abstract types involved:

      object Test extends Application {
       trait A
       trait B extends A
       
        trait C {
          trait D { type T >: B <: A }
          val y: (D with this.type)#T = new B { }
        }
       
        class D extends C {
          trait E
          type T = E 
          def frob(arg : E) : E = arg
          frob(y)
        }
       
        new D
      }
      

      Yielding:

      java.lang.ExceptionInInitializerError
              at Test.main(volatile-intersection.scala)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:585)
      	at scala.tools.nsc.ObjectRunner$$$$anonfun$$run$$1.apply(ObjectRunner.scala:75)
      	at scala.tools.nsc.ObjectRunner$$.withContextClassLoader(ObjectRunner.scala:49)
      	at scala.tools.nsc.ObjectRunner$$.run(ObjectRunner.scala:74)
      	at scala.tools.nsc.MainGenericRunner$$.main(MainGenericRunner.scala:154)
      	at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
      Caused by: java.lang.ClassCastException: Test$$C$$$$anon$$1
      	at Test$$D.<init>(volatile-intersection.scala:14)
      	at Test$$.<init>(volatile-intersection.scala:17)
      	at Test$$.<clinit>(volatile-intersection.scala)
      	... 10 more
      

        Attachments

          Issue Links

            Activity

            Hide
            washburn Geoffrey Alan Washburn added a comment -

            It is worth noting that is it not necessary to use "this.type" or an equivalent self-name:

            object Test extends Application {
             trait A
             trait B extends A
             
              trait C {
                val x : AnyRef
                trait D { type T >: B <: A }
                val y: (D with x.type)#T = new B { }
              }
             
              class D extends C {
                trait E
                val x : AnyRef { type T = E} = null
                def frob(arg : E) : E = arg
                frob(y)
              }
             
              new D
            }

            Show
            washburn Geoffrey Alan Washburn added a comment - It is worth noting that is it not necessary to use "this.type" or an equivalent self-name: object Test extends Application { trait A trait B extends A   trait C { val x : AnyRef trait D { type T >: B <: A } val y: (D with x.type)#T = new B { } }   class D extends C { trait E val x : AnyRef { type T = E} = null def frob(arg : E) : E = arg frob(y) }   new D }
            Hide
            soc Simon Ochsenreither added a comment -

            Both throw a CCE instead now:

            }}
            java.lang.ClassCastException: Test$C$$anon$1 cannot be cast to Test$D$E
            	at Test$D.<init>(<console>:21)
            	at Test$.<init>(<console>:24)
            	at Test$.<clinit>(<console>)
            	at .<init>(<console>:9)
            	at .<clinit>(<console>)
            	at .<init>(<console>:11)
            	at .<clinit>(<console>)
             
            {{

            Show
            soc Simon Ochsenreither added a comment - Both throw a CCE instead now: }} java.lang.ClassCastException: Test$C$$anon$1 cannot be cast to Test$D$E at Test$D.<init>(<console>:21) at Test$.<init>(<console>:24) at Test$.<clinit>(<console>) at .<init>(<console>:9) at .<clinit>(<console>) at .<init>(<console>:11) at .<clinit>(<console>)   {{
            Hide
            heathermiller Heather Miller added a comment -

            Still throws the above class cast exception.

            This shouldn't compile. The type of y is able to be changed through x.

            Test case added, test/pending/neg/t1557.scala. (pull request)

            Show
            heathermiller Heather Miller added a comment - Still throws the above class cast exception. This shouldn't compile. The type of y is able to be changed through x. Test case added, test/pending/neg/t1557.scala. ( pull request )
            Hide
            extempore Paul Phillips added a comment -

            Sorry you have not been fixed, SI-1557, but now I am consolidating you with some related soundness issues under SI-7278.

            Show
            extempore Paul Phillips added a comment - Sorry you have not been fixed, SI-1557 , but now I am consolidating you with some related soundness issues under SI-7278 .

              People

              • Assignee:
                odersky Martin Odersky
                Reporter:
                washburn Geoffrey Alan Washburn
                TracCC:
                Ismael Juma
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: