Add @JvmDefault diagnostics
This commit is contained in:
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getFirstArgumentExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.jvm.checkers.JvmDefaultChecker
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
@@ -59,8 +60,6 @@ import java.io.StringWriter
|
||||
import java.io.PrintWriter
|
||||
import java.util.*
|
||||
|
||||
private val JVM_DEFAULT_FQ_NAME = FqName("kotlin.annotations.JvmDefault")
|
||||
|
||||
fun generateIsCheck(
|
||||
v: InstructionAdapter,
|
||||
kotlinType: KotlinType,
|
||||
@@ -424,4 +423,4 @@ fun MethodNode.textifyMethodNode(): String {
|
||||
return "$sw"
|
||||
}
|
||||
|
||||
fun CallableMemberDescriptor.hasJvmDefaultAnnotation() = getDirectMember(this).annotations.hasAnnotation(JVM_DEFAULT_FQ_NAME)
|
||||
fun CallableMemberDescriptor.hasJvmDefaultAnnotation() = getDirectMember(this).annotations.hasAnnotation(JvmDefaultChecker.JVM_DEFAULT_FQ_NAME)
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
|
||||
class JvmDefaultChecker(val jvmTarget: JvmTarget) : DeclarationChecker {
|
||||
|
||||
companion object {
|
||||
val JVM_DEFAULT_FQ_NAME = FqName("kotlin.jvm.JvmDefault")
|
||||
|
||||
}
|
||||
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
|
||||
descriptor.annotations.findAnnotation(JVM_DEFAULT_FQ_NAME)?.let { annotationDescriptor ->
|
||||
val reportOn = DescriptorToSourceUtils.getSourceFromAnnotation(annotationDescriptor) ?: declaration
|
||||
if (!DescriptorUtils.isInterface(descriptor.containingDeclaration)) {
|
||||
context.trace.report(ErrorsJvm.JVM_DEFAULT_NOT_IN_INTERFACE.on(reportOn))
|
||||
} else if (jvmTarget == JvmTarget.JVM_1_6) {
|
||||
context.trace.report(ErrorsJvm.JVM_DEFAULT_IN_JVM6_TARGET.on(reportOn))
|
||||
}
|
||||
return@check
|
||||
}
|
||||
|
||||
if (!DescriptorUtils.isInterface(descriptor.containingDeclaration)) return
|
||||
val memberDescriptor = descriptor as? CallableMemberDescriptor ?: return
|
||||
if (descriptor is PropertyAccessorDescriptor) return
|
||||
|
||||
if (memberDescriptor.overriddenDescriptors.any { it.annotations.hasAnnotation(JVM_DEFAULT_FQ_NAME) }) {
|
||||
context.trace.report(ErrorsJvm.JVM_DEFAULT_REQUIRED_FOR_OVERRIDE.on(declaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -133,6 +133,10 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
|
||||
MAP.put(ASSIGNMENT_TO_ARRAY_LOOP_VARIABLE, "Assignment to a for-in-array loop range variable. Behavior may change in Kotlin 1.3. " +
|
||||
"See https://youtrack.jetbrains.com/issue/KT-21354 for more details");
|
||||
|
||||
MAP.put(JVM_DEFAULT_NOT_IN_INTERFACE,"'@JvmDefault' is only supported on interface members");
|
||||
MAP.put(JVM_DEFAULT_IN_JVM6_TARGET,"'@JvmDefault' is only supported since JVM target 1.8. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(JVM_DEFAULT_REQUIRED_FOR_OVERRIDE, "'@JvmDefault' is required for an override of a '@JvmDefault' member");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -114,6 +114,10 @@ public interface ErrorsJvm {
|
||||
|
||||
DiagnosticFactory0<KtExpression> ASSIGNMENT_TO_ARRAY_LOOP_VARIABLE = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<PsiElement> JVM_DEFAULT_NOT_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> JVM_DEFAULT_IN_JVM6_TARGET = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDeclaration> JVM_DEFAULT_REQUIRED_FOR_OVERRIDE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
enum NullabilityInformationSource {
|
||||
KOTLIN {
|
||||
@NotNull
|
||||
|
||||
+1
@@ -91,6 +91,7 @@ object JvmPlatformConfigurator : PlatformConfigurator(
|
||||
container.useImpl<JavaSyntheticScopes>()
|
||||
container.useImpl<SamConversionResolverImpl>()
|
||||
container.useImpl<InterfaceDefaultMethodCallChecker>()
|
||||
container.useImpl<JvmDefaultChecker>()
|
||||
container.useImpl<InlinePlatformCompatibilityChecker>()
|
||||
container.useImpl<JvmModuleAccessibilityChecker>()
|
||||
container.useImpl<JvmModuleAccessibilityChecker.ClassifierUsage>()
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.8
|
||||
interface A<T> {
|
||||
@kotlin.annotations.JvmDefault
|
||||
fun test(p: T) {
|
||||
}
|
||||
}
|
||||
|
||||
interface ANonDefault {
|
||||
fun test(p: String) {}
|
||||
}
|
||||
|
||||
interface B<T> : A<T> {
|
||||
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun test(p: T)<!>
|
||||
{}
|
||||
}
|
||||
|
||||
interface C<T> : A<T>, ANonDefault {
|
||||
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun test(p: T)<!>
|
||||
{}
|
||||
|
||||
override fun test(p: String) {
|
||||
}
|
||||
}
|
||||
|
||||
interface C1 : C<String> {
|
||||
override fun test(p: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
interface C2 : C<String>, ANonDefault {
|
||||
override fun test(p: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
interface D<T> : ANonDefault, A<T> {
|
||||
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun test(p: T)<!>
|
||||
{}
|
||||
|
||||
override fun test(p: String) {
|
||||
}
|
||||
}
|
||||
|
||||
interface D1 : D<String> {
|
||||
override fun test(p: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
interface D2 : ANonDefault, D<String> {
|
||||
override fun test(p: String) {
|
||||
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package
|
||||
|
||||
public interface A</*0*/ T> {
|
||||
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.annotations.JvmDefault public open fun test(/*0*/ p: T): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface ANonDefault {
|
||||
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(/*0*/ p: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B</*0*/ T> : A<T> {
|
||||
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 override /*1*/ fun test(/*0*/ p: T): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface C</*0*/ T> : A<T>, ANonDefault {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ fun test(/*0*/ p: T): kotlin.Unit
|
||||
public open override /*1*/ fun test(/*0*/ p: kotlin.String): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface C1 : C<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
|
||||
public open override /*2*/ fun test(/*0*/ p: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface C2 : C<kotlin.String>, ANonDefault {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*3*/ fun test(/*0*/ p: kotlin.String): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface D</*0*/ T> : ANonDefault, A<T> {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ fun test(/*0*/ p: T): kotlin.Unit
|
||||
public open override /*1*/ fun test(/*0*/ p: kotlin.String): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface D1 : D<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
|
||||
public open override /*2*/ fun test(/*0*/ p: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface D2 : ANonDefault, D<kotlin.String> {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*3*/ fun test(/*0*/ p: kotlin.String): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.8
|
||||
abstract class A {
|
||||
|
||||
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@kotlin.annotations.JvmDefault<!>
|
||||
fun test() {}
|
||||
|
||||
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@kotlin.annotations.JvmDefault<!>
|
||||
abstract fun test2(s: String = "")
|
||||
|
||||
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@kotlin.annotations.JvmDefault<!>
|
||||
abstract fun test3()
|
||||
}
|
||||
|
||||
object B {
|
||||
|
||||
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@kotlin.annotations.JvmDefault<!>
|
||||
fun test() {}
|
||||
|
||||
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@kotlin.annotations.JvmDefault<!>
|
||||
fun test2(<!UNUSED_PARAMETER!>s<!>: String = "") {}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public abstract class A {
|
||||
public constructor A()
|
||||
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.annotations.JvmDefault public final fun test(): kotlin.Unit
|
||||
@kotlin.annotations.JvmDefault public abstract fun test2(/*0*/ s: kotlin.String = ...): kotlin.Unit
|
||||
@kotlin.annotations.JvmDefault public abstract fun test3(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object B {
|
||||
private constructor B()
|
||||
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.annotations.JvmDefault public final fun test(): kotlin.Unit
|
||||
@kotlin.annotations.JvmDefault public final fun test2(/*0*/ s: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.8
|
||||
interface B {
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
val prop1: String
|
||||
<!WRONG_ANNOTATION_TARGET!>@kotlin.annotations.JvmDefault<!> get() = ""
|
||||
|
||||
|
||||
var prop2: String
|
||||
<!WRONG_ANNOTATION_TARGET!>@kotlin.annotations.JvmDefault<!> get() = ""
|
||||
<!WRONG_ANNOTATION_TARGET!>@kotlin.annotations.JvmDefault<!> set(value) {}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package
|
||||
|
||||
public interface B {
|
||||
@kotlin.annotations.JvmDefault public open val prop1: kotlin.String
|
||||
public open var prop2: 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
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.8
|
||||
interface A {
|
||||
@kotlin.annotations.JvmDefault
|
||||
fun test() {}
|
||||
}
|
||||
|
||||
interface Abstract : A {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun test()<!>
|
||||
}
|
||||
|
||||
interface ANonDefault {
|
||||
fun test() {}
|
||||
}
|
||||
|
||||
interface B: A {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun test()<!> {}
|
||||
}
|
||||
|
||||
interface C: ANonDefault, A {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun test()<!> {}
|
||||
}
|
||||
|
||||
interface D: A, ANonDefault {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun test()<!> {}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package
|
||||
|
||||
public interface A {
|
||||
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.annotations.JvmDefault public open fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface ANonDefault {
|
||||
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.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Abstract : A {
|
||||
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 abstract override /*1*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B : A {
|
||||
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 override /*1*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface C : ANonDefault, A {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface D : A, ANonDefault {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.8
|
||||
@kotlin.annotations.JvmDefaultFeature
|
||||
interface A {
|
||||
@kotlin.annotations.JvmDefault
|
||||
fun test() {
|
||||
}
|
||||
}
|
||||
|
||||
interface Abstract : <!EXPERIMENTAL_API_USAGE!>A<!> {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun <!EXPERIMENTAL_OVERRIDE!>test<!>()<!>
|
||||
}
|
||||
|
||||
interface ANonDefault {
|
||||
fun test() {}
|
||||
}
|
||||
|
||||
interface B : <!EXPERIMENTAL_API_USAGE!>A<!> {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun <!EXPERIMENTAL_OVERRIDE!>test<!>()<!> {}
|
||||
}
|
||||
|
||||
interface C : ANonDefault, <!EXPERIMENTAL_API_USAGE!>A<!> {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun <!EXPERIMENTAL_OVERRIDE!>test<!>()<!> {}
|
||||
}
|
||||
|
||||
interface D : <!EXPERIMENTAL_API_USAGE!>A<!>, ANonDefault {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override fun <!EXPERIMENTAL_OVERRIDE!>test<!>()<!> {}
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
package
|
||||
|
||||
@kotlin.annotations.JvmDefaultFeature public interface A {
|
||||
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.annotations.JvmDefault public open fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface ANonDefault {
|
||||
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.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Abstract : A {
|
||||
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 abstract override /*1*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B : A {
|
||||
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 override /*1*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface C : ANonDefault, A {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface D : A, ANonDefault {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.8
|
||||
interface A {
|
||||
@kotlin.annotations.JvmDefault
|
||||
val test: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
interface Abstract : A {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override val test: String<!>
|
||||
}
|
||||
|
||||
interface ANonDefault {
|
||||
val test: String
|
||||
get() = "ANonDefault"
|
||||
}
|
||||
|
||||
interface B: A {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override val test: String<!>
|
||||
get() = "B"
|
||||
}
|
||||
|
||||
interface C: ANonDefault, A {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override val test: String<!>
|
||||
get() = "C"
|
||||
}
|
||||
|
||||
interface D: A, ANonDefault {
|
||||
<!JVM_DEFAULT_REQUIRED_FOR_OVERRIDE!>override val test: String<!>
|
||||
get() = "C"
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
package
|
||||
|
||||
public interface A {
|
||||
@kotlin.annotations.JvmDefault public open val test: 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
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface ANonDefault {
|
||||
public open val test: 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
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Abstract : A {
|
||||
public abstract override /*1*/ val test: 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
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B : A {
|
||||
public open override /*1*/ val test: 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
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface C : ANonDefault, A {
|
||||
public open override /*2*/ val test: kotlin.String
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface D : A, ANonDefault {
|
||||
public open override /*2*/ val test: kotlin.String
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.6
|
||||
interface B {
|
||||
|
||||
<!JVM_DEFAULT_IN_JVM6_TARGET!>@kotlin.annotations.JvmDefault<!>
|
||||
fun test() {}
|
||||
|
||||
<!JVM_DEFAULT_IN_JVM6_TARGET!>@kotlin.annotations.JvmDefault<!>
|
||||
abstract fun test2(s: String = "")
|
||||
|
||||
<!JVM_DEFAULT_IN_JVM6_TARGET!>@kotlin.annotations.JvmDefault<!>
|
||||
abstract fun test3()
|
||||
|
||||
|
||||
|
||||
<!JVM_DEFAULT_IN_JVM6_TARGET!>@kotlin.annotations.JvmDefault<!>
|
||||
abstract val prop: String
|
||||
|
||||
<!JVM_DEFAULT_IN_JVM6_TARGET!>@kotlin.annotations.JvmDefault<!>
|
||||
abstract val prop2: String
|
||||
|
||||
<!JVM_DEFAULT_IN_JVM6_TARGET!>@kotlin.annotations.JvmDefault<!>
|
||||
val prop3: String
|
||||
get() = ""
|
||||
|
||||
<!JVM_DEFAULT_IN_JVM6_TARGET!>@kotlin.annotations.JvmDefault<!>
|
||||
var prop4: String
|
||||
get() = ""
|
||||
set(value) {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public interface B {
|
||||
@kotlin.annotations.JvmDefault public abstract val prop: kotlin.String
|
||||
@kotlin.annotations.JvmDefault public abstract val prop2: kotlin.String
|
||||
@kotlin.annotations.JvmDefault public open val prop3: kotlin.String
|
||||
@kotlin.annotations.JvmDefault public open var prop4: 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.annotations.JvmDefault public open fun test(): kotlin.Unit
|
||||
@kotlin.annotations.JvmDefault public abstract fun test2(/*0*/ s: kotlin.String = ...): kotlin.Unit
|
||||
@kotlin.annotations.JvmDefault public abstract fun test3(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE
|
||||
// !API_VERSION: 1.3
|
||||
// !JVM_TARGET: 1.8
|
||||
interface B {
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
fun test() {}
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
abstract fun test2(s: String = "")
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
abstract fun test3()
|
||||
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
abstract val prop: String
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
abstract val prop2: String
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
val prop3: String
|
||||
get() = ""
|
||||
|
||||
@kotlin.annotations.JvmDefault
|
||||
var prop4: String
|
||||
get() = ""
|
||||
set(value) {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public interface B {
|
||||
@kotlin.annotations.JvmDefault public abstract val prop: kotlin.String
|
||||
@kotlin.annotations.JvmDefault public abstract val prop2: kotlin.String
|
||||
@kotlin.annotations.JvmDefault public open val prop3: kotlin.String
|
||||
@kotlin.annotations.JvmDefault public open var prop4: 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.annotations.JvmDefault public open fun test(): kotlin.Unit
|
||||
@kotlin.annotations.JvmDefault public abstract fun test2(/*0*/ s: kotlin.String = ...): kotlin.Unit
|
||||
@kotlin.annotations.JvmDefault public abstract fun test3(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+57
@@ -468,6 +468,63 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JvmDefault extends AbstractDiagnosticsTestWithStdLib {
|
||||
public void testAllFilesPresentInJvmDefault() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("generic.kt")
|
||||
public void testGeneric() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/generic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("notInterface.kt")
|
||||
public void testNotInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/notInterface.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAccessor.kt")
|
||||
public void testPropertyAccessor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/propertyAccessor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleOverride.kt")
|
||||
public void testSimpleOverride() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/simpleOverride.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleOverrideWithFeature.kt")
|
||||
public void testSimpleOverrideWithFeature() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/simpleOverrideWithFeature.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simplePropertyOverride.kt")
|
||||
public void testSimplePropertyOverride() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/simplePropertyOverride.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("target6.kt")
|
||||
public void testTarget6() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/target6.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("target8.kt")
|
||||
public void testTarget8() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/target8.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+57
@@ -468,6 +468,63 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JvmDefault extends AbstractDiagnosticsTestWithStdLibUsingJavac {
|
||||
public void testAllFilesPresentInJvmDefault() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("generic.kt")
|
||||
public void testGeneric() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/generic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("notInterface.kt")
|
||||
public void testNotInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/notInterface.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAccessor.kt")
|
||||
public void testPropertyAccessor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/propertyAccessor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleOverride.kt")
|
||||
public void testSimpleOverride() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/simpleOverride.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleOverrideWithFeature.kt")
|
||||
public void testSimpleOverrideWithFeature() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/simpleOverrideWithFeature.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simplePropertyOverride.kt")
|
||||
public void testSimplePropertyOverride() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/simplePropertyOverride.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("target6.kt")
|
||||
public void testTarget6() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/target6.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("target8.kt")
|
||||
public void testTarget8() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/target8.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user