Private visibility for non-const, non-jvmField class companion property backing field

This commit is contained in:
Michael Bogdanov
2015-12-25 15:05:31 +03:00
parent 85ae0cb78e
commit e116cc3206
76 changed files with 299 additions and 157 deletions
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.load.java.JavaVisibilities; import org.jetbrains.kotlin.load.java.JavaVisibilities;
import org.jetbrains.kotlin.load.java.JvmAnnotationNames; import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap;
import org.jetbrains.kotlin.resolve.DeprecationUtilKt; import org.jetbrains.kotlin.resolve.DeprecationUtilKt;
import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt; import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
@@ -61,6 +62,7 @@ import java.util.Set;
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isBoolean; import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isBoolean;
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isPrimitiveClass; import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isPrimitiveClass;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAnnotation;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface; import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.load.java.JvmAnnotationNames.KOTLIN_SYNTHETIC_CLASS; import static org.jetbrains.kotlin.load.java.JvmAnnotationNames.KOTLIN_SYNTHETIC_CLASS;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*; import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
@@ -681,13 +683,13 @@ public class AsmUtil {
isObject(propertyDescriptor.getContainingDeclaration()); isObject(propertyDescriptor.getContainingDeclaration());
} }
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) { public static int getVisibilityForBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null; boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
if (isDelegate || isExtensionProperty) { if (isDelegate || isExtensionProperty) {
return ACC_PRIVATE; return ACC_PRIVATE;
} }
else { else {
return areBothAccessorDefault(propertyDescriptor) return propertyDescriptor.isLateInit() || isConstOrHasJvmFieldAnnotation(propertyDescriptor)
? getVisibilityAccessFlag(descriptorForVisibility(propertyDescriptor)) ? getVisibilityAccessFlag(descriptorForVisibility(propertyDescriptor))
: ACC_PRIVATE; : ACC_PRIVATE;
} }
@@ -706,16 +708,7 @@ public class AsmUtil {
DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration(); DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration();
return propertyDescriptor.isConst() return propertyDescriptor.isConst()
&& isCompanionObject(propertyContainer) && isInterface(propertyContainer.getContainingDeclaration()) && isCompanionObject(propertyContainer) && isInterface(propertyContainer.getContainingDeclaration())
&& getVisibilityForSpecialPropertyBackingField(propertyDescriptor, false) == ACC_PUBLIC; && getVisibilityForBackingField(propertyDescriptor, false) == ACC_PUBLIC;
}
private static boolean areBothAccessorDefault(@NotNull PropertyDescriptor propertyDescriptor) {
return isAccessorWithEmptyBody(propertyDescriptor.getGetter())
&& (!propertyDescriptor.isVar() || isAccessorWithEmptyBody(propertyDescriptor.getSetter()));
}
private static boolean isAccessorWithEmptyBody(@Nullable PropertyAccessorDescriptor accessorDescriptor) {
return accessorDescriptor == null || !accessorDescriptor.hasBody();
} }
public static Type comparisonOperandType(Type left, Type right) { public static Type comparisonOperandType(Type left, Type right) {
@@ -2140,7 +2140,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
PropertyDescriptor originalPropertyDescriptor = DescriptorUtils.unwrapFakeOverride(propertyDescriptor); PropertyDescriptor originalPropertyDescriptor = DescriptorUtils.unwrapFakeOverride(propertyDescriptor);
if (fieldAccessorKind != FieldAccessorKind.NORMAL) { if (fieldAccessorKind != FieldAccessorKind.NORMAL) {
int flags = AsmUtil.getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegatedProperty); int flags = AsmUtil.getVisibilityForBackingField(propertyDescriptor, isDelegatedProperty);
skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || skipAccessorsForPrivateFieldInOuterClass; skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || skipAccessorsForPrivateFieldInOuterClass;
if (!skipPropertyAccessors) { if (!skipPropertyAccessors) {
//noinspection ConstantConditions //noinspection ConstantConditions
@@ -54,12 +54,14 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
import java.util.List; import java.util.List;
import static org.jetbrains.kotlin.codegen.AsmUtil.*; import static org.jetbrains.kotlin.codegen.AsmUtil.getDeprecatedAccessFlag;
import static org.jetbrains.kotlin.codegen.AsmUtil.getVisibilityForBackingField;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAnnotation; import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAnnotation;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface; import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.FIELD_FOR_PROPERTY; 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.SYNTHETIC_METHOD_FOR_PROPERTY;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*; 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; import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.K_PROPERTY_TYPE;
import static org.jetbrains.kotlin.resolve.jvm.annotations.AnnotationUtilKt.hasJvmFieldAnnotation; import static org.jetbrains.kotlin.resolve.jvm.annotations.AnnotationUtilKt.hasJvmFieldAnnotation;
import static org.jetbrains.org.objectweb.asm.Opcodes.*; import static org.jetbrains.org.objectweb.asm.Opcodes.*;
@@ -300,50 +302,17 @@ public class PropertyCodegen {
ClassBuilder builder = v; ClassBuilder builder = v;
boolean hasJvmFieldAnnotation = hasJvmFieldAnnotation(propertyDescriptor);
FieldOwnerContext backingFieldContext = context; FieldOwnerContext backingFieldContext = context;
boolean takeVisibilityFromDescriptor = propertyDescriptor.isLateInit() || propertyDescriptor.isConst();
boolean takeVisibilityFromSetter = propertyDescriptor.isLateInit() && propertyDescriptor.getSetter() != null;
if (AsmUtil.isInstancePropertyWithStaticBackingField(propertyDescriptor) ) { if (AsmUtil.isInstancePropertyWithStaticBackingField(propertyDescriptor) ) {
modifiers |= ACC_STATIC; modifiers |= ACC_STATIC;
if (takeVisibilityFromDescriptor) {
modifiers |= getVisibilityAccessFlag(propertyDescriptor);
}
else if (hasJvmFieldAnnotation && !isDelegate) {
modifiers |= getDefaultVisibilityFlag(propertyDescriptor.getVisibility());
}
else {
modifiers |= getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegate);
}
if (JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor)) { if (JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor)) {
ImplementationBodyCodegen codegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen(); ImplementationBodyCodegen codegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
builder = codegen.v; builder = codegen.v;
backingFieldContext = codegen.context; backingFieldContext = codegen.context;
} }
if (isObject(propertyDescriptor.getContainingDeclaration()) &&
!hasJvmFieldAnnotation &&
!propertyDescriptor.isConst() &&
(modifiers & ACC_PRIVATE) == 0) {
modifiers |= ACC_DEPRECATED;
}
}
else if (takeVisibilityFromSetter) {
// For lateinits, we take visibility from setter, if any
modifiers |= getVisibilityAccessFlag(propertyDescriptor.getSetter());
}
else if (takeVisibilityFromDescriptor) {
modifiers |= getVisibilityAccessFlag(propertyDescriptor);
}
else if (!isDelegate && hasJvmFieldAnnotation) {
modifiers |= getDefaultVisibilityFlag(propertyDescriptor.getVisibility());
}
else {
modifiers |= ACC_PRIVATE;
} }
modifiers |= getVisibilityForBackingField(propertyDescriptor, isDelegate);
if (AsmUtil.isPropertyWithBackingFieldCopyInOuterClass(propertyDescriptor)) { if (AsmUtil.isPropertyWithBackingFieldCopyInOuterClass(propertyDescriptor)) {
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen(); ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
@@ -55,7 +55,7 @@ public class FunctionDescriptorUtil {
@NotNull FunctionDescriptor functionDescriptor, @NotNull FunctionDescriptor functionDescriptor,
@NotNull List<KotlinType> typeArguments @NotNull List<KotlinType> typeArguments
) { ) {
if (functionDescriptor.getTypeParameters().isEmpty()) return TypeSubstitution.getEMPTY(); if (functionDescriptor.getTypeParameters().isEmpty()) return TypeSubstitution.EMPTY;
return new IndexedParametersSubstitution(functionDescriptor.getTypeParameters(), TypeUtilsKt.defaultProjections(typeArguments)); return new IndexedParametersSubstitution(functionDescriptor.getTypeParameters(), TypeUtilsKt.defaultProjections(typeArguments));
} }
@@ -1,9 +1,6 @@
public final class ClassObjectField { public final class ClassObjectField {
/**
* @deprecated
*/
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
public static final java.lang.String x = ""; private static final java.lang.String x = "";
private static final java.lang.String y = ""; private static final java.lang.String y = "";
public static final ClassObjectField.Companion Companion; public static final ClassObjectField.Companion Companion;
@@ -1,13 +1,7 @@
public final class A { public final class A {
/** private static final int c = 1;
* @deprecated
*/
public static final int c = 1;
/**
* @deprecated
*/
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public static java.lang.String v; private static java.lang.String v;
public static final pack.A INSTANCE; public static final pack.A INSTANCE;
public final int getC() { /* compiled code */ } public final int getC() { /* compiled code */ }
@@ -3,8 +3,8 @@ class Test {
return A.foo; return A.foo;
} }
public static String bar() { public static String constBar() {
return A.bar; return A.constBar;
} }
public static String getBar() { public static String getBar() {
@@ -3,7 +3,9 @@ import kotlin.jvm.JvmStatic
enum class A { enum class A {
; ;
companion object { companion object {
val foo: String = "OK" @JvmField val foo: String = "OK"
const val constBar: String = "OK"
@JvmStatic val bar: String = "OK" @JvmStatic val bar: String = "OK"
@@ -13,7 +15,7 @@ enum class A {
fun box(): String { fun box(): String {
if (Test.foo() != "OK") return "Fail foo" if (Test.foo() != "OK") return "Fail foo"
if (Test.bar() != "OK") return "Fail bar" if (Test.constBar() != "OK") return "Fail bar"
if (Test.getBar() != "OK") return "Fail getBar" if (Test.getBar() != "OK") return "Fail getBar"
if (Test.baz() != "OK") return "Fail baz" if (Test.baz() != "OK") return "Fail baz"
return "OK" return "OK"
@@ -1,7 +1,7 @@
class KotlinClass { class KotlinClass {
companion object { companion object {
val FOO_INT: Int = 10 const val FOO_INT: Int = 10
val FOO_STRING: String = "OK" @JvmField val FOO_STRING: String = "OK"
} }
} }
@@ -5,12 +5,18 @@ class Test {
s = Klass.NAME; s = Klass.NAME;
if (!s.equals("Klass")) throw new AssertionError("Fail class: " + s); if (!s.equals("Klass")) throw new AssertionError("Fail class: " + s);
s = Klass.JVM_NAME;
if (!s.equals("JvmKlass")) throw new AssertionError("Fail jvm class: " + s);
s = Trait.NAME; s = Trait.NAME;
if (!s.equals("Trait")) throw new AssertionError("Fail interface: " + s); if (!s.equals("Trait")) throw new AssertionError("Fail interface: " + s);
s = Enoom.NAME; s = Enoom.NAME;
if (!s.equals("Enum")) throw new AssertionError("Fail enum: " + s); if (!s.equals("Enum")) throw new AssertionError("Fail enum: " + s);
s = Enoom.JVM_NAME;
if (!s.equals("JvmEnum")) throw new AssertionError("Fail jvm enum: " + s);
return "OK"; return "OK";
} }
} }
@@ -1,6 +1,7 @@
class Klass { class Klass {
companion object { companion object {
val NAME = "Klass" const val NAME = "Klass"
@JvmField val JVM_NAME = "JvmKlass"
} }
} }
@@ -14,6 +15,7 @@ enum class Enoom {
; ;
companion object { companion object {
const val NAME = "Enum" const val NAME = "Enum"
@JvmField val JVM_NAME = "JvmEnum"
} }
} }
@@ -12,7 +12,7 @@ public interface ErrorsJvmTrait {
public class ErrorsJvmClass { public class ErrorsJvmClass {
companion object { companion object {
public val param : G<String> = G("STRING") @JvmField public val param : G<String> = G("STRING")
} }
} }
@@ -11,13 +11,13 @@ annotation class AFloat(val value: Float)
class Test { class Test {
companion object { companion object {
val vstring: String = "Test" const val vstring: String = "Test"
val vchar: Char = 'c' const val vchar: Char = 'c'
val vint: Int = 10 const val vint: Int = 10
val vbyte: Byte = 11 const val vbyte: Byte = 11
val vlong: Long = 12 const val vlong: Long = 12
val vdouble: Double = 1.2 const val vdouble: Double = 1.2
val vfloat: Float = 1.3.toFloat() const val vfloat: Float = 1.3.toFloat()
} }
} }
@@ -44,12 +44,12 @@ public final class Test {
public companion object Companion { public companion object Companion {
private constructor Companion() private constructor Companion()
public final val vbyte: kotlin.Byte public const final val vbyte: kotlin.Byte
public final val vchar: kotlin.Char public const final val vchar: kotlin.Char
public final val vdouble: kotlin.Double public const final val vdouble: kotlin.Double
public final val vfloat: kotlin.Float public const final val vfloat: kotlin.Float
public final val vint: kotlin.Int public const final val vint: kotlin.Int
public final val vlong: kotlin.Long public const final val vlong: kotlin.Long
public final val vstring: kotlin.String public const final val vstring: kotlin.String
} }
} }
@@ -2,6 +2,6 @@ package test
class KotlinClass { class KotlinClass {
companion object { companion object {
val FOO: Int = 10 const val FOO: Int = 10
} }
} }
@@ -5,7 +5,7 @@ public final class KotlinClass {
public companion object Companion { public companion object Companion {
private constructor Companion() private constructor Companion()
public final val FOO: kotlin.Int public const final val FOO: kotlin.Int
} }
} }
@@ -3,9 +3,9 @@ package test
class Test { class Test {
companion object { companion object {
public val valProp: Int = 10 public const val valProp: Int = 10
public var varProp: Int = 10 @JvmField public var varProp: Int = 10
} }
} }
@@ -5,8 +5,8 @@ public final class Test {
public companion object Companion { public companion object Companion {
private constructor Companion() private constructor Companion()
public final val valProp: kotlin.Int public const final val valProp: kotlin.Int
public final var varProp: kotlin.Int @field:kotlin.jvm.JvmField() public final var varProp: kotlin.Int
} }
} }
@@ -1,12 +1,12 @@
class Test { class Test {
companion object { companion object {
var prop: Int = 0; const val prop: Int = 0;
} }
} }
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -6,7 +6,7 @@ class Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PRIVATE
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -1,12 +1,12 @@
class Test { class Test {
companion object { companion object {
protected val prop: Int = 0; const protected val prop: Int = 0;
} }
} }
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PROTECTED, ACC_FINAL, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PROTECTED, ACC_FINAL
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -1,12 +1,12 @@
class Test { class Test {
companion object { companion object {
public val prop: Int = 0; public const val prop: Int = 0;
} }
} }
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -6,7 +6,7 @@ class Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PRIVATE
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -7,7 +7,7 @@ class Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PROTECTED, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PRIVATE
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -7,7 +7,7 @@ class Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PRIVATE
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -1,7 +1,7 @@
class Test(val prop: String) { class Test(val prop: String) {
companion object { companion object {
public val prop : String = "CO"; public const val prop : String = "CO";
} }
} }
@@ -13,4 +13,4 @@ class Test(val prop: String) {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL
@@ -3,7 +3,7 @@ class Test {
public var prop: Int = 0; public var prop: Int = 0;
companion object { companion object {
public val prop: Int = 0; public const val prop: Int = 0;
} }
} }
@@ -13,4 +13,4 @@ class Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL, ACC_DEPRECATED // FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL
@@ -10,4 +10,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PUBLIC, ACC_FINAL, ACC_STATIC, ACC_DEPRECATED // FLAGS: ACC_PRIVATE, ACC_FINAL, ACC_STATIC
@@ -10,4 +10,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_DEPRECATED // FLAGS: ACC_PRIVATE, ACC_STATIC
@@ -0,0 +1,13 @@
interface Test {
companion object {
protected const val prop: Int = 0
}
}
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop
// ABSENT: TRUE
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PROTECTED, ACC_FINAL, ACC_STATIC
@@ -10,4 +10,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PROTECTED, ACC_FINAL, ACC_STATIC, ACC_DEPRECATED // FLAGS: ACC_PRIVATE, ACC_FINAL, ACC_STATIC
@@ -10,4 +10,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PUBLIC, ACC_FINAL, ACC_STATIC, ACC_DEPRECATED // FLAGS: ACC_PRIVATE, ACC_FINAL, ACC_STATIC
@@ -10,4 +10,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_DEPRECATED // FLAGS: ACC_PRIVATE, ACC_STATIC
@@ -11,4 +11,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PROTECTED, ACC_STATIC, ACC_DEPRECATED // FLAGS: ACC_PRIVATE, ACC_STATIC
@@ -11,4 +11,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_DEPRECATED // FLAGS: ACC_PRIVATE, ACC_STATIC
@@ -875,6 +875,12 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("protectedConstVal.kt")
public void testProtectedConstVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/protectedConstVal.kt");
doTest(fileName);
}
@TestMetadata("protectedVal.kt") @TestMetadata("protectedVal.kt")
public void testProtectedVal() throws Exception { public void testProtectedVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/protectedVal.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/protectedVal.kt");
@@ -240,7 +240,7 @@ public enum class DescriptorRendererModifier(val includeByDefault: Boolean) {
; ;
companion object { companion object {
val DEFAULTS = DescriptorRendererModifier.values().filter { it.includeByDefault }.toSet() @JvmField val DEFAULTS = DescriptorRendererModifier.values().filter { it.includeByDefault }.toSet()
val ALL = DescriptorRendererModifier.values().toSet() @JvmField val ALL = DescriptorRendererModifier.values().toSet()
} }
} }
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
public abstract class TypeSubstitution { public abstract class TypeSubstitution {
companion object { companion object {
@JvmStatic @JvmField
public val EMPTY: TypeSubstitution = object : TypeSubstitution() { public val EMPTY: TypeSubstitution = object : TypeSubstitution() {
override fun get(key: KotlinType) = null override fun get(key: KotlinType) = null
override fun isEmpty() = true override fun isEmpty() = true
@@ -32,10 +32,13 @@ fwBackingField.kt:62
fwBackingField.kt:45 fwBackingField.kt:45
fwBackingField.kt:48 fwBackingField.kt:48
fwBackingField.kt:62 fwBackingField.kt:62
fwBackingField.kt:42
fwBackingField.kt:45 fwBackingField.kt:45
fwBackingField.kt:51 fwBackingField.kt:51
fwBackingField.kt:42
fwBackingField.kt:48 fwBackingField.kt:48
fwBackingField.kt:52 fwBackingField.kt:52
fwBackingField.kt:42
fwBackingField.kt:48 fwBackingField.kt:48
fwBackingField.kt:54 fwBackingField.kt:54
fwBackingField.kt:63 fwBackingField.kt:63
@@ -892,6 +892,18 @@ public class ExperimentalIncrementalJpsTestGenerated extends AbstractExperimenta
doTest(fileName); doTest(fileName);
} }
@TestMetadata("jvmFieldChanged")
public void testJvmFieldChanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldChanged/");
doTest(fileName);
}
@TestMetadata("jvmFieldUnchanged")
public void testJvmFieldUnchanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldUnchanged/");
doTest(fileName);
}
@TestMetadata("methodAddedInSuper") @TestMetadata("methodAddedInSuper")
public void testMethodAddedInSuper() throws Exception { public void testMethodAddedInSuper() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/methodAddedInSuper/"); String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/methodAddedInSuper/");
@@ -34,10 +34,18 @@ public class IncrementalConstantSearchTest : AbstractIncrementalJpsTest() {
doTest("jps-plugin/testData/incremental/custom/kotlinConstantChangedUsedInJava/") doTest("jps-plugin/testData/incremental/custom/kotlinConstantChangedUsedInJava/")
} }
fun testKotlinJvmFieldChangedUsedInJava() {
doTest("jps-plugin/testData/incremental/custom/kotlinJvmFieldChangedUsedInJava/")
}
fun testKotlinConstantUnchangedUsedInJava() { fun testKotlinConstantUnchangedUsedInJava() {
doTest("jps-plugin/testData/incremental/custom/kotlinConstantUnchangedUsedInJava/") doTest("jps-plugin/testData/incremental/custom/kotlinConstantUnchangedUsedInJava/")
} }
fun testKotlinJvmFieldUnchangedUsedInJava() {
doTest("jps-plugin/testData/incremental/custom/kotlinJvmFieldUnchangedUsedInJava/")
}
override val mockConstantSearch: Callbacks.ConstantAffectionResolver? override val mockConstantSearch: Callbacks.ConstantAffectionResolver?
get() = object : Callbacks.ConstantAffectionResolver { get() = object : Callbacks.ConstantAffectionResolver {
override fun request( override fun request(
@@ -892,6 +892,18 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("jvmFieldChanged")
public void testJvmFieldChanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldChanged/");
doTest(fileName);
}
@TestMetadata("jvmFieldUnchanged")
public void testJvmFieldUnchanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldUnchanged/");
doTest(fileName);
}
@TestMetadata("methodAddedInSuper") @TestMetadata("methodAddedInSuper")
public void testMethodAddedInSuper() throws Exception { public void testMethodAddedInSuper() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/methodAddedInSuper/"); String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/methodAddedInSuper/");
@@ -3,6 +3,6 @@ package test
class Klass { class Klass {
companion object { companion object {
// Old and new constant values are different, but their hashes are the same // Old and new constant values are different, but their hashes are the same
val CONST = "BF" const val CONST = "BF"
} }
} }
@@ -3,6 +3,6 @@ package test
class Klass { class Klass {
companion object { companion object {
// Old and new constant values are different, but their hashes are the same // Old and new constant values are different, but their hashes are the same
val CONST = "Ae" const val CONST = "Ae"
} }
} }
@@ -2,6 +2,6 @@ package test
class Klass { class Klass {
companion object { companion object {
val CONST = "bar" const val CONST = "bar"
} }
} }
@@ -0,0 +1,7 @@
import test.*;
class Usage {
public static void main(String[] args) {
System.out.println(Klass.CONST + Klass.CONST);
}
}
@@ -0,0 +1,13 @@
Cleaning output files:
out/production/module/test/Klass$Companion.class
out/production/module/test/Klass.class
End of files
Compiling files:
src/const.kt
End of files
Cleaning output files:
out/production/module/Usage.class
End of files
Compiling files:
src/Usage.java
End of files
@@ -0,0 +1,9 @@
package test
class Klass {
companion object {
// Old and new constant values are different, but their hashes are the same
@JvmField
val CONST = "BF"
}
}
@@ -0,0 +1,9 @@
package test
class Klass {
companion object {
// Old and new constant values are different, but their hashes are the same
@JvmField
val CONST = "Ae"
}
}
@@ -0,0 +1,7 @@
import test.*;
class Usage {
public static void main(String[] args) {
System.out.println(Klass.CONST + Klass.CONST);
}
}
@@ -0,0 +1,7 @@
Cleaning output files:
out/production/module/test/Klass$Companion.class
out/production/module/test/Klass.class
End of files
Compiling files:
src/const.kt
End of files
@@ -0,0 +1,8 @@
package test
class Klass {
companion object {
@JvmField
val CONST = "bar"
}
}
@@ -3,6 +3,6 @@ package test
class Klass { class Klass {
companion object { companion object {
// Old and new constant values are different, but their hashes are the same // Old and new constant values are different, but their hashes are the same
val CONST = "BF" const val CONST = "BF"
} }
} }
@@ -3,6 +3,6 @@ package test
class Klass { class Klass {
companion object { companion object {
// Old and new constant values are different, but their hashes are the same // Old and new constant values are different, but their hashes are the same
val CONST = "Ae" const val CONST = "Ae"
} }
} }
@@ -2,6 +2,6 @@ package test
class Klass { class Klass {
companion object { companion object {
val CONST = "bar" const val CONST = "bar"
} }
} }
@@ -0,0 +1,7 @@
import test.*;
class Usage {
public static void main(String[] args) {
System.out.println(Klass.CONST + Klass.CONST);
}
}
@@ -0,0 +1,18 @@
Cleaning output files:
out/production/module/test/Klass$Companion.class
out/production/module/test/Klass.class
End of files
Compiling files:
src/const.kt
End of files
Cleaning output files:
out/production/module/Usage.class
out/production/module/test/Klass$Companion.class
out/production/module/test/Klass.class
End of files
Compiling files:
src/const.kt
End of files
Compiling files:
src/Usage.java
End of files
@@ -0,0 +1,9 @@
package test
class Klass {
companion object {
// Old and new constant values are different, but their hashes are the same
@JvmField
val CONST = "BF"
}
}
@@ -0,0 +1,9 @@
package test
class Klass {
companion object {
// Old and new constant values are different, but their hashes are the same
@JvmField
val CONST = "Ae"
}
}
@@ -0,0 +1,7 @@
import test.*;
class Usage {
public static void main(String[] args) {
System.out.println(Klass.CONST + Klass.CONST);
}
}
@@ -0,0 +1,7 @@
Cleaning output files:
out/production/module/test/Klass$Companion.class
out/production/module/test/Klass.class
End of files
Compiling files:
src/const.kt
End of files
@@ -0,0 +1,8 @@
package test
class Klass {
companion object {
@JvmField
val CONST = "bar"
}
}
@@ -9,7 +9,7 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val login = 5 const val login = 5
} }
} }
} }
@@ -9,7 +9,7 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val login = 5 const val login = 5
} }
} }
} }
@@ -9,7 +9,7 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val login = 5 const val login = 5
} }
} }
} }
@@ -9,7 +9,7 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val login = 5 const val login = 5
} }
} }
} }
@@ -11,7 +11,7 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val login = 5 const val login = 5
} }
} }
} }
@@ -11,7 +11,7 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val login = 5 const val login = 5
} }
} }
} }
@@ -9,15 +9,15 @@ import kotlinx.android.synthetic.main.layout1.*
class R { class R {
class id { class id {
companion object { companion object {
val item_detail_container = 0 const val item_detail_container = 0
val textView1 = 1 const val textView1 = 1
val password = 2 const val password = 2
val textView2 = 3 const val textView2 = 3
val passwordConfirmation = 4 const val passwordConfirmation = 4
val login = 5 const val login = 5
val passwordField = 6 const val passwordField = 6
val passwordCaption = 7 const val passwordCaption = 7
val loginButton = 8 const val loginButton = 8
} }
} }
} }
@@ -9,12 +9,12 @@ import kotlinx.android.synthetic.main.layout1.*
class R { class R {
class id { class id {
companion object { companion object {
val item_detail_container = 0 const val item_detail_container = 0
val textView1 = 1 const val textView1 = 1
val password = 2 const val password = 2
val textView2 = 3 const val textView2 = 3
val passwordConfirmation = 4 const val passwordConfirmation = 4
val login = 5 const val login = 5
} }
} }
} }
@@ -8,12 +8,12 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val item_detail_container = 0 const val item_detail_container = 0
val textView1 = 1 const val textView1 = 1
val password = 2 const val password = 2
val textView2 = 3 const val textView2 = 3
val passwordConfirmation = 4 const val passwordConfirmation = 4
val login = 5 const val login = 5
} }
} }
} }
@@ -8,12 +8,12 @@ import kotlinx.android.synthetic.main.layout.*
class R { class R {
class id { class id {
companion object { companion object {
val item_detail_container = 0 const val item_detail_container = 0
val textView1 = 1 const val textView1 = 1
val password = 2 const val password = 2
val textView2 = 3 const val textView2 = 3
val passwordConfirmation = 4 const val passwordConfirmation = 4
val login = 5 const val login = 5
} }
} }
} }
@@ -9,8 +9,8 @@ import kotlinx.android.synthetic.main.layout.view.*
class R { class R {
class id { class id {
companion object { companion object {
val container = 0 const val container = 0
val login = 1 const val login = 1
} }
} }
} }
@@ -9,8 +9,8 @@ import kotlinx.android.synthetic.main.layout.view.*
class R { class R {
class id { class id {
companion object { companion object {
val container = 0 const val container = 0
val login = 1 const val login = 1
} }
} }
} }