Restrict conditions for @JvmDefault super calls
Condition was too strict if we actually make super call through super class. Diagnostic is redundant cause there isn't breaking change depending on interface method generation strategy.
This commit is contained in:
+2
-5
@@ -25,11 +25,8 @@ class JvmDefaultSuperCallChecker : CallChecker {
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor as? CallableMemberDescriptor ?: return
|
||||
if (!resultingDescriptor.hasJvmDefaultAnnotation()) return
|
||||
|
||||
val containingDeclaration = DescriptorUtils.unwrapFakeOverrideToAnyDeclaration(resultingDescriptor).containingDeclaration
|
||||
if (DescriptorUtils.isInterface(containingDeclaration) ||
|
||||
DescriptorUtils.isAnnotationClass(containingDeclaration)
|
||||
) {
|
||||
if (DescriptorUtils.isInterface(resultingDescriptor.containingDeclaration)) {
|
||||
context.trace.report(ErrorsJvm.USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL.on(reportOn))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+26
-2
@@ -27,12 +27,36 @@ open class <!JVM_DEFAULT_THROUGH_INHERITANCE!>Foo2<!> : B
|
||||
|
||||
open class Bar : Foo2() {
|
||||
override fun test() {
|
||||
super.<!USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL!>test<!>()
|
||||
super.test()
|
||||
}
|
||||
}
|
||||
|
||||
class Bar2 : Bar() {
|
||||
open class Bar2 : Bar() {
|
||||
override fun test() {
|
||||
super.test()
|
||||
}
|
||||
}
|
||||
|
||||
class <!JVM_DEFAULT_THROUGH_INHERITANCE!>ManySupers<!>: Foo2(), B {
|
||||
fun foo() {
|
||||
super<Foo2>.test()
|
||||
super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>B<!>>.<!USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL!>test<!>()
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>test<!>()
|
||||
}
|
||||
}
|
||||
|
||||
class <!JVM_DEFAULT_THROUGH_INHERITANCE!>ManySupers2<!>: Foo2(), C {
|
||||
fun foo() {
|
||||
super<Foo2>.test()
|
||||
super<C>.<!USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL!>test<!>()
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>test<!>()
|
||||
}
|
||||
}
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class <!JVM_DEFAULT_THROUGH_INHERITANCE!>ManySupers3<!><!>: Bar2(), C {
|
||||
fun foo() {
|
||||
super<Bar2>.test()
|
||||
super<C>.<!USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL!>test<!>()
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>test<!>()
|
||||
}
|
||||
}
|
||||
+28
-1
@@ -22,7 +22,7 @@ public open class Bar : Foo2 {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Bar2 : Bar {
|
||||
public open class Bar2 : Bar {
|
||||
public constructor Bar2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -52,3 +52,30 @@ public open class Foo2 : B {
|
||||
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class ManySupers : Foo2, B {
|
||||
public constructor ManySupers()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@kotlin.jvm.JvmDefault public open override /*2*/ /*fake_override*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class ManySupers2 : Foo2, C {
|
||||
public constructor ManySupers2()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@kotlin.jvm.JvmDefault public open override /*2*/ /*fake_override*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class ManySupers3 : Bar2, C {
|
||||
public constructor ManySupers3()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user