Support default method super calls within @JvmDefault ones
This commit is contained in:
+41
-10
@@ -21,10 +21,12 @@ import org.jetbrains.kotlin.config.JvmTarget
|
|||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor
|
||||||
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
||||||
|
import org.jetbrains.kotlin.resolve.annotations.hasJvmDefaultAnnotation
|
||||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpression
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpression
|
||||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
|
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
|
||||||
@@ -36,7 +38,8 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker
|
|||||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||||
val supportDefaults = jvmTarget == JvmTarget.JVM_1_8
|
val supportDefaults = jvmTarget == JvmTarget.JVM_1_8
|
||||||
|
|
||||||
val descriptor = resolvedCall.resultingDescriptor as? FunctionDescriptor ?: return
|
val descriptor = resolvedCall.resultingDescriptor as? CallableMemberDescriptor ?: return
|
||||||
|
if (descriptor is JavaPropertyDescriptor) return
|
||||||
|
|
||||||
if (!supportDefaults &&
|
if (!supportDefaults &&
|
||||||
isStaticDeclaration(descriptor) &&
|
isStaticDeclaration(descriptor) &&
|
||||||
@@ -53,21 +56,49 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker
|
|||||||
val realDescriptor = unwrapFakeOverride(descriptor)
|
val realDescriptor = unwrapFakeOverride(descriptor)
|
||||||
val realDescriptorOwner = realDescriptor.containingDeclaration as? ClassDescriptor ?: return
|
val realDescriptorOwner = realDescriptor.containingDeclaration as? ClassDescriptor ?: return
|
||||||
|
|
||||||
if (isInterface(realDescriptorOwner) && realDescriptor is JavaCallableMemberDescriptor) {
|
if (isInterface(realDescriptorOwner) && (realDescriptor is JavaCallableMemberDescriptor || realDescriptor.hasJvmDefaultAnnotation())) {
|
||||||
val classifier = getSuperCallLabelTarget(context.trace.bindingContext, superCallExpression)
|
val bindingContext = context.trace.bindingContext
|
||||||
//is java interface default method called from trait
|
val thisForSuperCall = getSuperCallLabelTarget(bindingContext, superCallExpression)
|
||||||
if (classifier != null && DescriptorUtils.isInterface(classifier)) {
|
|
||||||
context.trace.report(INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(reportOn))
|
if (thisForSuperCall != null && DescriptorUtils.isInterface(thisForSuperCall)) {
|
||||||
|
val declarationWithCall = findInterfaceMember(thisForSuperCall, superCallExpression, bindingContext)
|
||||||
|
if (declarationWithCall?.hasJvmDefaultAnnotation() == false) {
|
||||||
|
context.trace.report(INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(reportOn))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!supportDefaults) {
|
|
||||||
val diagnostic = if (isDefaultCallsProhibited(context)) DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET
|
if (!supportDefaults) {
|
||||||
|
val diagnostic =
|
||||||
|
if (isDefaultCallsProhibited(context)) DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET
|
||||||
context.trace.report(diagnostic.on(reportOn))
|
context.trace.report(diagnostic.on(reportOn))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun findInterfaceMember(
|
||||||
|
descriptorToSearch: ClassDescriptor,
|
||||||
|
startExpression: KtSuperExpression,
|
||||||
|
bindingContext: BindingContext
|
||||||
|
): CallableMemberDescriptor? {
|
||||||
|
val parents = generateSequence({ startExpression.parent }) { it.parent }
|
||||||
|
parents.fold<PsiElement, PsiElement>(startExpression) { child, parent ->
|
||||||
|
if (parent is KtClassBody &&
|
||||||
|
descriptorToSearch == bindingContext.get(BindingContext.CLASS, parent.parent)
|
||||||
|
) {
|
||||||
|
return when (child) {
|
||||||
|
is KtNamedFunction -> bindingContext.get(BindingContext.FUNCTION, child)
|
||||||
|
is KtProperty -> bindingContext.get(BindingContext.VARIABLE, child) as? PropertyDescriptor
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
} else parent
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
private fun isDefaultCallsProhibited(context: CallCheckerContext) =
|
private fun isDefaultCallsProhibited(context: CallCheckerContext) =
|
||||||
context.languageVersionSettings.supportsFeature(LanguageFeature.DefaultMethodsCallFromJava6TargetError)
|
context.languageVersionSettings.supportsFeature(LanguageFeature.DefaultMethodsCallFromJava6TargetError)
|
||||||
|
|
||||||
private fun getSuperCallLabelTarget(
|
private fun getSuperCallLabelTarget(
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
|||||||
MAP.put(NO_REFLECTION_IN_CLASS_PATH, "Call uses reflection API which is not found in compilation classpath. " +
|
MAP.put(NO_REFLECTION_IN_CLASS_PATH, "Call uses reflection API which is not found in compilation classpath. " +
|
||||||
"Make sure you have kotlin-reflect.jar in the classpath");
|
"Make sure you have kotlin-reflect.jar in the classpath");
|
||||||
|
|
||||||
MAP.put(INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER, "Interfaces can't call Java default methods via super");
|
MAP.put(INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER, "Interfaces can call default methods via super only within @JvmDefault members. Please annotate the containing interface member with @JvmDefault");
|
||||||
MAP.put(SUBCLASS_CANT_CALL_COMPANION_PROTECTED_NON_STATIC, "Using non-JVM static members protected in the superclass companion is unsupported yet");
|
MAP.put(SUBCLASS_CANT_CALL_COMPANION_PROTECTED_NON_STATIC, "Using non-JVM static members protected in the superclass companion is unsupported yet");
|
||||||
|
|
||||||
MAP.put(ErrorsJvm.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS,
|
MAP.put(ErrorsJvm.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS,
|
||||||
|
|||||||
+323
@@ -0,0 +1,323 @@
|
|||||||
|
// !API_VERSION: 1.3
|
||||||
|
// !ENABLE_JVM_DEFAULT
|
||||||
|
// !JVM_TARGET: 1.8
|
||||||
|
|
||||||
|
public interface KInterface {
|
||||||
|
@JvmDefault
|
||||||
|
fun test(): String {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
val property: String
|
||||||
|
get() = "OK"
|
||||||
|
|
||||||
|
|
||||||
|
fun testNonDefault(): String {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
val propertyNonDefault: String
|
||||||
|
get() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
interface KotlinInterface : KInterface {
|
||||||
|
@JvmDefault
|
||||||
|
fun fooo() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterface.test()
|
||||||
|
super@KotlinInterface.property
|
||||||
|
|
||||||
|
super@KotlinInterface.testNonDefault()
|
||||||
|
super@KotlinInterface.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
val propertyy: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterface.test()
|
||||||
|
super@KotlinInterface.property
|
||||||
|
|
||||||
|
super@KotlinInterface.testNonDefault()
|
||||||
|
super@KotlinInterface.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foooNonDefault() {
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterface.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super@KotlinInterface.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super@KotlinInterface.testNonDefault()
|
||||||
|
super@KotlinInterface.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val propertyyNonDefault: String
|
||||||
|
get() {
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterface.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super@KotlinInterface.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super@KotlinInterface.testNonDefault()
|
||||||
|
super@KotlinInterface.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KotlinInterfaceInderectInheritance : KotlinInterface {
|
||||||
|
@JvmDefault
|
||||||
|
fun foooo() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterfaceInderectInheritance.test()
|
||||||
|
super@KotlinInterfaceInderectInheritance.property
|
||||||
|
|
||||||
|
super@KotlinInterfaceInderectInheritance.testNonDefault()
|
||||||
|
super@KotlinInterfaceInderectInheritance.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
val propertyyy: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterfaceInderectInheritance.test()
|
||||||
|
super@KotlinInterfaceInderectInheritance.property
|
||||||
|
|
||||||
|
super@KotlinInterfaceInderectInheritance.testNonDefault()
|
||||||
|
super@KotlinInterfaceInderectInheritance.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fooooNonDefault() {
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterfaceInderectInheritance.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super@KotlinInterfaceInderectInheritance.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super@KotlinInterfaceInderectInheritance.testNonDefault()
|
||||||
|
super@KotlinInterfaceInderectInheritance.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val propertyyyNonDefault: String
|
||||||
|
get() {
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterfaceInderectInheritance.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>test<!>()
|
||||||
|
super@KotlinInterfaceInderectInheritance.<!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>property<!>
|
||||||
|
|
||||||
|
super@KotlinInterfaceInderectInheritance.testNonDefault()
|
||||||
|
super@KotlinInterfaceInderectInheritance.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class KotlinClass : KInterface {
|
||||||
|
fun foo() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClass.test()
|
||||||
|
super@KotlinClass.property
|
||||||
|
|
||||||
|
super@KotlinClass.testNonDefault()
|
||||||
|
super@KotlinClass.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val xproperty: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClass.test()
|
||||||
|
super@KotlinClass.property
|
||||||
|
|
||||||
|
super@KotlinClass.testNonDefault()
|
||||||
|
super@KotlinClass.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KotlinClassInderectInheritance : KotlinClass() {
|
||||||
|
fun foo2() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance.test()
|
||||||
|
super@KotlinClassInderectInheritance.property
|
||||||
|
|
||||||
|
super@KotlinClassInderectInheritance.testNonDefault()
|
||||||
|
super@KotlinClassInderectInheritance.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val property2: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance.test()
|
||||||
|
super@KotlinClassInderectInheritance.property
|
||||||
|
|
||||||
|
super@KotlinClassInderectInheritance.testNonDefault()
|
||||||
|
super@KotlinClassInderectInheritance.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KotlinClassInderectInheritance2 : KotlinInterfaceInderectInheritance {
|
||||||
|
fun foo() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance2.test()
|
||||||
|
super@KotlinClassInderectInheritance2.property
|
||||||
|
|
||||||
|
super@KotlinClassInderectInheritance2.testNonDefault()
|
||||||
|
super@KotlinClassInderectInheritance2.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val xproperty: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.property
|
||||||
|
|
||||||
|
super.testNonDefault()
|
||||||
|
super.propertyNonDefault
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance2.test()
|
||||||
|
super@KotlinClassInderectInheritance2.property
|
||||||
|
|
||||||
|
super@KotlinClassInderectInheritance2.testNonDefault()
|
||||||
|
super@KotlinClassInderectInheritance2.propertyNonDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
KotlinClass().test()
|
||||||
|
KotlinClass().property
|
||||||
|
KotlinClass().propertyNonDefault
|
||||||
|
KotlinClassInderectInheritance2().test()
|
||||||
|
KotlinClassInderectInheritance2().testNonDefault()
|
||||||
|
KotlinClassInderectInheritance2().propertyyy
|
||||||
|
KotlinClassInderectInheritance2().propertyyyNonDefault
|
||||||
|
|
||||||
|
KotlinClass().test()
|
||||||
|
KotlinClass().testNonDefault()
|
||||||
|
KotlinClass().property
|
||||||
|
KotlinClass().propertyNonDefault
|
||||||
|
}
|
||||||
+94
@@ -0,0 +1,94 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public interface KInterface {
|
||||||
|
@kotlin.jvm.JvmDefault public open val property: kotlin.String
|
||||||
|
public open val propertyNonDefault: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
@kotlin.jvm.JvmDefault public open fun test(): kotlin.String
|
||||||
|
public open fun testNonDefault(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class KotlinClass : KInterface {
|
||||||
|
public constructor KotlinClass()
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val property: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyNonDefault: kotlin.String
|
||||||
|
public final val xproperty: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun test(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun testNonDefault(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class KotlinClassInderectInheritance : KotlinClass {
|
||||||
|
public constructor KotlinClassInderectInheritance()
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val property: kotlin.String
|
||||||
|
public final val property2: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyNonDefault: kotlin.String
|
||||||
|
public final override /*1*/ /*fake_override*/ val xproperty: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||||
|
public final fun foo2(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun test(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun testNonDefault(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class KotlinClassInderectInheritance2 : KotlinInterfaceInderectInheritance {
|
||||||
|
public constructor KotlinClassInderectInheritance2()
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val property: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyNonDefault: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val propertyy: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyyNonDefault: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val propertyyy: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyyyNonDefault: kotlin.String
|
||||||
|
public final val xproperty: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.Unit
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun fooo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun foooNonDefault(): kotlin.Unit
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun foooo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun fooooNonDefault(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun test(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun testNonDefault(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface KotlinInterface : KInterface {
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val property: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyNonDefault: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open val propertyy: kotlin.String
|
||||||
|
public open val propertyyNonDefault: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
@kotlin.jvm.JvmDefault public open fun fooo(): kotlin.Unit
|
||||||
|
public open fun foooNonDefault(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun test(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun testNonDefault(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface KotlinInterfaceInderectInheritance : KotlinInterface {
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val property: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyNonDefault: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val propertyy: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ val propertyyNonDefault: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open val propertyyy: kotlin.String
|
||||||
|
public open val propertyyyNonDefault: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun fooo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun foooNonDefault(): kotlin.Unit
|
||||||
|
@kotlin.jvm.JvmDefault public open fun foooo(): kotlin.Unit
|
||||||
|
public open fun fooooNonDefault(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun test(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun testNonDefault(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Vendored
+163
@@ -0,0 +1,163 @@
|
|||||||
|
// !API_VERSION: 1.3
|
||||||
|
// !ENABLE_JVM_DEFAULT
|
||||||
|
// !JVM_TARGET: 1.8
|
||||||
|
// FILE: JavaInterface.java
|
||||||
|
|
||||||
|
public interface JavaInterface {
|
||||||
|
default String test() {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
default String testOverride() {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
interface KotlinInterface : JavaInterface {
|
||||||
|
@JvmDefault
|
||||||
|
fun fooo() {
|
||||||
|
super.test()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterface.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
val propertyy: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterface.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
override fun testOverride(): String {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KotlinInterfaceInderectInheritance : KotlinInterface {
|
||||||
|
@JvmDefault
|
||||||
|
fun foooo() {
|
||||||
|
super.test()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterfaceInderectInheritance.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
val propertyyy: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinInterfaceInderectInheritance.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class KotlinClass : JavaInterface {
|
||||||
|
fun foo() {
|
||||||
|
super.test()
|
||||||
|
super.testOverride()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClass.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val property: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.testOverride()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClass.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KotlinClassInderectInheritance : KotlinClass() {
|
||||||
|
fun foo2() {
|
||||||
|
super.test()
|
||||||
|
super.testOverride()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val property2: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.testOverride()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KotlinClassInderectInheritance2 : KotlinInterfaceInderectInheritance {
|
||||||
|
fun foo() {
|
||||||
|
super.test()
|
||||||
|
super.testOverride()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance2.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val property: String
|
||||||
|
get() {
|
||||||
|
super.test()
|
||||||
|
super.testOverride()
|
||||||
|
|
||||||
|
object {
|
||||||
|
fun run () {
|
||||||
|
super@KotlinClassInderectInheritance2.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
KotlinClass().foo()
|
||||||
|
KotlinClass().property
|
||||||
|
KotlinClassInderectInheritance2().foo()
|
||||||
|
KotlinClassInderectInheritance2().property
|
||||||
|
|
||||||
|
KotlinClass().test()
|
||||||
|
KotlinClass().property
|
||||||
|
KotlinClass().testOverride()
|
||||||
|
KotlinClassInderectInheritance().testOverride()
|
||||||
|
}
|
||||||
Vendored
+72
@@ -0,0 +1,72 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public interface JavaInterface {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open fun test(): kotlin.String!
|
||||||
|
public open fun testOverride(): kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class KotlinClass : JavaInterface {
|
||||||
|
public constructor KotlinClass()
|
||||||
|
public final val property: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun test(): kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class KotlinClassInderectInheritance : KotlinClass {
|
||||||
|
public constructor KotlinClassInderectInheritance()
|
||||||
|
public final override /*1*/ /*fake_override*/ val property: kotlin.String
|
||||||
|
public final val property2: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||||
|
public final fun foo2(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun test(): kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class KotlinClassInderectInheritance2 : KotlinInterfaceInderectInheritance {
|
||||||
|
public constructor KotlinClassInderectInheritance2()
|
||||||
|
public final val property: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val propertyy: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val propertyyy: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.Unit
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun fooo(): kotlin.Unit
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun foooo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun test(): kotlin.String!
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface KotlinInterface : JavaInterface {
|
||||||
|
@kotlin.jvm.JvmDefault public open val propertyy: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
@kotlin.jvm.JvmDefault public open fun fooo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun test(): kotlin.String!
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ fun testOverride(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface KotlinInterfaceInderectInheritance : KotlinInterface {
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ val propertyy: kotlin.String
|
||||||
|
@kotlin.jvm.JvmDefault public open val propertyyy: kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun fooo(): kotlin.Unit
|
||||||
|
@kotlin.jvm.JvmDefault public open fun foooo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun test(): kotlin.String!
|
||||||
|
@kotlin.jvm.JvmDefault public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
+12
@@ -488,6 +488,18 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmDefaults.kt")
|
||||||
|
public void testJvmDefaults() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaults.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmDefaultsWithJava.kt")
|
||||||
|
public void testJvmDefaultsWithJava() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noJvmDefaultFlag.kt")
|
@TestMetadata("noJvmDefaultFlag.kt")
|
||||||
public void testNoJvmDefaultFlag() throws Exception {
|
public void testNoJvmDefaultFlag() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/noJvmDefaultFlag.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/noJvmDefaultFlag.kt");
|
||||||
|
|||||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+12
@@ -488,6 +488,18 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmDefaults.kt")
|
||||||
|
public void testJvmDefaults() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaults.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmDefaultsWithJava.kt")
|
||||||
|
public void testJvmDefaultsWithJava() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noJvmDefaultFlag.kt")
|
@TestMetadata("noJvmDefaultFlag.kt")
|
||||||
public void testNoJvmDefaultFlag() throws Exception {
|
public void testNoJvmDefaultFlag() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/noJvmDefaultFlag.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/noJvmDefaultFlag.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user