Open
Description
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_152).
Type in expressions for evaluation. Or try :help.
scala> trait Base {
| type Foo
| type Bar
| }
defined trait Base
scala> trait OK extends Base {
| trait InnerImpl
| type Foo <: Bar with InnerImpl
| }
defined trait OK
scala> trait Error extends Base {
| trait InnerImpl
| type Foo <: InnerImpl with Bar
| }
<console>:14: error: overriding type Foo in trait Base with bounds;
type Foo is a volatile type; cannot override a type with non-volatile upper bound
type Foo <: InnerImpl with Bar
^
scala> trait Error2 extends Base {
| trait InnerImpl { def abstractMethod: Unit }
| type Foo <: Bar with InnerImpl
| }
<console>:14: error: overriding type Foo in trait Base with bounds;
type Foo is a volatile type; cannot override a type with non-volatile upper bound
type Foo <: Bar with InnerImpl
^
The only difference between trait OK
and trait Error
is the order of super types of Foo
. I expect all the three examples compile.