diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-24 03:00:56 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-24 03:00:56 -0700 |
commit | 54c92ca7abe56e9f8947c9d64e72a90ea76c9b86 (patch) | |
tree | cbe44377cb8a22df249de042f782f64dcc315509 /test | |
parent | e0761b4dcbbc3bcbebc6392faa91bf239d247ca0 (diff) | |
parent | 72ee06de4cc0b8c12acf07c892302a3043a1e578 (diff) | |
download | scala-54c92ca7abe56e9f8947c9d64e72a90ea76c9b86.tar.gz scala-54c92ca7abe56e9f8947c9d64e72a90ea76c9b86.tar.bz2 scala-54c92ca7abe56e9f8947c9d64e72a90ea76c9b86.zip |
Merge pull request #733 from retronym/ticket/4989-3
SI-4989 Reject super.x if an intermediate class declares x abstract.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t4989.check | 7 | ||||
-rw-r--r-- | test/files/neg/t4989.scala | 68 |
2 files changed, 75 insertions, 0 deletions
diff --git a/test/files/neg/t4989.check b/test/files/neg/t4989.check new file mode 100644 index 0000000000..814507fc3f --- /dev/null +++ b/test/files/neg/t4989.check @@ -0,0 +1,7 @@ +t4989.scala:14: error: method print in class A cannot be directly accessed from class C because class B redeclares it as abstract + override def print(): String = super.print() // should be an error + ^ +t4989.scala:18: error: method print in class A cannot be directly accessed from trait T because class B redeclares it as abstract + override def print(): String = super.print() // should be an error + ^ +two errors found diff --git a/test/files/neg/t4989.scala b/test/files/neg/t4989.scala new file mode 100644 index 0000000000..e7ff80ed74 --- /dev/null +++ b/test/files/neg/t4989.scala @@ -0,0 +1,68 @@ +abstract class A0 { + def print(): String +} + +class A extends A0 { + def print(): String = "A" +} + +abstract class B extends A { + def print() : String +} + +class C extends B { + override def print(): String = super.print() // should be an error +} + +trait T extends B { + override def print(): String = super.print() // should be an error +} + +class D extends A { + override def print(): String = super.print() // okay +} + + +// it's okay do this when trait are in the mix, as the +// suitable super accessor methods are used. +object ConcreteMethodAndIntermediaryAreTraits { + trait T1 { + def print(): String = "" + } + + trait T2 extends T1 { + def print(): String + } + + class C3 extends T2 { + def print(): String = super.print() // okay + } +} + +object IntermediaryIsTrait { + class T1 { + def print(): String = "" + } + + trait T2 extends T1 { + def print(): String + } + + class C3 extends T2 { + override def print(): String = super.print() // okay + } +} + +object ConcreteMethodIsTrait { + trait T1 { + def print(): String = "" + } + + abstract class T2 extends T1 { + def print(): String + } + + class C3 extends T2 { + override def print(): String = super.print() // okay + } +} |