summaryrefslogtreecommitdiff
path: root/test/files/neg/sd128
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2016-07-15 11:32:38 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-08-12 17:34:10 -0700
commit3a3688f64af0755cef5a772d322ac80e08498e54 (patch)
tree6f1f5f82062d6fe18d1199b70ded064a4a6d607d /test/files/neg/sd128
parent3e0b2c2b14bdc26a40887af7a375077565f004b3 (diff)
downloadscala-3a3688f64af0755cef5a772d322ac80e08498e54.tar.gz
scala-3a3688f64af0755cef5a772d322ac80e08498e54.tar.bz2
scala-3a3688f64af0755cef5a772d322ac80e08498e54.zip
SD-128 fix override checks for default methods
The check for inheriting two conflicting members was wrong for default methods, leading to a missing error message. We were also not issuing "needs `override' modifier" when overriding a default method. Removes two methods: - `isDeferredOrJavaDefault` had a single use that is removed in this commit. - `isDeferredNotJavaDefault` is redundant with `isDeferred`, because no default method has the `DEFERRED` flag: - For symbols originating in the classfile parser this was the case from day one: default methods don't receive the `DEFERRED` flag. Only abstract interface methods do, as they have the `JAVA_ACC_ABSTRACT` flag in bytecode, which the classfile parser translates to `DEFERRED`. - For symbols created by the Java source parser, we don't add the `DEFERRED` to default methods anymore since 373db1e. Fixes scala/scala-dev#128
Diffstat (limited to 'test/files/neg/sd128')
-rw-r--r--test/files/neg/sd128/A.java3
-rw-r--r--test/files/neg/sd128/Test.scala19
2 files changed, 22 insertions, 0 deletions
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
+}