Support @JvmField on interface properties
#KT-15807 Fixed
This commit is contained in:
@@ -2005,12 +2005,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
|
||||
boolean isBackingFieldInClassCompanion = JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||
boolean isBackingFieldMovedFromCompanion = JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||
AccessorKind fieldAccessorKind;
|
||||
if (skipLateinitAssertion) {
|
||||
fieldAccessorKind = AccessorKind.LATEINIT_INTRINSIC;
|
||||
}
|
||||
else if (isBackingFieldInClassCompanion &&
|
||||
else if (isBackingFieldMovedFromCompanion &&
|
||||
(forceField ||
|
||||
(Visibilities.isPrivate(propertyDescriptor.getVisibility()) &&
|
||||
isDefaultAccessor(propertyDescriptor.getGetter()) && isDefaultAccessor(propertyDescriptor.getSetter())))) {
|
||||
@@ -2076,7 +2076,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
else {
|
||||
skipPropertyAccessors = forceField;
|
||||
ownerDescriptor = isBackingFieldInClassCompanion ? containingDeclaration : propertyDescriptor;
|
||||
ownerDescriptor = isBackingFieldMovedFromCompanion ? containingDeclaration : propertyDescriptor;
|
||||
}
|
||||
|
||||
if (!skipPropertyAccessors) {
|
||||
|
||||
@@ -929,7 +929,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
boolean isNonCompanionObject = isNonCompanionObject(descriptor);
|
||||
boolean isInterfaceCompanion = isCompanionObjectInInterfaceNotIntrinsic(descriptor);
|
||||
boolean isMappedIntrinsicCompanionObject = isMappedIntrinsicCompanionObject(descriptor);
|
||||
if (isNonCompanionObject || isInterfaceCompanion || isMappedIntrinsicCompanionObject) {
|
||||
boolean objectWithBackingFieldsInOuter = isCompanionObjectWithBackingFieldsInOuter(descriptor);
|
||||
if (isNonCompanionObject || (isInterfaceCompanion && !objectWithBackingFieldsInOuter) || isMappedIntrinsicCompanionObject) {
|
||||
ExpressionCodegen clInitCodegen = createOrGetClInitCodegen();
|
||||
InstructionAdapter v = clInitCodegen.v;
|
||||
markLineNumberForElement(element.getPsiOrParent(), v);
|
||||
@@ -957,7 +958,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (isCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
||||
else if (objectWithBackingFieldsInOuter) {
|
||||
ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
||||
ExpressionCodegen parentClInitCodegen = parentCodegen.createOrGetClInitCodegen();
|
||||
InstructionAdapter parentVisitor = parentClInitCodegen.v;
|
||||
|
||||
@@ -57,9 +57,9 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAn
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.DELEGATED_PROPERTIES;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.DELEGATED_PROPERTY_METADATA_OWNER;
|
||||
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.FIELD_FOR_PROPERTY;
|
||||
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.SYNTHETIC_METHOD_FOR_PROPERTY;
|
||||
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.*;
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.EXPECTED_FUNCTION_SOURCE_WITH_DEFAULT_ARGUMENTS_NOT_FOUND;
|
||||
import static org.jetbrains.kotlin.load.java.JvmAbi.isInterfaceCompanionWithBackingFieldsInOuter;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isInterface;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.K_PROPERTY_TYPE;
|
||||
@@ -420,6 +420,10 @@ public class PropertyCodegen {
|
||||
String name = backingFieldContext.getFieldName(propertyDescriptor, isDelegate);
|
||||
|
||||
v.getSerializationBindings().put(FIELD_FOR_PROPERTY, propertyDescriptor, Pair.create(type, name));
|
||||
if (hasJvmFieldAnnotation(propertyDescriptor) &&
|
||||
isInterfaceCompanionWithBackingFieldsInOuter(propertyDescriptor.getContainingDeclaration())) {
|
||||
v.getSerializationBindings().put(FIELD_MOVED_FROM_INTERFACE_COMPANION, propertyDescriptor, true);
|
||||
}
|
||||
|
||||
FieldVisitor fv = builder.newField(
|
||||
JvmDeclarationOriginKt.OtherOrigin(element, propertyDescriptor), modifiers, name, type.getDescriptor(),
|
||||
|
||||
+2
@@ -35,6 +35,8 @@ public final class JvmSerializationBindings {
|
||||
SerializationMappingSlice.create();
|
||||
public static final SerializationMappingSlice<PropertyDescriptor, Method> SYNTHETIC_METHOD_FOR_PROPERTY =
|
||||
SerializationMappingSlice.create();
|
||||
public static final SerializationMappingSlice<PropertyDescriptor, Boolean> FIELD_MOVED_FROM_INTERFACE_COMPANION =
|
||||
SerializationMappingSlice.create();
|
||||
|
||||
private static final class SerializationMappingSlice<K, V> extends BasicWritableSlice<K, V> {
|
||||
public SerializationMappingSlice() {
|
||||
|
||||
+5
@@ -189,6 +189,11 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
);
|
||||
|
||||
proto.setExtension(JvmProtoBuf.propertySignature, signature);
|
||||
Boolean fieldMovedFromInterfaceCompanion = bindings.get(FIELD_MOVED_FROM_INTERFACE_COMPANION, descriptor);
|
||||
if (fieldMovedFromInterfaceCompanion != null && fieldMovedFromInterfaceCompanion) {
|
||||
proto.setExtension(JvmProtoBuf.isMovedFromInterfaceCompanion, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-1
@@ -16,9 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.fileClasses.isInsideJvmMultifileClassFile
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -40,6 +42,7 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
|
||||
LATEINIT("JvmField cannot be applied to lateinit property"),
|
||||
CONST("JvmField cannot be applied to const property"),
|
||||
INSIDE_COMPANION_OF_INTERFACE("JvmField cannot be applied to a property defined in companion object of interface"),
|
||||
NOT_PUBLIC_VAL_WITH_JVMFIELD("JvmField could be applied only if all interface companion properties are 'public final val' with '@JvmField' annotation"),
|
||||
TOP_LEVEL_PROPERTY_OF_MULTIFILE_FACADE("JvmField cannot be applied to top level property of a file annotated with ${JvmFileClassUtil.JVM_MULTIFILE_CLASS_SHORT}"),
|
||||
DELEGATE("JvmField cannot be applied to delegated property")
|
||||
}
|
||||
@@ -57,7 +60,14 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
|
||||
descriptor.overriddenDescriptors.isNotEmpty() -> OVERRIDES
|
||||
descriptor.isLateInit -> LATEINIT
|
||||
descriptor.isConst -> CONST
|
||||
descriptor.isInsideCompanionObjectOfInterface() -> INSIDE_COMPANION_OF_INTERFACE
|
||||
descriptor.isInsideCompanionObjectOfInterface() ->
|
||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.JvmFieldInInterface))
|
||||
INSIDE_COMPANION_OF_INTERFACE
|
||||
else {
|
||||
if (!JvmAbi.isInterfaceCompanionWithBackingFieldsInOuter(descriptor.containingDeclaration)) {
|
||||
NOT_PUBLIC_VAL_WITH_JVMFIELD
|
||||
} else return
|
||||
}
|
||||
DescriptorUtils.isTopLevelDeclaration(descriptor) && declaration.isInsideJvmMultifileClassFile() ->
|
||||
TOP_LEVEL_PROPERTY_OF_MULTIFILE_FACADE
|
||||
else -> return
|
||||
@@ -79,4 +89,5 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
|
||||
val outerClassKind = (containingClass.containingDeclaration as? ClassDescriptor)?.kind
|
||||
return outerClassKind == ClassKind.INTERFACE || outerClassKind == ClassKind.ANNOTATION_CLASS
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
import kotlin.reflect.full.memberProperties
|
||||
|
||||
class Bar(val value: String)
|
||||
|
||||
interface Foo {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val z = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val field = Foo.Companion::z
|
||||
return field.get().value
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface +NestedClassesInAnnotations
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Foo.kt
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
annotation class Foo {
|
||||
companion object {
|
||||
@JvmField
|
||||
val FOO = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.FOO.value
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface +NestedClassesInAnnotations
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test {
|
||||
public static String publicField() {
|
||||
return Foo.z.getS();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: simple.kt
|
||||
|
||||
|
||||
public class Bar(public val s: String)
|
||||
|
||||
annotation class Foo {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val z = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Test.publicField()
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package zzz
|
||||
import java.lang.reflect.Field
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.KProperty0
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class A(val s1: String, val s2: String) {
|
||||
@@ -21,27 +22,28 @@ class A(val s1: String, val s2: String) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// TODO: uncomment when callable references to object members are supported
|
||||
class AWithCompanion {
|
||||
companion object {
|
||||
@JvmField public val publicField = "1";
|
||||
@JvmField internal val internalField = "2";
|
||||
|
||||
fun testAccessors() {
|
||||
checkAccessor(AWithCompanion.Companion::publicField, "1", AWithCompanion.Companion)
|
||||
checkAccessor(AWithCompanion.Companion::internalField, "2", AWithCompanion.Companion)
|
||||
checkAccessor(AWithCompanion.Companion::publicField, "1")
|
||||
checkAccessor(AWithCompanion.Companion::internalField, "2")
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
fun box(): String {
|
||||
A("1", "2").testAccessors()
|
||||
// AWithCompanion.testAccessors()
|
||||
AWithCompanion.testAccessors()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
public fun <T, R> checkAccessor(prop: KProperty1<T, R>, value: R, receiver: T) {
|
||||
assertEquals(prop.get(receiver), value, "Property ${prop} has wrong value")
|
||||
}
|
||||
|
||||
public fun <R> checkAccessor(prop: KProperty0<R>, value: R) {
|
||||
assertEquals(prop.get(), value, "Property ${prop} has wrong value")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Foo.kt
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
interface Foo {
|
||||
companion object {
|
||||
@JvmField
|
||||
val FOO = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.FOO.value
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test {
|
||||
public static String publicField() {
|
||||
return Foo.o.getS() + Foo.k.getS();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: simple.kt
|
||||
|
||||
|
||||
public class Bar(public val s: String)
|
||||
|
||||
interface Foo {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val o = Bar("O")
|
||||
|
||||
@JvmField
|
||||
val k = Bar("K")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Test.publicField()
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
interface Foo {
|
||||
companion object {
|
||||
@JvmField
|
||||
val value = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val field = Foo.Companion::value.javaField!!
|
||||
return field.get(null) as String
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface +NestedClassesInAnnotations
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
|
||||
annotation class Ann(val value: String)
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
annotation class Foo {
|
||||
companion object {
|
||||
@JvmField @Ann("O")
|
||||
val FOO = Bar("K")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val field = Foo.Companion::class.declaredMemberProperties.single()
|
||||
return (field.annotations.single() as Ann).value + (field.get(Foo.Companion) as Bar).value
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.full.memberProperties
|
||||
import kotlin.reflect.full.companionObject
|
||||
|
||||
class Bar(val value: String)
|
||||
|
||||
interface Foo {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val z = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val field = Foo::class.companionObject!!.memberProperties.single() as KProperty1<Foo.Companion, Bar>
|
||||
return field.get(Foo.Companion).value
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
|
||||
annotation class Ann(val value: String)
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
interface Foo {
|
||||
companion object {
|
||||
@JvmField @Ann("O")
|
||||
val FOO = Bar("K")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val field = Foo.Companion::class.declaredMemberProperties.single()
|
||||
return (field.annotations.single() as Ann).value + (field.get(Foo.Companion) as Bar).value
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface +NestedClassesInAnnotations
|
||||
// TARGER_BACKEND: JVM
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Foo.kt
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
annotation class Foo {
|
||||
companion object {
|
||||
@JvmField
|
||||
val FOO = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.FOO.value
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGER_BACKEND: JVM
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Foo.kt
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
interface Foo {
|
||||
companion object {
|
||||
@JvmField
|
||||
val FOO = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.FOO.value
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
|
||||
interface A {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val c = 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface B {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val c = 3
|
||||
|
||||
@JvmField
|
||||
val a = 3
|
||||
}
|
||||
}
|
||||
|
||||
interface C {
|
||||
companion object {
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
val c = 3
|
||||
|
||||
val a = 3
|
||||
}
|
||||
}
|
||||
|
||||
interface D {
|
||||
companion object {
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
var c = 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface E {
|
||||
companion object {
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
private val a = 3
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
internal val b = 3
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
protected val c = 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface F {
|
||||
companion object {
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
<!NON_FINAL_MEMBER_IN_OBJECT!>open<!> val a = 3
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
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
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
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 {
|
||||
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 companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final val a: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
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 {
|
||||
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 companion object Companion {
|
||||
private constructor Companion()
|
||||
public final val a: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
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 D {
|
||||
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 companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
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 E {
|
||||
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 companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField private final val a: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField internal final val b: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField protected final val c: kotlin.Int = 3
|
||||
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
|
||||
}
|
||||
}
|
||||
Vendored
+2
@@ -95,6 +95,8 @@ interface K {
|
||||
companion object {
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
var c = 3
|
||||
|
||||
var x = 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -75,6 +75,7 @@ public interface K {
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
public final var x: kotlin.Int
|
||||
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
|
||||
|
||||
Generated
+45
@@ -1637,6 +1637,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/array.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boundJvmFieldInInterfaceCompanion.kt")
|
||||
public void testBoundJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/boundJvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companionObjectReceiver.kt")
|
||||
public void testCompanionObjectReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/companionObjectReceiver.kt");
|
||||
@@ -11943,6 +11948,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/jvmField"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationCompanion.kt")
|
||||
public void testAnnotationCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/annotationCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationCompanionWithJava.kt")
|
||||
public void testAnnotationCompanionWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/annotationCompanionWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("captureClassFields.kt")
|
||||
public void testCaptureClassFields() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/captureClassFields.kt");
|
||||
@@ -11973,6 +11988,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/jvmField/constructorProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanion.kt")
|
||||
public void testInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/interfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanionWithJava.kt")
|
||||
public void testInterfaceCompanionWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/interfaceCompanionWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("publicField.kt")
|
||||
public void testPublicField() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/publicField.kt");
|
||||
@@ -17691,6 +17716,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/inlineReifiedFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanionPropertyWithJvmField.kt")
|
||||
public void testInterfaceCompanionPropertyWithJvmField() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/interfaceCompanionPropertyWithJvmField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mappedClassIsEqualToClassLiteral.kt")
|
||||
public void testMappedClassIsEqualToClassLiteral() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/mappedClassIsEqualToClassLiteral.kt");
|
||||
@@ -18286,6 +18316,21 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/javaStaticField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInAnnotationCompanionWithAnnotation.kt")
|
||||
public void testJvmFieldInAnnotationCompanionWithAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInAnnotationCompanionWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInInterfaceCompanion.kt")
|
||||
public void testJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInInterfaceCompanionWithAnnotation.kt")
|
||||
public void testJvmFieldInInterfaceCompanionWithAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInInterfaceCompanionWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyInheritedInJava.kt")
|
||||
public void testKotlinPropertyInheritedInJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/kotlinPropertyInheritedInJava.kt");
|
||||
|
||||
+5
@@ -556,6 +556,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/inSingleFileFacade.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interface13.kt")
|
||||
public void testInterface13() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldApplicability.kt")
|
||||
public void testJvmFieldApplicability() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -556,6 +556,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/inSingleFileFacade.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interface13.kt")
|
||||
public void testInterface13() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldApplicability.kt")
|
||||
public void testJvmFieldApplicability() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability.kt");
|
||||
|
||||
+45
@@ -1637,6 +1637,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/array.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boundJvmFieldInInterfaceCompanion.kt")
|
||||
public void testBoundJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/boundJvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companionObjectReceiver.kt")
|
||||
public void testCompanionObjectReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/companionObjectReceiver.kt");
|
||||
@@ -11943,6 +11948,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/jvmField"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationCompanion.kt")
|
||||
public void testAnnotationCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/annotationCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationCompanionWithJava.kt")
|
||||
public void testAnnotationCompanionWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/annotationCompanionWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("captureClassFields.kt")
|
||||
public void testCaptureClassFields() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/captureClassFields.kt");
|
||||
@@ -11973,6 +11988,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/jvmField/constructorProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanion.kt")
|
||||
public void testInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/interfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanionWithJava.kt")
|
||||
public void testInterfaceCompanionWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/interfaceCompanionWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("publicField.kt")
|
||||
public void testPublicField() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/publicField.kt");
|
||||
@@ -17691,6 +17716,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/inlineReifiedFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanionPropertyWithJvmField.kt")
|
||||
public void testInterfaceCompanionPropertyWithJvmField() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/interfaceCompanionPropertyWithJvmField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mappedClassIsEqualToClassLiteral.kt")
|
||||
public void testMappedClassIsEqualToClassLiteral() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/mappedClassIsEqualToClassLiteral.kt");
|
||||
@@ -18286,6 +18316,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/javaStaticField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInAnnotationCompanionWithAnnotation.kt")
|
||||
public void testJvmFieldInAnnotationCompanionWithAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInAnnotationCompanionWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInInterfaceCompanion.kt")
|
||||
public void testJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInInterfaceCompanionWithAnnotation.kt")
|
||||
public void testJvmFieldInInterfaceCompanionWithAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInInterfaceCompanionWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyInheritedInJava.kt")
|
||||
public void testKotlinPropertyInheritedInJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/kotlinPropertyInheritedInJava.kt");
|
||||
|
||||
+10
@@ -143,11 +143,21 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
|
||||
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInAnnotationCompanion.kt")
|
||||
public void testJvmFieldInAnnotationCompanion() throws Exception {
|
||||
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmFieldInAnnotationCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInConstructor.kt")
|
||||
public void testJvmFieldInConstructor() throws Exception {
|
||||
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmFieldInConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInInterfaceCompanion.kt")
|
||||
public void testJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmNames.kt")
|
||||
public void testJvmNames() throws Exception {
|
||||
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmNames.kt");
|
||||
|
||||
+45
@@ -1637,6 +1637,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/array.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boundJvmFieldInInterfaceCompanion.kt")
|
||||
public void testBoundJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/boundJvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companionObjectReceiver.kt")
|
||||
public void testCompanionObjectReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/bound/companionObjectReceiver.kt");
|
||||
@@ -11943,6 +11948,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/jvmField"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationCompanion.kt")
|
||||
public void testAnnotationCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/annotationCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationCompanionWithJava.kt")
|
||||
public void testAnnotationCompanionWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/annotationCompanionWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("captureClassFields.kt")
|
||||
public void testCaptureClassFields() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/captureClassFields.kt");
|
||||
@@ -11973,6 +11988,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/jvmField/constructorProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanion.kt")
|
||||
public void testInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/interfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanionWithJava.kt")
|
||||
public void testInterfaceCompanionWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/interfaceCompanionWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("publicField.kt")
|
||||
public void testPublicField() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/publicField.kt");
|
||||
@@ -17691,6 +17716,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/inlineReifiedFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanionPropertyWithJvmField.kt")
|
||||
public void testInterfaceCompanionPropertyWithJvmField() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/interfaceCompanionPropertyWithJvmField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mappedClassIsEqualToClassLiteral.kt")
|
||||
public void testMappedClassIsEqualToClassLiteral() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/mapping/mappedClassIsEqualToClassLiteral.kt");
|
||||
@@ -18286,6 +18316,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/javaStaticField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInAnnotationCompanionWithAnnotation.kt")
|
||||
public void testJvmFieldInAnnotationCompanionWithAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInAnnotationCompanionWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInInterfaceCompanion.kt")
|
||||
public void testJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmFieldInInterfaceCompanionWithAnnotation.kt")
|
||||
public void testJvmFieldInInterfaceCompanionWithAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/jvmFieldInInterfaceCompanionWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyInheritedInJava.kt")
|
||||
public void testKotlinPropertyInheritedInJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/properties/kotlinPropertyInheritedInJava.kt");
|
||||
|
||||
@@ -67,6 +67,7 @@ enum class LanguageFeature(
|
||||
ProperForInArrayLoopRangeVariableAssignmentSemantic(KOTLIN_1_3, kind = BUG_FIX),
|
||||
NestedClassesInAnnotations(KOTLIN_1_3),
|
||||
JvmStaticInInterface(KOTLIN_1_3, kind = UNSTABLE_FEATURE),
|
||||
JvmFieldInInterface(KOTLIN_1_3, kind = UNSTABLE_FEATURE),
|
||||
ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion(KOTLIN_1_3, kind = BUG_FIX),
|
||||
ProhibitNonConstValuesAsVarargsInAnnotations(KOTLIN_1_3, kind = BUG_FIX),
|
||||
ReleaseCoroutines(KOTLIN_1_3, kind = UNSTABLE_FEATURE),
|
||||
|
||||
Reference in New Issue
Block a user