diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-08-12 21:25:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-12 21:25:41 -0700 |
commit | 69c6500b5f25e1b4a66d3a62cf40d23877a9023f (patch) | |
tree | cbd5af93970a2d43ca24e676a8d1029700860a85 /test | |
parent | 4b77734b28f82e2573446bd997e739b80de4af1d (diff) | |
parent | 3a3688f64af0755cef5a772d322ac80e08498e54 (diff) | |
download | scala-69c6500b5f25e1b4a66d3a62cf40d23877a9023f.tar.gz scala-69c6500b5f25e1b4a66d3a62cf40d23877a9023f.tar.bz2 scala-69c6500b5f25e1b4a66d3a62cf40d23877a9023f.zip |
Merge pull request #5331 from adriaanm/pr5282-reword
SD-128 fix override checks for default methods
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/sd128.check | 17 | ||||
-rw-r--r-- | test/files/neg/sd128/A.java | 3 | ||||
-rw-r--r-- | test/files/neg/sd128/Test.scala | 19 |
3 files changed, 39 insertions, 0 deletions
diff --git a/test/files/neg/sd128.check b/test/files/neg/sd128.check new file mode 100644 index 0000000000..8f6fcb1213 --- /dev/null +++ b/test/files/neg/sd128.check @@ -0,0 +1,17 @@ +Test.scala:4: error: class C1 inherits conflicting members: + method f in trait A of type ()Int and + method f in trait T of type => Int +(Note: this can be resolved by declaring an override in class C1.) +class C1 extends A with T // error + ^ +Test.scala:5: error: class C2 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 C2.) +class C2 extends T with A // error + ^ +Test.scala:14: error: overriding method f in trait A of type ()Int; + method f needs `override' modifier + def f() = 9999 // need override modifier + ^ +three errors found diff --git a/test/files/neg/sd128/A.java b/test/files/neg/sd128/A.java new file mode 100644 index 0000000000..6774deba2e --- /dev/null +++ b/test/files/neg/sd128/A.java @@ -0,0 +1,3 @@ +interface A { + default int f() { return -10; } +} diff --git a/test/files/neg/sd128/Test.scala b/test/files/neg/sd128/Test.scala new file mode 100644 index 0000000000..66ca3d0940 --- /dev/null +++ b/test/files/neg/sd128/Test.scala @@ -0,0 +1,19 @@ +trait T { + def f = 99 +} +class C1 extends A with T // error +class C2 extends T with A // error + +trait U extends A { + override def f = 999 +} +class D1 extends A with U // OK +class D2 extends U with A // OK + +class E1 extends A { + def f() = 9999 // need override modifier +} + +class E2 extends A { + override def f() = 9999 // OK +} |