Closed
Description
$ cat A.java
interface A { default int f() { return -10; } }
$ cat Test.scala
trait T { def f = 99 }
class C extends A with T
$ javac A.java
$ qsc Test.scala
$ qs
scala> new C().f
res0: Int = 99
Swapping the order of parents gives the error:
$ cat Test.scala
trait T { def f = 99 }
class C extends T with A
$ qsc Test.scala
Test.scala:5: error: class C inherits conflicting members:
method f in trait T of type => Int and
method f in trait A of type ()Int
(Note: this can be resolved by declaring an override in class C.)
class C extends T with A
^
one error found
also, if A
is a class instead of an interface, we get the error:
$ cat A.java
public class A { public int f() { return -10; } }
$ cat Test.scala
trait T { def f = 99 }
class C extends A with T
$ javac A.java
$ qsc Test.scala
Test.scala:5: error: class C inherits conflicting members:
method f in class A of type ()Int and
method f in trait T of type => Int
(Note: this can be resolved by declaring an override in class C.)
class C extends A with T
^
one error found