From d78d4bc44c2029cf71e256f705c1c842abab7611 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 28 May 2014 19:17:31 +0400 Subject: [PATCH] Disallow extension properties with backing fields #KT-1682 Fixed --- .../jet/codegen/ExpressionCodegen.java | 20 ++++++---- .../org/jetbrains/jet/codegen/StackValue.java | 30 ++++++-------- .../codegen/context/FieldOwnerContext.java | 11 ++---- .../jet/lang/diagnostics/Errors.java | 1 + .../rendering/DefaultErrorMessages.java | 1 + .../jet/lang/resolve/DeclarationsChecker.java | 22 +++++++---- .../accessorForPrivateSetter.kt | 21 ++++++++++ .../box/extensionProperties/inClass.kt | 13 ++++--- .../inClassLongTypeInReceiver.kt | 34 ++++++++++------ .../inClassWithEmptySetter.kt | 13 ------- .../extensionProperties/inClassWithGetter.kt | 19 +++++---- .../inClassWithPrivateGetter.kt | 19 +++++---- .../inClassWithPrivateSetter.kt | 25 ++++++------ .../extensionProperties/inClassWithSetter.kt | 25 ++++++------ .../box/extensionProperties/topLevel.kt | 7 ++-- .../topLevelLongTypeInReceiver.kt | 28 +++++++++---- .../topLevelSetterLongTypeInReceiver.kt | 17 -------- .../extensionProperties/topLevelWithGetter.kt | 8 ---- .../extensionProperties/topLevelWithSetter.kt | 10 ----- .../codegen/box/fieldRename/inPackage.kt | 18 --------- .../codegen/box/fieldRename/simple.kt | 22 ----------- .../codegen/box/functions/invoke/kt3772.kt | 4 +- .../codegen/box/labels/propertyAccessor.kt | 20 +--------- .../labels/propertyAccessorFunctionLiteral.kt | 12 +----- .../propertyAccessorInnerExtensionFun.kt | 5 ++- .../box/labels/propertyAccessorObject.kt | 38 +----------------- .../codegen/box/properties/generalAccess.kt | 4 +- .../testData/codegen/box/properties/kt1892.kt | 8 ++-- .../testData/codegen/box/strings/ea35743.kt | 2 +- .../tests/enum/extensionNamedAsEnumEntry.kt | 4 +- .../tests/extensions/ExtensionFunctions.kt | 2 +- .../extensions/kt819ExtensionProperties.kt | 13 ++++--- .../diagnostics/tests/extensions/object.kt | 2 +- .../diagnostics/tests/overload/kt1998.kt | 3 +- .../ConflictingExtensionProperties.kt | 4 +- .../tests/regressions/kt1489_1728.kt | 4 +- .../tests/resolve/invoke/invokeAsExtension.kt | 3 +- .../tests/resolve/invoke/invokeAsMember.kt | 3 +- .../resolve/invoke/invokeAsMemberExtension.kt | 3 +- .../tests/resolve/invoke/kt3772.kt | 6 ++- .../initializerScopeOfExtensionProperty.kt | 12 +++--- .../thisAndSuper/thisInPropertyInitializer.kt | 2 +- .../prop/defaultAccessors/ExtValLong.kt | 8 ++-- .../prop/defaultAccessors/ExtValLong.txt | 8 ++-- .../prop/defaultAccessors/ExtVarLong.kt | 27 +++++++++++-- .../prop/defaultAccessors/ExtVarLong.txt | 39 +++++++++++++------ .../defaultAccessors/ExtVarLongWithSet.kt | 28 ------------- .../defaultAccessors/ExtVarLongWithSet.txt | 29 -------------- .../classObject/class/extensionPublicVal.kt | 13 ------- .../classObject/class/extensionPublicVar.kt | 13 ------- .../rename/extensionAndExtension.kt | 18 --------- .../rename/extensionAndProperty.kt | 16 -------- .../classObject/trait/extensionPublicVal.kt | 13 ------- .../classObject/trait/extensionPublicVar.kt | 13 ------- .../flags/WriteFlagsTestGenerated.java | 30 -------------- .../BlackBoxCodegenTestGenerated.java | 35 +++-------------- .../jvm/compiler/LoadJavaTestGenerated.java | 5 --- ...esolveRecursiveComparingTestGenerated.java | 5 --- .../jet/lang/resolve/java/JvmAbi.java | 18 +-------- idea/testData/checker/ExtensionFunctions.kt | 2 +- idea/testData/checker/Redeclaration.kt | 2 +- .../tinyApp/src/evaluate/dependentOnFile.kt | 2 +- .../stubs/LazyResolveByStubTestGenerated.java | 5 --- js/js.libraries/src/core/string.kt | 2 +- js/js.libraries/src/stdlib/domCode.kt | 2 +- .../expression/misc/cases/elvisWithThrow.kt | 2 +- .../cases/propertyWithGetterAndSetter.kt | 2 +- .../nameClashes/cases/overloadExtension.kt | 4 +- .../cases/nativePropertyWithCustomName.kt | 4 +- .../cases/nativePropertiesNameClashes.kt | 4 +- .../cases/overrideExtensionProperty.kt | 6 +-- .../testData/regression/cases/kt2470.kt | 2 +- 72 files changed, 297 insertions(+), 578 deletions(-) create mode 100644 compiler/testData/codegen/box/extensionProperties/accessorForPrivateSetter.kt delete mode 100644 compiler/testData/codegen/box/extensionProperties/inClassWithEmptySetter.kt delete mode 100644 compiler/testData/codegen/box/extensionProperties/topLevelSetterLongTypeInReceiver.kt delete mode 100644 compiler/testData/codegen/box/extensionProperties/topLevelWithGetter.kt delete mode 100644 compiler/testData/codegen/box/extensionProperties/topLevelWithSetter.kt delete mode 100644 compiler/testData/codegen/box/fieldRename/inPackage.kt delete mode 100644 compiler/testData/codegen/box/fieldRename/simple.kt delete mode 100644 compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.kt delete mode 100644 compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.txt delete mode 100644 compiler/testData/writeFlags/property/classObject/class/extensionPublicVal.kt delete mode 100644 compiler/testData/writeFlags/property/classObject/class/extensionPublicVar.kt delete mode 100644 compiler/testData/writeFlags/property/classObject/rename/extensionAndExtension.kt delete mode 100644 compiler/testData/writeFlags/property/classObject/rename/extensionAndProperty.kt delete mode 100644 compiler/testData/writeFlags/property/classObject/trait/extensionPublicVal.kt delete mode 100644 compiler/testData/writeFlags/property/classObject/trait/extensionPublicVar.kt diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 3803a0428ef..a293a69be08 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1790,6 +1790,7 @@ public class ExpressionCodegen extends JetVisitor implem boolean isStatic = containingDeclaration instanceof PackageFragmentDescriptor; boolean isSuper = superExpression != null; boolean isInsideClass = isCallInsideSameClassAsDeclared(propertyDescriptor, context); + boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null; JetType delegateType = getPropertyDelegateType(propertyDescriptor, bindingContext); boolean isDelegatedProperty = delegateType != null; @@ -1859,17 +1860,22 @@ public class ExpressionCodegen extends JetVisitor implem owner = callableMethod.getOwner(); } - String name; - if (propertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) { - assert backingFieldContext instanceof FieldOwnerContext : "Actual context is " + backingFieldContext + " but should be instance of FieldOwnerContext" ; - name = ((FieldOwnerContext) backingFieldContext).getFieldName(propertyDescriptor, isDelegatedProperty); - } else { - name = JvmAbi.getDefaultPropertyName(propertyDescriptor.getName(), isDelegatedProperty, propertyDescriptor.getReceiverParameter() != null); + String fieldName; + if (isExtensionProperty && !isDelegatedProperty) { + fieldName = null; + } + else if (propertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) { + assert backingFieldContext instanceof FieldOwnerContext + : "Actual context is " + backingFieldContext + " but should be instance of FieldOwnerContext"; + fieldName = ((FieldOwnerContext) backingFieldContext).getFieldName(propertyDescriptor, isDelegatedProperty); + } + else { + fieldName = JvmAbi.getDefaultFieldNameForProperty(propertyDescriptor.getName(), isDelegatedProperty); } return StackValue.property(propertyDescriptor, owner, typeMapper.mapType(isDelegatedProperty && forceField ? delegateType : propertyDescriptor.getOriginal().getType()), - isStatic, name, callableGetter, callableSetter, state); + isStatic, fieldName, callableGetter, callableSetter, state); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index 90a33a8a83f..7923ef58712 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -144,12 +144,12 @@ public abstract class StackValue { @NotNull Type methodOwner, @NotNull Type type, boolean isStatic, - @NotNull String name, + @Nullable String fieldName, @Nullable CallableMethod getter, @Nullable CallableMethod setter, GenerationState state ) { - return new Property(descriptor, methodOwner, getter, setter, isStatic, name, type, state); + return new Property(descriptor, methodOwner, getter, setter, isStatic, fieldName, type, state); } @NotNull @@ -817,24 +817,19 @@ public abstract class StackValue { } static class Property extends StackValueWithSimpleReceiver { - @Nullable private final CallableMethod getter; - @Nullable private final CallableMethod setter; - @NotNull - public final Type methodOwner; + private final Type methodOwner; - @NotNull private final PropertyDescriptor descriptor; - @NotNull private final GenerationState state; - private final String name; + private final String fieldName; public Property( @NotNull PropertyDescriptor descriptor, @NotNull Type methodOwner, @Nullable CallableMethod getter, @Nullable CallableMethod setter, boolean isStatic, - @NotNull String name, @NotNull Type type, @NotNull GenerationState state + @Nullable String fieldName, @NotNull Type type, @NotNull GenerationState state ) { super(type, isStatic); this.methodOwner = methodOwner; @@ -842,14 +837,14 @@ public abstract class StackValue { this.setter = setter; this.descriptor = descriptor; this.state = state; - this.name = name; + this.fieldName = fieldName; } @Override public void put(Type type, InstructionAdapter v) { if (getter == null) { - v.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, methodOwner.getInternalName(), getPropertyName(), - this.type.getDescriptor()); + assert fieldName != null : "Property should have either a getter or a field name: " + descriptor; + v.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, methodOwner.getInternalName(), fieldName, this.type.getDescriptor()); genNotNullAssertionForField(v, state, descriptor); coerceTo(type, v); } @@ -864,18 +859,15 @@ public abstract class StackValue { public void store(Type topOfStackType, InstructionAdapter v) { coerceFrom(topOfStackType, v); if (setter == null) { - v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, methodOwner.getInternalName(), getPropertyName(), - this.type.getDescriptor()); } + assert fieldName != null : "Property should have either a setter or a field name: " + descriptor; + v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, methodOwner.getInternalName(), fieldName, this.type.getDescriptor()); + } else { Method method = setter.getAsmMethod(); v.visitMethodInsn(setter.getInvokeOpcode(), setter.getOwner().getInternalName(), method.getName(), method.getDescriptor()); } } - private String getPropertyName() { - return name; - } - public boolean isPropertyWithBackingFieldInOuterClass() { return descriptor instanceof AccessorForPropertyBackingFieldInOuterClass; } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/FieldOwnerContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/FieldOwnerContext.java index c4d91177101..8088c2922cf 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/context/FieldOwnerContext.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/FieldOwnerContext.java @@ -44,16 +44,11 @@ public abstract class FieldOwnerContext extends } @NotNull - public String getFieldName(@NotNull PropertyDescriptor descriptor, boolean isDelegated) { + public String getFieldName(@NotNull PropertyDescriptor possiblySubstitutedDescriptor, boolean isDelegated) { + PropertyDescriptor descriptor = possiblySubstitutedDescriptor.getOriginal(); assert descriptor.getKind().isReal() : "Only declared properties can have backing fields: " + descriptor; - boolean isExtension = descriptor.getReceiverParameter() != null; - return getFieldName(descriptor.getOriginal(), isDelegated, isExtension); - } - - @NotNull - private String getFieldName(@NotNull PropertyDescriptor descriptor, boolean isDelegated, boolean isExtension) { - String defaultPropertyName = JvmAbi.getDefaultPropertyName(descriptor.getName(), isDelegated, isExtension); + String defaultPropertyName = JvmAbi.getDefaultFieldNameForProperty(descriptor.getName(), isDelegated); Map descriptor2Name = fieldNames.get(defaultPropertyName); if (descriptor2Name == null) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index 7b3d1008aa8..885b1920462 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -263,6 +263,7 @@ public interface Errors { DiagnosticFactory0 MUST_BE_INITIALIZED = DiagnosticFactory0.create(ERROR, NAMED_ELEMENT); DiagnosticFactory0 MUST_BE_INITIALIZED_OR_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, NAMED_ELEMENT); + DiagnosticFactory0 EXTENSION_PROPERTY_WITH_BACKING_FIELD = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 PROPERTY_INITIALIZER_NO_BACKING_FIELD = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 PROPERTY_INITIALIZER_IN_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 FINAL_PROPERTY_IN_TRAIT = DiagnosticFactory0.create(ERROR, FINAL_MODIFIER); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java index 5a81a687f86..a6069de8946 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java @@ -131,6 +131,7 @@ public class DefaultErrorMessages { MAP.put(MUST_BE_INITIALIZED_OR_BE_ABSTRACT, "Property must be initialized or be abstract"); MAP.put(PROPERTY_INITIALIZER_IN_TRAIT, "Property initializers are not allowed in traits"); MAP.put(FINAL_PROPERTY_IN_TRAIT, "Abstract property in trait cannot be final"); + MAP.put(EXTENSION_PROPERTY_WITH_BACKING_FIELD, "Extension property cannot be initialized because it has no backing field"); MAP.put(PROPERTY_INITIALIZER_NO_BACKING_FIELD, "Initializer is not allowed here because this property has no backing field"); MAP.put(ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS, "Abstract property ''{0}'' in non-abstract class ''{1}''", STRING, NAME); MAP.put(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, "Abstract function ''{0}'' in non-abstract class ''{1}''", STRING, NAME); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java index 22992ce05b1..a07420658a7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java @@ -402,10 +402,7 @@ public class DeclarationsChecker { } } - private void checkPropertyInitializer( - @NotNull JetProperty property, - @NotNull PropertyDescriptor propertyDescriptor - ) { + private void checkPropertyInitializer(@NotNull JetProperty property, @NotNull PropertyDescriptor propertyDescriptor) { JetPropertyAccessor getter = property.getGetter(); JetPropertyAccessor setter = property.getSetter(); boolean hasAccessorImplementation = (getter != null && getter.hasBody()) || @@ -421,14 +418,17 @@ public class DeclarationsChecker { boolean inTrait = containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor)containingDeclaration).getKind() == ClassKind.TRAIT; JetExpression initializer = property.getInitializer(); JetPropertyDelegate delegate = property.getDelegate(); - boolean backingFieldRequired = trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor); + boolean backingFieldRequired = + Boolean.TRUE.equals(trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)); if (inTrait && backingFieldRequired && hasAccessorImplementation) { trace.report(BACKING_FIELD_IN_TRAIT.on(property)); } + if (initializer == null && delegate == null) { boolean error = false; - if (backingFieldRequired && !inTrait && !trace.getBindingContext().get(BindingContext.IS_INITIALIZED, propertyDescriptor)) { + if (backingFieldRequired && !inTrait && + Boolean.FALSE.equals(trace.getBindingContext().get(BindingContext.IS_INITIALIZED, propertyDescriptor))) { if (!(containingDeclaration instanceof ClassDescriptor) || hasAccessorImplementation) { error = true; trace.report(MUST_BE_INITIALIZED.on(property)); @@ -446,6 +446,7 @@ public class DeclarationsChecker { } return; } + if (inTrait) { if (delegate != null) { trace.report(DELEGATED_PROPERTY_IN_TRAIT.on(delegate)); @@ -454,8 +455,13 @@ public class DeclarationsChecker { trace.report(PROPERTY_INITIALIZER_IN_TRAIT.on(initializer)); } } - else if (!backingFieldRequired && delegate == null) { - trace.report(PROPERTY_INITIALIZER_NO_BACKING_FIELD.on(initializer)); + else if (delegate == null) { + if (!backingFieldRequired) { + trace.report(PROPERTY_INITIALIZER_NO_BACKING_FIELD.on(initializer)); + } + else if (property.getReceiverTypeRef() != null) { + trace.report(EXTENSION_PROPERTY_WITH_BACKING_FIELD.on(initializer)); + } } } diff --git a/compiler/testData/codegen/box/extensionProperties/accessorForPrivateSetter.kt b/compiler/testData/codegen/box/extensionProperties/accessorForPrivateSetter.kt new file mode 100644 index 00000000000..6dae405db6d --- /dev/null +++ b/compiler/testData/codegen/box/extensionProperties/accessorForPrivateSetter.kt @@ -0,0 +1,21 @@ +class A { + var result = "Fail" + + private var Int.foo: String + get() = result + private set(value) { + result = value + } + + fun run(): String { + class O { + fun run() { + 42.foo = "OK" + } + } + O().run() + return (-42).foo + } +} + +fun box() = A().run() diff --git a/compiler/testData/codegen/box/extensionProperties/inClass.kt b/compiler/testData/codegen/box/extensionProperties/inClass.kt index 19dfc7d8759..7f1d8387e59 100644 --- a/compiler/testData/codegen/box/extensionProperties/inClass.kt +++ b/compiler/testData/codegen/box/extensionProperties/inClass.kt @@ -1,11 +1,12 @@ class Test { - val Int.foo: String = "OK" + val Int.foo: String + get() = "OK" - fun test(): String { - return 1.foo - } + fun test(): String { + return 1.foo + } } fun box(): String { - return Test().test() -} \ No newline at end of file + return Test().test() +} diff --git a/compiler/testData/codegen/box/extensionProperties/inClassLongTypeInReceiver.kt b/compiler/testData/codegen/box/extensionProperties/inClassLongTypeInReceiver.kt index 85bbbe5ac07..f4a3c12530b 100644 --- a/compiler/testData/codegen/box/extensionProperties/inClassLongTypeInReceiver.kt +++ b/compiler/testData/codegen/box/extensionProperties/inClassLongTypeInReceiver.kt @@ -1,16 +1,28 @@ class Test { - var Double.fooDouble: String = "fail" - var Long.fooLong: String = "fail" + var doubleStorage = "fail" + var longStorage = "fail" - fun test(): String { - val d = 1.0 - d.fooDouble = "O" - val l = 1.toLong() - l.fooLong = "K" - return d.fooDouble + l.fooLong - } + var Double.foo: String + get() = doubleStorage + set(value) { + doubleStorage = value + } + + var Long.bar: String + get() = longStorage + set(value) { + longStorage = value + } + + fun test(): String { + val d = 1.0 + d.foo = "O" + val l = 1L + l.bar = "K" + return d.foo + l.bar + } } fun box(): String { - return Test().test() -} \ No newline at end of file + return Test().test() +} diff --git a/compiler/testData/codegen/box/extensionProperties/inClassWithEmptySetter.kt b/compiler/testData/codegen/box/extensionProperties/inClassWithEmptySetter.kt deleted file mode 100644 index fac8522d5d6..00000000000 --- a/compiler/testData/codegen/box/extensionProperties/inClassWithEmptySetter.kt +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - var Int.foo: String = "fail" - - fun test(): String { - val i = 1 - i.foo = "OK" - return i.foo - } -} - -fun box(): String { - return Test().test() -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/extensionProperties/inClassWithGetter.kt b/compiler/testData/codegen/box/extensionProperties/inClassWithGetter.kt index 159e83036d8..e14ca8e686f 100644 --- a/compiler/testData/codegen/box/extensionProperties/inClassWithGetter.kt +++ b/compiler/testData/codegen/box/extensionProperties/inClassWithGetter.kt @@ -1,15 +1,14 @@ class Test { - val Int.foo: String = "OK" - get() { - val a = $foo - return "OK" - } + val Int.foo: String + get() { + return "OK" + } - fun test(): String { - return 1.foo - } + fun test(): String { + return 1.foo + } } fun box(): String { - return Test().test() -} \ No newline at end of file + return Test().test() +} diff --git a/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateGetter.kt b/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateGetter.kt index 9af6d6e83a4..b16ace4a6f0 100644 --- a/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateGetter.kt +++ b/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateGetter.kt @@ -1,15 +1,14 @@ class Test { - private val Int.foo: String = "OK" - get() { - val a = $foo - return "OK" - } + private val Int.foo: String + get() { + return "OK" + } - fun test(): String { - return 1.foo - } + fun test(): String { + return 1.foo + } } fun box(): String { - return Test().test() -} \ No newline at end of file + return Test().test() +} diff --git a/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateSetter.kt b/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateSetter.kt index 225e4975f78..de02691a5ac 100644 --- a/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateSetter.kt +++ b/compiler/testData/codegen/box/extensionProperties/inClassWithPrivateSetter.kt @@ -1,16 +1,19 @@ class Test { - var Int.foo: String = "OK" - private set(str: String) { - $foo = str - } + var storage = "Fail" - fun test(): String { - val i = 1 - i.foo = "OK" - return i.foo - } + var Int.foo: String + get() = storage + private set(str: String) { + storage = str + } + + fun test(): String { + val i = 1 + i.foo = "OK" + return i.foo + } } fun box(): String { - return Test().test() -} \ No newline at end of file + return Test().test() +} diff --git a/compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt b/compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt index e0e02d29b2f..c562b29e92e 100644 --- a/compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt +++ b/compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt @@ -1,16 +1,19 @@ class Test { - var Int.foo: String = "fail" - set(str: String) { - $foo = str - } + var storage = "Fail" - fun test(): String { - val i = 1 - i.foo = "OK" - return i.foo - } + var Int.foo: String + get() = storage + set(value) { + storage = value + } + + fun test(): String { + val i = 1 + i.foo = "OK" + return i.foo + } } fun box(): String { - return Test().test() -} \ No newline at end of file + return Test().test() +} diff --git a/compiler/testData/codegen/box/extensionProperties/topLevel.kt b/compiler/testData/codegen/box/extensionProperties/topLevel.kt index e10b5e038e6..df0abcea24e 100644 --- a/compiler/testData/codegen/box/extensionProperties/topLevel.kt +++ b/compiler/testData/codegen/box/extensionProperties/topLevel.kt @@ -1,5 +1,6 @@ -val Int.foo: String = "OK" +val Int.foo: String + get() = "OK" fun box(): String { - return 1.foo -} \ No newline at end of file + return 1.foo +} diff --git a/compiler/testData/codegen/box/extensionProperties/topLevelLongTypeInReceiver.kt b/compiler/testData/codegen/box/extensionProperties/topLevelLongTypeInReceiver.kt index c43cbe22149..b00288453a2 100644 --- a/compiler/testData/codegen/box/extensionProperties/topLevelLongTypeInReceiver.kt +++ b/compiler/testData/codegen/box/extensionProperties/topLevelLongTypeInReceiver.kt @@ -1,10 +1,22 @@ -var Double.fooDouble: String = "fail" -var Long.fooLong: String = "fail" +var fooStorage = "Fail" +var barStorage = "Fail" + +var Double.foo: String + get() = fooStorage + set(value) { + fooStorage = value + } + +var Long.bar: String + get() = barStorage + set(value) { + barStorage = value + } fun box(): String { - val d = 1.0 - d.fooDouble = "O" - val l = 1.toLong() - l.fooLong = "K" - return d.fooDouble + l.fooLong -} \ No newline at end of file + val d = 1.0 + d.foo = "O" + val l = 1L + l.bar = "K" + return d.foo + l.bar +} diff --git a/compiler/testData/codegen/box/extensionProperties/topLevelSetterLongTypeInReceiver.kt b/compiler/testData/codegen/box/extensionProperties/topLevelSetterLongTypeInReceiver.kt deleted file mode 100644 index e1973dfc2f5..00000000000 --- a/compiler/testData/codegen/box/extensionProperties/topLevelSetterLongTypeInReceiver.kt +++ /dev/null @@ -1,17 +0,0 @@ -var Double.fooDouble: String = "fail" - set(str: String) { - $fooDouble = str - } - -var Long.fooLong: String = "fail" - set(str: String) { - $fooLong = str - } - -fun box(): String { - val d = 1.0 - d.fooDouble = "O" - val l = 1.toLong() - l.fooLong = "K" - return d.fooDouble + l.fooLong -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/extensionProperties/topLevelWithGetter.kt b/compiler/testData/codegen/box/extensionProperties/topLevelWithGetter.kt deleted file mode 100644 index d18a9f83091..00000000000 --- a/compiler/testData/codegen/box/extensionProperties/topLevelWithGetter.kt +++ /dev/null @@ -1,8 +0,0 @@ -val Int.foo: String = "OK" - get() { - return $foo - } - -fun box(): String { - return 1.foo -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/extensionProperties/topLevelWithSetter.kt b/compiler/testData/codegen/box/extensionProperties/topLevelWithSetter.kt deleted file mode 100644 index 7a7607ca27a..00000000000 --- a/compiler/testData/codegen/box/extensionProperties/topLevelWithSetter.kt +++ /dev/null @@ -1,10 +0,0 @@ -var Int.foo: String = "fail" - set(str: String) { - $foo = str - } - -fun box(): String { - val i = 1 - i.foo = "OK" - return i.foo -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/fieldRename/inPackage.kt b/compiler/testData/codegen/box/fieldRename/inPackage.kt deleted file mode 100644 index 2629c427876..00000000000 --- a/compiler/testData/codegen/box/fieldRename/inPackage.kt +++ /dev/null @@ -1,18 +0,0 @@ -class A { } -class B { } - -public val A.prop: Int = 0; -public val B.prop: String = "1111"; -public val prop: Double = 0.1; - -public fun doTest() : String { - if (A().prop != 0) return "fail1" - if (B().prop != "1111") return "fail2" - if (prop != 0.1) return "fail3" - - return "OK" -} - -fun box() : String { - return doTest() -} diff --git a/compiler/testData/codegen/box/fieldRename/simple.kt b/compiler/testData/codegen/box/fieldRename/simple.kt deleted file mode 100644 index e2b94b8a27f..00000000000 --- a/compiler/testData/codegen/box/fieldRename/simple.kt +++ /dev/null @@ -1,22 +0,0 @@ -class A { } -class B { } - -class Test { - - public val A.prop: Int = 0; - public val B.prop: String = "1111"; - public val prop: Double = 0.1; - - public fun doTest() : String { - if (A().prop != 0) return "fail1" - if (B().prop != "1111") return "fail2" - if (prop != 0.1) return "fail3" - - return "OK" - } -} - - -fun box() : String { - return Test().doTest() -} diff --git a/compiler/testData/codegen/box/functions/invoke/kt3772.kt b/compiler/testData/codegen/box/functions/invoke/kt3772.kt index 2a81b3c61f0..687ad27032c 100644 --- a/compiler/testData/codegen/box/functions/invoke/kt3772.kt +++ b/compiler/testData/codegen/box/functions/invoke/kt3772.kt @@ -9,10 +9,10 @@ class B { } open class C -val C.attr = A() +val C.attr: A get() = A() open class D: C() -val D.attr = B() +val D.attr: B get() = B() fun box(): String { diff --git a/compiler/testData/codegen/box/labels/propertyAccessor.kt b/compiler/testData/codegen/box/labels/propertyAccessor.kt index 1a8ddf5004b..b9973e82ddc 100644 --- a/compiler/testData/codegen/box/labels/propertyAccessor.kt +++ b/compiler/testData/codegen/box/labels/propertyAccessor.kt @@ -3,27 +3,9 @@ val Int.getter: Int return this@getter } -var Int.setter1: Int = 2 - get() { - return this@setter1 - } - set(i: Int) { - $setter1 = this@setter1 - } - -var Int.setter2: Int = 2 - set(i: Int) { - $setter2 = this@setter2 - } - fun box(): String { val i = 1 if (i.getter != 1) return "getter failed" - i.setter1 = 2 - if (i.setter1 != 1) return "setter1 failed" - i.setter2 = 2 - if (i.setter2 != 1) return "setter2 failed" - return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt b/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt index 0668187e12a..6d26e930ed2 100644 --- a/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt +++ b/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt @@ -5,19 +5,9 @@ val Int.getter: Int }.invoke() } -var Int.setter: Int = 1 - set(i: Int) { - $setter = { - this@setter - }.invoke() - } - fun box(): String { val i = 1 if (i.getter != 1) return "getter failed" - i.setter = 2 - if (i.setter != 1) return "setter failed" - return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/labels/propertyAccessorInnerExtensionFun.kt b/compiler/testData/codegen/box/labels/propertyAccessorInnerExtensionFun.kt index 90353e8af08..113ec4bdf87 100644 --- a/compiler/testData/codegen/box/labels/propertyAccessorInnerExtensionFun.kt +++ b/compiler/testData/codegen/box/labels/propertyAccessorInnerExtensionFun.kt @@ -7,7 +7,8 @@ val Int.getter: Int } -var Int.setter: Int = 1 +var Int.setter: Int + get() = 1 set(i: Int) { val extFun = { Int.() -> this@setter @@ -24,4 +25,4 @@ fun box(): String { if (i.setter != 1) return "setter failed" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/labels/propertyAccessorObject.kt b/compiler/testData/codegen/box/labels/propertyAccessorObject.kt index 633b69957be..3459ad58cce 100644 --- a/compiler/testData/codegen/box/labels/propertyAccessorObject.kt +++ b/compiler/testData/codegen/box/labels/propertyAccessorObject.kt @@ -4,50 +4,16 @@ trait Base { val Int.getter: Int get() { - return object: Base { + return object : Base { override fun foo(): Int { return this@getter } }.foo() } -var Int.setter1: Int = 2 - set(i: Int) { - $setter1 = object: Base { - override fun foo(): Int { - this@setter1 - return 1 - } - }.foo() - } - - -var Int.setter2: Int = 2 - get() { - return object: Base { - override fun foo(): Int { - return this@setter2 - } - }.foo() - } - set(i: Int) { - $setter2 = object: Base { - override fun foo(): Int { - this@setter2 - return 1 - } - }.foo() - } - - fun box(): String { val i = 1 if (i.getter != 1) return "getter failed" - i.setter1 = 2 - if (i.setter1 != 1) return "setter1 failed" - i.setter2 = 2 - if (i.setter2 != 1) return "setter2 failed" - return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/properties/generalAccess.kt b/compiler/testData/codegen/box/properties/generalAccess.kt index 696610ff9e4..a69d3f1a358 100644 --- a/compiler/testData/codegen/box/properties/generalAccess.kt +++ b/compiler/testData/codegen/box/properties/generalAccess.kt @@ -2,7 +2,7 @@ package As val staticProperty : String = "1" -val String.staticExt = "1" +val String.staticExt: String get() = "1" open class A(val init: String) { @@ -10,7 +10,7 @@ open class A(val init: String) { private val privateProperty : String = init - val String.ext = "1" + val String.ext: String get() = "1" val Int.myInc : Int get() = this + 1 diff --git a/compiler/testData/codegen/box/properties/kt1892.kt b/compiler/testData/codegen/box/properties/kt1892.kt index 6b24e7943a1..ae564c7fc93 100644 --- a/compiler/testData/codegen/box/properties/kt1892.kt +++ b/compiler/testData/codegen/box/properties/kt1892.kt @@ -1,5 +1,5 @@ -val Int.ext : () -> Int = { 5 } -val Long.ext : Long = 4.ext().toLong() //(c.kt:4) -val y : Long = 10.toLong().ext +val Int.ext: () -> Int get() = { 5 } +val Long.ext: Long get() = 4.ext().toLong() //(c.kt:4) +val y: Long get() = 10L.ext -fun box() : String = if (y == 5.toLong()) "OK" else "fail" +fun box(): String = if (y == 5L) "OK" else "fail: $y" diff --git a/compiler/testData/codegen/box/strings/ea35743.kt b/compiler/testData/codegen/box/strings/ea35743.kt index 23832223923..31b59f2dcbb 100644 --- a/compiler/testData/codegen/box/strings/ea35743.kt +++ b/compiler/testData/codegen/box/strings/ea35743.kt @@ -1,4 +1,4 @@ -val Int.test = "test" +val Int.test: String get() = "test" fun box(): String { val x = "a ${1.test}" diff --git a/compiler/testData/diagnostics/tests/enum/extensionNamedAsEnumEntry.kt b/compiler/testData/diagnostics/tests/enum/extensionNamedAsEnumEntry.kt index 12ad15c4377..7441eca0cfa 100644 --- a/compiler/testData/diagnostics/tests/enum/extensionNamedAsEnumEntry.kt +++ b/compiler/testData/diagnostics/tests/enum/extensionNamedAsEnumEntry.kt @@ -2,7 +2,7 @@ enum class E { entry } -val Int.entry = 42 -val Long.entry = 239 +val Int.entry: Int get() = 42 +val Long.entry: Int get() = 239 val e = E.entry diff --git a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt index a2c5585ac31..a7611533027 100644 --- a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt +++ b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt @@ -2,7 +2,7 @@ package outer fun Int?.optint() : Unit {} -val Int?.optval : Unit = Unit.VALUE +val Int?.optval : Unit get() = Unit.VALUE fun T.foo(x : E, y : A) : T { y.plus(1) diff --git a/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt b/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt index 2602df3945a..46093150c9a 100644 --- a/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt +++ b/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt @@ -1,4 +1,3 @@ - //KT-819 Redeclaration error for extension properties with the same name and different receivers import java.io.* @@ -15,16 +14,20 @@ open class A() { open fun String.foo() {} open fun Int.foo() {} - open val String.foo = 0 - open val Int.foo = 1 + open val String.foo: Int + get() = 0 + open val Int.foo: Int + get() = 1 } class B() : A() { override fun String.foo() {} override fun Int.foo() {} - override val String.foo = 0 - override val Int.foo = 0 + override val String.foo: Int + get() = 0 + override val Int.foo: Int + get() = 0 fun use(s: String) { s.foo diff --git a/compiler/testData/diagnostics/tests/extensions/object.kt b/compiler/testData/diagnostics/tests/extensions/object.kt index 9e997519cc2..359316e1b95 100644 --- a/compiler/testData/diagnostics/tests/extensions/object.kt +++ b/compiler/testData/diagnostics/tests/extensions/object.kt @@ -1,6 +1,6 @@ object O fun Any.foo() = 42 -val Any?.bar = 239 +val Any?.bar: Int get() = 239 val x = O.foo() + O.bar diff --git a/compiler/testData/diagnostics/tests/overload/kt1998.kt b/compiler/testData/diagnostics/tests/overload/kt1998.kt index 5cb4ed25c1f..56e521a67e2 100644 --- a/compiler/testData/diagnostics/tests/overload/kt1998.kt +++ b/compiler/testData/diagnostics/tests/overload/kt1998.kt @@ -10,4 +10,5 @@ object A { class B -val B.c : String = "test" \ No newline at end of file +val B.c : String + get() = "test" diff --git a/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.kt b/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.kt index 97428be2fa6..6e3a6e2b70e 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.kt @@ -1,4 +1,4 @@ package foo -val Int.foo = 2 -val Int.foo = 3 +val Int.foo: Int get() = 2 +val Int.foo: Int get() = 3 diff --git a/compiler/testData/diagnostics/tests/regressions/kt1489_1728.kt b/compiler/testData/diagnostics/tests/regressions/kt1489_1728.kt index c97a10a9c7f..11acf7d5ad3 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt1489_1728.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt1489_1728.kt @@ -26,5 +26,5 @@ class C { //KT-1728 Can't invoke extension property as a function -val Int.ext : () -> Int = { 5 } -val x = 1.ext() \ No newline at end of file +val Int.ext : () -> Int get() = { 5 } +val x = 1.ext() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsExtension.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsExtension.kt index f04620b96b6..229e713d50e 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsExtension.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsExtension.kt @@ -24,7 +24,8 @@ fun test(a: A) { //variable as extension trait B { } -val B.foo = Foo() +val B.foo: Foo + get() = Foo() fun test(b: B) { b.foo() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMember.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMember.kt index 44c8084cbeb..c3f09111379 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMember.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMember.kt @@ -22,7 +22,8 @@ fun test(a: A) { //variable as extension trait B {} -val B.foo = Foo() +val B.foo: Foo + get() = Foo() fun test(b: B) { diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtension.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtension.kt index 2f312de73c8..06425369b39 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtension.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtension.kt @@ -40,7 +40,8 @@ fun test(c: C, b: B) { //variable as extension, trait D { } -val D.foo = Foo() +val D.foo: Foo + get() = Foo() class E { fun Foo.invoke() {} diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/kt3772.kt b/compiler/testData/diagnostics/tests/resolve/invoke/kt3772.kt index b1504a71400..a4f863cbd30 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/kt3772.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/kt3772.kt @@ -10,10 +10,12 @@ class B { } open class C -val C.attr = A() +val C.attr: A + get() = A() open class D: C() -val D.attr = B() +val D.attr: B + get() = B() fun main(args: Array) { diff --git a/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.kt b/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.kt index 602a3617d24..a907e4057dd 100644 --- a/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.kt +++ b/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.kt @@ -1,10 +1,10 @@ package i -val List.length = size() +val List.length = size() val List.length1 : Int get() = size() -val String.bd = this + "!" +val String.bd = this + "!" val String.bd1 : String get() = this + "!" @@ -13,7 +13,7 @@ class A { val ii : Int = 1 } -val A.foo = ii +val A.foo = ii val A.foo1 : Int get() = ii @@ -22,8 +22,8 @@ class C { inner class D {} } -val C.foo : C.D = D() +val C.foo : C.D = D() -val C.bar : C.D = C().D() +val C.bar : C.D = C().D() -val C.foo1 : C.D get() = D() \ No newline at end of file +val C.foo1 : C.D get() = D() diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/thisInPropertyInitializer.kt b/compiler/testData/diagnostics/tests/thisAndSuper/thisInPropertyInitializer.kt index 7d493932b4c..8876f572337 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/thisInPropertyInitializer.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/thisInPropertyInitializer.kt @@ -1,7 +1,7 @@ trait Base { fun foo() } -val String.test: Base = object: Base { +val String.test: Base = object: Base { override fun foo() { this@test } diff --git a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.kt b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.kt index 0a130534231..594e574064e 100644 --- a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.kt +++ b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.kt @@ -1,9 +1,9 @@ package test -val Long.date1: Object = java.util.Date() +val Long.date1: Any get() = java.util.Date() -internal val Long.date12: Object = java.util.Date() +internal val Long.date12: Any get() = java.util.Date() -private val Long.date3: java.util.Date = java.util.Date() +private val Long.date3: java.util.Date get() = java.util.Date() -public val Long.date4: java.util.Date = java.util.Date() \ No newline at end of file +public val Long.date4: java.util.Date get() = java.util.Date() diff --git a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.txt b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.txt index e7d636260c8..3b16e24df70 100644 --- a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.txt +++ b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtValLong.txt @@ -1,9 +1,9 @@ package test -internal val kotlin.Long.date1: java.lang.Object - internal fun kotlin.Long.(): java.lang.Object -internal val kotlin.Long.date12: java.lang.Object - internal fun kotlin.Long.(): java.lang.Object +internal val kotlin.Long.date1: kotlin.Any + internal fun kotlin.Long.(): kotlin.Any +internal val kotlin.Long.date12: kotlin.Any + internal fun kotlin.Long.(): kotlin.Any private val kotlin.Long.date3: java.util.Date private fun kotlin.Long.(): java.util.Date public val kotlin.Long.date4: java.util.Date diff --git a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.kt b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.kt index e0bdd4eb816..bd664877ae8 100644 --- a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.kt +++ b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.kt @@ -1,9 +1,28 @@ package test -var Long.date1: Object = java.util.Date() +var Long.date1: Any get() = java.util.Date() + set(value) {} -internal var Long.date12: Object = java.util.Date() +var Long.date2: Any get() = java.util.Date() + protected set(value) {} -private var Long.date3: java.util.Date = java.util.Date() +var Long.date3: Any get() = java.util.Date() + private set(value) {} -public var Long.date5: java.util.Date = java.util.Date() \ No newline at end of file +private var Long.date4: java.util.Date get() = java.util.Date() + set(value) {} + +public var Long.date7: java.util.Date get() = java.util.Date() + set(value) {} + +public var Long.date8: java.util.Date get() = java.util.Date() + internal set(value) {} + +public var Long.date9: java.util.Date get() = java.util.Date() + private set(value) {} + +public var Long.date10: java.util.Date get() = java.util.Date() + protected set(value) {} + +public var Long.date11: java.util.Date get() = java.util.Date() + public set(value) {} diff --git a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.txt b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.txt index 144df367248..5e20252b6c2 100644 --- a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.txt +++ b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.txt @@ -1,14 +1,29 @@ package test -internal var kotlin.Long.date1: java.lang.Object - internal fun kotlin.Long.(): java.lang.Object - internal fun kotlin.Long.(/*0*/ : java.lang.Object): kotlin.Unit -internal var kotlin.Long.date12: java.lang.Object - internal fun kotlin.Long.(): java.lang.Object - internal fun kotlin.Long.(/*0*/ : java.lang.Object): kotlin.Unit -private var kotlin.Long.date3: java.util.Date - private fun kotlin.Long.(): java.util.Date - private fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit -public var kotlin.Long.date5: java.util.Date - public fun kotlin.Long.(): java.util.Date - public fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit +internal var kotlin.Long.date1: kotlin.Any + internal fun kotlin.Long.(): kotlin.Any + internal fun kotlin.Long.(/*0*/ value: kotlin.Any): kotlin.Unit +public var kotlin.Long.date10: java.util.Date + public fun kotlin.Long.(): java.util.Date + protected fun kotlin.Long.(/*0*/ value: java.util.Date): kotlin.Unit +public var kotlin.Long.date11: java.util.Date + public fun kotlin.Long.(): java.util.Date + public fun kotlin.Long.(/*0*/ value: java.util.Date): kotlin.Unit +internal var kotlin.Long.date2: kotlin.Any + internal fun kotlin.Long.(): kotlin.Any + protected fun kotlin.Long.(/*0*/ value: kotlin.Any): kotlin.Unit +internal var kotlin.Long.date3: kotlin.Any + internal fun kotlin.Long.(): kotlin.Any + private fun kotlin.Long.(/*0*/ value: kotlin.Any): kotlin.Unit +private var kotlin.Long.date4: java.util.Date + private fun kotlin.Long.(): java.util.Date + private fun kotlin.Long.(/*0*/ value: java.util.Date): kotlin.Unit +public var kotlin.Long.date7: java.util.Date + public fun kotlin.Long.(): java.util.Date + public fun kotlin.Long.(/*0*/ value: java.util.Date): kotlin.Unit +public var kotlin.Long.date8: java.util.Date + public fun kotlin.Long.(): java.util.Date + internal fun kotlin.Long.(/*0*/ value: java.util.Date): kotlin.Unit +public var kotlin.Long.date9: java.util.Date + public fun kotlin.Long.(): java.util.Date + private fun kotlin.Long.(/*0*/ value: java.util.Date): kotlin.Unit diff --git a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.kt b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.kt deleted file mode 100644 index ddf07e1616a..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.kt +++ /dev/null @@ -1,28 +0,0 @@ -package test - -var Long.date1: Object = java.util.Date() - set - -var Long.date2: Object = java.util.Date() - protected set - -var Long.date3: Object = java.util.Date() - private set - -private var Long.date4: java.util.Date = java.util.Date() - set - -public var Long.date7: java.util.Date = java.util.Date() - set - -public var Long.date8: java.util.Date = java.util.Date() - internal set - -public var Long.date9: java.util.Date = java.util.Date() - private set - -public var Long.date10: java.util.Date = java.util.Date() - protected set - -public var Long.date11: java.util.Date = java.util.Date() - public set \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.txt b/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.txt deleted file mode 100644 index f59219bcd60..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.txt +++ /dev/null @@ -1,29 +0,0 @@ -package test - -internal var kotlin.Long.date1: java.lang.Object - internal fun kotlin.Long.(): java.lang.Object - internal fun kotlin.Long.(/*0*/ : java.lang.Object): kotlin.Unit -public var kotlin.Long.date10: java.util.Date - public fun kotlin.Long.(): java.util.Date - protected fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit -public var kotlin.Long.date11: java.util.Date - public fun kotlin.Long.(): java.util.Date - public fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit -internal var kotlin.Long.date2: java.lang.Object - internal fun kotlin.Long.(): java.lang.Object - protected fun kotlin.Long.(/*0*/ : java.lang.Object): kotlin.Unit -internal var kotlin.Long.date3: java.lang.Object - internal fun kotlin.Long.(): java.lang.Object - private fun kotlin.Long.(/*0*/ : java.lang.Object): kotlin.Unit -private var kotlin.Long.date4: java.util.Date - private fun kotlin.Long.(): java.util.Date - private fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit -public var kotlin.Long.date7: java.util.Date - public fun kotlin.Long.(): java.util.Date - public fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit -public var kotlin.Long.date8: java.util.Date - public fun kotlin.Long.(): java.util.Date - internal fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit -public var kotlin.Long.date9: java.util.Date - public fun kotlin.Long.(): java.util.Date - private fun kotlin.Long.(/*0*/ : java.util.Date): kotlin.Unit diff --git a/compiler/testData/writeFlags/property/classObject/class/extensionPublicVal.kt b/compiler/testData/writeFlags/property/classObject/class/extensionPublicVal.kt deleted file mode 100644 index 96026758538..00000000000 --- a/compiler/testData/writeFlags/property/classObject/class/extensionPublicVal.kt +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - class object { - public val Test.prop: Int = 0; - } -} - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop$ext -// FLAGS: ACC_FINAL, ACC_STATIC, ACC_PRIVATE - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test$object, prop$ext -// ABSENT: TRUE \ No newline at end of file diff --git a/compiler/testData/writeFlags/property/classObject/class/extensionPublicVar.kt b/compiler/testData/writeFlags/property/classObject/class/extensionPublicVar.kt deleted file mode 100644 index 2a7b58e901e..00000000000 --- a/compiler/testData/writeFlags/property/classObject/class/extensionPublicVar.kt +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - class object { - public var Test.prop: Int = 0; - } -} - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop$ext -// FLAGS: ACC_STATIC, ACC_PRIVATE - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test$object, prop$ext -// ABSENT: TRUE \ No newline at end of file diff --git a/compiler/testData/writeFlags/property/classObject/rename/extensionAndExtension.kt b/compiler/testData/writeFlags/property/classObject/rename/extensionAndExtension.kt deleted file mode 100644 index a35f992a47a..00000000000 --- a/compiler/testData/writeFlags/property/classObject/rename/extensionAndExtension.kt +++ /dev/null @@ -1,18 +0,0 @@ -class A { } -class B { } - -class Test { - - class object { - public val A.prop: Int = 0; - public val B.prop: Int = 0; - } -} - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop$ext -// FLAGS: ACC_PRIVATE, ACC_FINAL, ACC_STATIC - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop$ext$1 -// FLAGS: ACC_PRIVATE, ACC_FINAL, ACC_STATIC diff --git a/compiler/testData/writeFlags/property/classObject/rename/extensionAndProperty.kt b/compiler/testData/writeFlags/property/classObject/rename/extensionAndProperty.kt deleted file mode 100644 index a8ad2764c6e..00000000000 --- a/compiler/testData/writeFlags/property/classObject/rename/extensionAndProperty.kt +++ /dev/null @@ -1,16 +0,0 @@ -class Test { - - public val prop: Int = 0; - - class object { - public var Test.prop: Int = 0; - } -} - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop -// FLAGS: ACC_PRIVATE, ACC_FINAL - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop$ext -// FLAGS: ACC_STATIC, ACC_PRIVATE diff --git a/compiler/testData/writeFlags/property/classObject/trait/extensionPublicVal.kt b/compiler/testData/writeFlags/property/classObject/trait/extensionPublicVal.kt deleted file mode 100644 index 0b05cf2ea99..00000000000 --- a/compiler/testData/writeFlags/property/classObject/trait/extensionPublicVal.kt +++ /dev/null @@ -1,13 +0,0 @@ -trait Test { - class object { - public val Test.prop: Int = 0; - } -} - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop$ext -// ABSENT: TRUE - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test$object, prop$ext -// FLAGS: ACC_FINAL, ACC_PRIVATE \ No newline at end of file diff --git a/compiler/testData/writeFlags/property/classObject/trait/extensionPublicVar.kt b/compiler/testData/writeFlags/property/classObject/trait/extensionPublicVar.kt deleted file mode 100644 index a6450f3cf6c..00000000000 --- a/compiler/testData/writeFlags/property/classObject/trait/extensionPublicVar.kt +++ /dev/null @@ -1,13 +0,0 @@ -trait Test { - class object { - public var Test.prop: Int = 0; - } -} - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test, prop$ext -// ABSENT: TRUE - -// TESTED_OBJECT_KIND: property -// TESTED_OBJECTS: Test$object, prop$ext -// FLAGS: ACC_PRIVATE \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/flags/WriteFlagsTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/flags/WriteFlagsTestGenerated.java index f895d2193be..e0042b3c1d0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/flags/WriteFlagsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/flags/WriteFlagsTestGenerated.java @@ -500,16 +500,6 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest { doTest("compiler/testData/writeFlags/property/classObject/class/delegatedPublicVal.kt"); } - @TestMetadata("extensionPublicVal.kt") - public void testExtensionPublicVal() throws Exception { - doTest("compiler/testData/writeFlags/property/classObject/class/extensionPublicVal.kt"); - } - - @TestMetadata("extensionPublicVar.kt") - public void testExtensionPublicVar() throws Exception { - doTest("compiler/testData/writeFlags/property/classObject/class/extensionPublicVar.kt"); - } - @TestMetadata("internalVal.kt") public void testInternalVal() throws Exception { doTest("compiler/testData/writeFlags/property/classObject/class/internalVal.kt"); @@ -608,16 +598,6 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest { doTest("compiler/testData/writeFlags/property/classObject/rename/delegatedAndProperty.kt"); } - @TestMetadata("extensionAndExtension.kt") - public void testExtensionAndExtension() throws Exception { - doTest("compiler/testData/writeFlags/property/classObject/rename/extensionAndExtension.kt"); - } - - @TestMetadata("extensionAndProperty.kt") - public void testExtensionAndProperty() throws Exception { - doTest("compiler/testData/writeFlags/property/classObject/rename/extensionAndProperty.kt"); - } - @TestMetadata("propertyAndProperty.kt") public void testPropertyAndProperty() throws Exception { doTest("compiler/testData/writeFlags/property/classObject/rename/propertyAndProperty.kt"); @@ -641,16 +621,6 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest { doTest("compiler/testData/writeFlags/property/classObject/trait/delegatedPublicVal.kt"); } - @TestMetadata("extensionPublicVal.kt") - public void testExtensionPublicVal() throws Exception { - doTest("compiler/testData/writeFlags/property/classObject/trait/extensionPublicVal.kt"); - } - - @TestMetadata("extensionPublicVar.kt") - public void testExtensionPublicVar() throws Exception { - doTest("compiler/testData/writeFlags/property/classObject/trait/extensionPublicVar.kt"); - } - @TestMetadata("internalVal.kt") public void testInternalVal() throws Exception { doTest("compiler/testData/writeFlags/property/classObject/trait/internalVal.kt"); diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java index b502d55d5b9..cdb718c7914 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -2272,6 +2272,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { @TestMetadata("compiler/testData/codegen/box/extensionProperties") public static class ExtensionProperties extends AbstractBlackBoxCodegenTest { + @TestMetadata("accessorForPrivateSetter.kt") + public void testAccessorForPrivateSetter() throws Exception { + doTest("compiler/testData/codegen/box/extensionProperties/accessorForPrivateSetter.kt"); + } + public void testAllFilesPresentInExtensionProperties() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/box/extensionProperties"), Pattern.compile("^(.+)\\.kt$"), true); } @@ -2286,11 +2291,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest("compiler/testData/codegen/box/extensionProperties/inClassLongTypeInReceiver.kt"); } - @TestMetadata("inClassWithEmptySetter.kt") - public void testInClassWithEmptySetter() throws Exception { - doTest("compiler/testData/codegen/box/extensionProperties/inClassWithEmptySetter.kt"); - } - @TestMetadata("inClassWithGetter.kt") public void testInClassWithGetter() throws Exception { doTest("compiler/testData/codegen/box/extensionProperties/inClassWithGetter.kt"); @@ -2321,21 +2321,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest("compiler/testData/codegen/box/extensionProperties/topLevelLongTypeInReceiver.kt"); } - @TestMetadata("topLevelSetterLongTypeInReceiver.kt") - public void testTopLevelSetterLongTypeInReceiver() throws Exception { - doTest("compiler/testData/codegen/box/extensionProperties/topLevelSetterLongTypeInReceiver.kt"); - } - - @TestMetadata("topLevelWithGetter.kt") - public void testTopLevelWithGetter() throws Exception { - doTest("compiler/testData/codegen/box/extensionProperties/topLevelWithGetter.kt"); - } - - @TestMetadata("topLevelWithSetter.kt") - public void testTopLevelWithSetter() throws Exception { - doTest("compiler/testData/codegen/box/extensionProperties/topLevelWithSetter.kt"); - } - } @TestMetadata("compiler/testData/codegen/box/fakeOverride") @@ -2387,16 +2372,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest("compiler/testData/codegen/box/fieldRename/genericPropertyWithItself.kt"); } - @TestMetadata("inPackage.kt") - public void testInPackage() throws Exception { - doTest("compiler/testData/codegen/box/fieldRename/inPackage.kt"); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - doTest("compiler/testData/codegen/box/fieldRename/simple.kt"); - } - } @TestMetadata("compiler/testData/codegen/box/finally") diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java index 50acd433385..8c4f6b9a33e 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java @@ -2774,11 +2774,6 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.kt"); } - @TestMetadata("ExtVarLongWithSet.kt") - public void testExtVarLongWithSet() throws Exception { - doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.kt"); - } - } public static Test innerSuite() { diff --git a/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java b/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java index b7edf8a8a51..3196853ceab 100644 --- a/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java @@ -1252,11 +1252,6 @@ public class LazyResolveRecursiveComparingTestGenerated extends AbstractLazyReso doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.kt"); } - @TestMetadata("ExtVarLongWithSet.kt") - public void testExtVarLongWithSet() throws Exception { - doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.kt"); - } - } public static Test innerSuite() { diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java index dbca1a0e761..49e8d8f3874 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java @@ -50,28 +50,14 @@ public final class JvmAbi { return fqName.lastSegmentIs(Name.identifier(CLASS_OBJECT_CLASS_NAME)); } - @NotNull - public static String getPropertyDelegateName(@NotNull Name name) { - return name.asString() + DELEGATED_PROPERTY_NAME_SUFFIX; - } - @NotNull public static String getSyntheticMethodNameForAnnotatedProperty(@NotNull Name propertyName) { return propertyName.asString() + ANNOTATED_PROPERTY_METHOD_NAME_SUFFIX; } @NotNull - public static String getDefaultPropertyName(@NotNull Name propertyName, boolean isDelegated, boolean isExtensionProperty) { - if (isDelegated) { - return getPropertyDelegateName(propertyName); - } - - String name = propertyName.asString(); - if (isExtensionProperty) { - name += "$ext"; - } - return name; - + public static String getDefaultFieldNameForProperty(@NotNull Name propertyName, boolean isDelegated) { + return isDelegated ? propertyName.asString() + DELEGATED_PROPERTY_NAME_SUFFIX : propertyName.asString(); } private JvmAbi() { diff --git a/idea/testData/checker/ExtensionFunctions.kt b/idea/testData/checker/ExtensionFunctions.kt index 55c078ae6d3..56f06271db4 100644 --- a/idea/testData/checker/ExtensionFunctions.kt +++ b/idea/testData/checker/ExtensionFunctions.kt @@ -1,5 +1,5 @@ fun Int?.optint() : Unit {} -val Int?.optval : Unit = Unit.VALUE +val Int?.optval : Unit get() = Unit.VALUE fun T.foo(x : E, y : A) : T { y.plus(1) diff --git a/idea/testData/checker/Redeclaration.kt b/idea/testData/checker/Redeclaration.kt index 08cffc678bb..22f0b883675 100644 --- a/idea/testData/checker/Redeclaration.kt +++ b/idea/testData/checker/Redeclaration.kt @@ -25,4 +25,4 @@ object B { fun PairParam<T, T>() {} class PParam<T, T> {} -val <T, T> T.fooParam : Int = 1 \ No newline at end of file +val <T, T> T.fooParam : Int get() = 1 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/dependentOnFile.kt b/idea/testData/debugger/tinyApp/src/evaluate/dependentOnFile.kt index e6ae81e5616..8fd781bf716 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/dependentOnFile.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/dependentOnFile.kt @@ -21,7 +21,7 @@ object TestObject { } val testVal = 1 -val Int.testExtVal = 1 +val Int.testExtVal: Int get() = 1 val testDelVal by Delegate() class Delegate { diff --git a/idea/tests/org/jetbrains/jet/plugin/stubs/LazyResolveByStubTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/stubs/LazyResolveByStubTestGenerated.java index 1fa5e65fc53..596665556ea 100644 --- a/idea/tests/org/jetbrains/jet/plugin/stubs/LazyResolveByStubTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/stubs/LazyResolveByStubTestGenerated.java @@ -1252,11 +1252,6 @@ public class LazyResolveByStubTestGenerated extends AbstractLazyResolveByStubTes doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLong.kt"); } - @TestMetadata("ExtVarLongWithSet.kt") - public void testExtVarLongWithSet() throws Exception { - doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/prop/defaultAccessors/ExtVarLongWithSet.kt"); - } - } public static Test innerSuite() { diff --git a/js/js.libraries/src/core/string.kt b/js/js.libraries/src/core/string.kt index 93e880afa83..292ec434dde 100644 --- a/js/js.libraries/src/core/string.kt +++ b/js/js.libraries/src/core/string.kt @@ -36,7 +36,7 @@ native public fun String.match(regex : String) : Array = js.noImpl native public fun String.trim() : String = js.noImpl native("length") -public val CharSequence.size: Int = js.noImpl +public val CharSequence.size: Int get() = js.noImpl library public fun CharSequence.length(): Int = js.noImpl diff --git a/js/js.libraries/src/stdlib/domCode.kt b/js/js.libraries/src/stdlib/domCode.kt index 8d8bd316cab..6d2e3249b9b 100644 --- a/js/js.libraries/src/stdlib/domCode.kt +++ b/js/js.libraries/src/stdlib/domCode.kt @@ -7,7 +7,7 @@ public fun createDocument(): Document { return js.dom.html.document.implementation.createDocument(null, null, null) } -native public val Node.outerHTML: String = js.noImpl +native public val Node.outerHTML: String get() = js.noImpl /** Converts the node to an XML String */ public fun Node.toXmlString(): String = this.outerHTML diff --git a/js/js.translator/testData/expression/misc/cases/elvisWithThrow.kt b/js/js.translator/testData/expression/misc/cases/elvisWithThrow.kt index ad665ca5062..fa27af24649 100644 --- a/js/js.translator/testData/expression/misc/cases/elvisWithThrow.kt +++ b/js/js.translator/testData/expression/misc/cases/elvisWithThrow.kt @@ -11,7 +11,7 @@ fun bar(): Any? { } native -val Exception.message: String = noImpl +val Exception.message: String get() = noImpl fun box(): String { val a: String? = null diff --git a/js/js.translator/testData/extensionProperty/cases/propertyWithGetterAndSetter.kt b/js/js.translator/testData/extensionProperty/cases/propertyWithGetterAndSetter.kt index 766d4d6bd7d..80e64b4ac5d 100644 --- a/js/js.translator/testData/extensionProperty/cases/propertyWithGetterAndSetter.kt +++ b/js/js.translator/testData/extensionProperty/cases/propertyWithGetterAndSetter.kt @@ -10,7 +10,7 @@ var Test.b: Int a = c - 1 } -val Test.d: Int = 44 +val Test.d: Int get() = 44 fun box(): Boolean { val c = Test() diff --git a/js/js.translator/testData/nameClashes/cases/overloadExtension.kt b/js/js.translator/testData/nameClashes/cases/overloadExtension.kt index 2fcca16bebb..832471efda6 100644 --- a/js/js.translator/testData/nameClashes/cases/overloadExtension.kt +++ b/js/js.translator/testData/nameClashes/cases/overloadExtension.kt @@ -5,8 +5,8 @@ fun Int.foo() { fun String.foo() { } -val Int.bar = 1 -val String.bar = 2 +val Int.bar: Int get() = 1 +val String.bar: Int get() = 2 fun box(): String { val a = 43 diff --git a/js/js.translator/testData/native/cases/nativePropertyWithCustomName.kt b/js/js.translator/testData/native/cases/nativePropertyWithCustomName.kt index cc51a408fc4..868ec4fdfd7 100644 --- a/js/js.translator/testData/native/cases/nativePropertyWithCustomName.kt +++ b/js/js.translator/testData/native/cases/nativePropertyWithCustomName.kt @@ -9,8 +9,8 @@ native("\"O\"") val foo: String = noImpl native("boo") val bar: String = noImpl class A -native("__proto__") val Any.proto: String = noImpl -native("__proto__") val A.proto: String = noImpl +native("__proto__") val Any.proto: String get() = noImpl +native("__proto__") val A.proto: String get() = noImpl fun actual(foo: String, native("boo") bar: String) = foo + bar fun expected(foo: String, boo: String) = foo + boo diff --git a/js/js.translator/testData/propertyAccess/cases/nativePropertiesNameClashes.kt b/js/js.translator/testData/propertyAccess/cases/nativePropertiesNameClashes.kt index 10bc66cda15..e0ffbab5762 100644 --- a/js/js.translator/testData/propertyAccess/cases/nativePropertiesNameClashes.kt +++ b/js/js.translator/testData/propertyAccess/cases/nativePropertiesNameClashes.kt @@ -5,8 +5,8 @@ val PACKAGE = "Kotlin.modules.JS_TESTS.foo" native fun eval(e: String): Any? = noImpl class A -native val Any.__proto__: String = noImpl -native val A.__proto__: String = noImpl +native val Any.__proto__: String get() = noImpl +native val A.__proto__: String get() = noImpl fun box(): String { val a = A() diff --git a/js/js.translator/testData/propertyOverride/cases/overrideExtensionProperty.kt b/js/js.translator/testData/propertyOverride/cases/overrideExtensionProperty.kt index ad84649f9e7..de57f1469fb 100644 --- a/js/js.translator/testData/propertyOverride/cases/overrideExtensionProperty.kt +++ b/js/js.translator/testData/propertyOverride/cases/overrideExtensionProperty.kt @@ -3,9 +3,9 @@ package foo class T open class A { - open val T.foo: Int = 34 + open val T.foo: Int get() { - return $foo + return 34 } fun test(): Int { return T().foo @@ -13,7 +13,7 @@ open class A { } class B : A() { - override val T.foo: Int = 5 + override val T.foo: Int get() = 5 } diff --git a/js/js.translator/testData/regression/cases/kt2470.kt b/js/js.translator/testData/regression/cases/kt2470.kt index 57749c35537..32ae36a11f5 100644 --- a/js/js.translator/testData/regression/cases/kt2470.kt +++ b/js/js.translator/testData/regression/cases/kt2470.kt @@ -2,7 +2,7 @@ package foo -native val Exception.message: String = noImpl +native val Exception.message: String get() = noImpl public fun failsWith(block: () -> Any): T { try {