Override members does not generate qualified super when not needed

This commit is contained in:
Valentin Kipyatkov
2015-08-25 20:32:07 +03:00
parent dd6702b832
commit 40638de67c
28 changed files with 92 additions and 63 deletions
@@ -1,3 +1,5 @@
// ERROR: 'internal open fun foo(): kotlin.Unit' is already defined in C
// ERROR: 'internal open fun foo(): kotlin.Unit' is already defined in C
interface I {
open fun foo(){}
}
@@ -8,7 +10,7 @@ open class A {
class C : A(), I {
override fun equals(other: Any?): Boolean {
<selection><caret>return super<A>.equals(other)</selection>
<selection><caret>return super.equals(other)</selection>
}
override fun foo() {
@@ -20,10 +22,10 @@ class C : A(), I {
}
override fun hashCode(): Int {
return super<A>.hashCode()
return super.hashCode()
}
override fun toString(): String {
return super<A>.toString()
return super.toString()
}
}
@@ -15,11 +15,11 @@ abstract class B : A() {
class C : B(), I {
override fun equals(other: Any?): Boolean {
<selection><caret>return super<B>.equals(other)</selection>
<selection><caret>return super.equals(other)</selection>
}
override fun f() {
super<B>.f()
super.f()
}
override fun g() {
@@ -27,10 +27,10 @@ class C : B(), I {
}
override fun hashCode(): Int {
return super<B>.hashCode()
return super.hashCode()
}
override fun toString(): String {
return super<B>.toString()
return super.toString()
}
}
@@ -2,6 +2,6 @@ open class A {
open fun foo(`object` : Any): Int = 0
}
class C : A {
class C : A() {
<caret>
}
@@ -2,7 +2,7 @@ open class A {
open fun foo(`object` : Any): Int = 0
}
class C : A {
class C : A() {
override fun foo(`object`: Any): Int {
<selection><caret>return super.foo(`object`)</selection>
}
@@ -1,5 +1,6 @@
// see KT-8942
interface Trait {
fun <A, B : Runnable, E : Map.Entry<A, B>> foo() where B : Cloneable, B : Comparable<B>;
fun <A, B : Runnable, E : Map.Entry<A, B>> foo() where B : Cloneable, B : Comparable<B>
}
class TraitImpl : Trait {
@@ -1,5 +1,8 @@
// ERROR: 'foo' overrides nothing
// ERROR: Class 'TraitImpl' must be declared abstract or implement abstract member internal abstract fun <A, B : java.lang.Runnable, E : kotlin.Map.Entry<A, B>> foo(): kotlin.Unit where B : kotlin.Cloneable, B : kotlin.Comparable<B> defined in Trait
// see KT-8942
interface Trait {
fun <A, B : Runnable, E : Map.Entry<A, B>> foo() where B : Cloneable, B : Comparable<B>;
fun <A, B : Runnable, E : Map.Entry<A, B>> foo() where B : Cloneable, B : Comparable<B>
}
class TraitImpl : Trait {
@@ -1,3 +1,3 @@
class X : java.util.ArrayList<String>(), Runnable {
abstract class X : java.util.ArrayList<String>(), Runnable {
<caret>
}
@@ -1,7 +1,5 @@
import java.util.ArrayList
class X : java.util.ArrayList<String>(), Runnable {
abstract class X : java.util.ArrayList<String>(), Runnable {
override fun size(): Int {
<selection><caret>return super<ArrayList>.size()</selection>
<selection><caret>return super.size()</selection>
}
}
@@ -12,35 +12,35 @@ interface B {
class C : A(), B {
override fun equals(other: Any?): Boolean {
<selection><caret>return super<A>.equals(other)</selection>
<selection><caret>return super.equals(other)</selection>
}
override fun hashCode(): Int {
return super<A>.hashCode()
return super.hashCode()
}
override fun internalFun() {
super<A>.internalFun()
super.internalFun()
}
override val internalProperty: Int
get() = throw UnsupportedOperationException()
override fun protectedFun() {
super<A>.protectedFun()
super.protectedFun()
}
override val protectedProperty: Int
get() = throw UnsupportedOperationException()
override fun publicFun() {
super<A>.publicFun()
super.publicFun()
}
override val publicProperty: Int
get() = throw UnsupportedOperationException()
override fun toString(): String {
return super<A>.toString()
return super.toString()
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ abstract class C<A> {
fun f() {
class R
object : C<R> {
object : C<R>() {
<caret>
}
}
@@ -5,7 +5,7 @@ abstract class C<A> {
fun f() {
class R
object : C<R> {
object : C<R>() {
override fun f(a: R) {
<selection><caret>throw UnsupportedOperationException()</selection>
}
@@ -12,18 +12,18 @@ class C : A(), B {
}
override fun equals(other: Any?): Boolean {
return super<A>.equals(other)
return super.equals(other)
}
override fun foo() {
super<A>.foo()
super.foo()
}
override fun hashCode(): Int {
return super<A>.hashCode()
return super.hashCode()
}
override fun toString(): String {
return super<A>.toString()
return super.toString()
}
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: println
open class A() {
open val method : () -> Unit? = {println("hello")}
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: println
interface A<T> {
fun foo(value : T) : Unit = println(value)
}
@@ -1,6 +1,6 @@
package foo;
class A {
public class A {
public int getAnswer(String[] array, int number, Object value) {
return 42;
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: println
open class A() {
open fun foo(value : Int) : Unit = println(value)
open val bar : Int = 0
@@ -1,5 +1,5 @@
interface A {
fun foo(value : String) : Unit = 0
fun foo(value : String) : Unit {}
}
class C : A {
@@ -1,5 +1,5 @@
interface A {
fun foo(value : String) : Unit = 0
fun foo(value : String) : Unit {}
}
class C : A {
@@ -4,19 +4,19 @@ interface I {
class C : A(), I {
override fun equals(other: Any?): Boolean {
<selection><caret>return super<A>.equals(other)</selection>
<selection><caret>return super.equals(other)</selection>
}
override fun hashCode(): Int {
return super<A>.hashCode()
return super.hashCode()
}
override fun toString(): String {
return super<A>.toString()
return super.toString()
}
override fun x() {
super<A>.x()
super.x()
}
override fun z() {
@@ -10,6 +10,6 @@ class Outer {
class X : Outer.Inner1, Outer.Inner2 {
override fun f() {
<selection><caret>super<Outer.Inner1>.f()</selection>
<selection><caret>super.f()</selection>
}
}
@@ -5,4 +5,4 @@ public class Impl : ArrayFactory {
<caret>
}
val array: Array<String>
val array: Array<String> = emptyArray()
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: emptyArray
//KT-1602
import lib.ArrayFactory
@@ -7,4 +8,4 @@ public class Impl : ArrayFactory {
}
}
val array: Array<String>
val array: Array<String> = emptyArray()
@@ -18,15 +18,15 @@ interface I3 {
abstract class B : I2, A(), I3 {
override fun a() {
<selection><caret>super<A>.a()</selection>
<selection><caret>super.a()</selection>
}
override fun equals(other: Any?): Boolean {
return super<A>.equals(other)
return super.equals(other)
}
override fun hashCode(): Int {
return super<A>.hashCode()
return super.hashCode()
}
override fun i() {
@@ -42,6 +42,6 @@ abstract class B : I2, A(), I3 {
}
override fun toString(): String {
return super<A>.toString()
return super.toString()
}
}