Error messages about "var with open / custom setter initialization" changed accordingly with the new backing field syntax
This commit is contained in:
+2
-2
@@ -280,9 +280,9 @@ public class DefaultErrorMessages {
|
||||
MAP.put(VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER, "''{0}'' on secondary constructor parameter is not allowed", TO_STRING);
|
||||
|
||||
MAP.put(INITIALIZATION_USING_BACKING_FIELD_CUSTOM_SETTER,
|
||||
"This property has a custom setter, so initialization using backing field required", NAME);
|
||||
"This property cannot be initialized inside ''init'' block because it has a custom setter", NAME);
|
||||
MAP.put(INITIALIZATION_USING_BACKING_FIELD_OPEN_SETTER,
|
||||
"Setter of this property can be overridden, so initialization using backing field required", NAME);
|
||||
"This property cannot be initialized inside ''init'' block because it has an open setter", NAME);
|
||||
|
||||
MAP.put(UNREACHABLE_CODE, "Unreachable code", TO_STRING);
|
||||
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
class Identifier<T>(t : T?, myHasDollar : Boolean) {
|
||||
private val myT : T?
|
||||
|
||||
public fun getName() : T? { return myT }
|
||||
|
||||
companion object {
|
||||
open public fun <T> init(name : T?) : Identifier<T> {
|
||||
val __ = Identifier<T>(name, false)
|
||||
return __
|
||||
}
|
||||
}
|
||||
init {
|
||||
myT = t
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var i3 : Identifier<String?>? = Identifier.init<String?>("name")
|
||||
System.out?.println(i3?.getName())
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Flower() {
|
||||
|
||||
var minusOne: Int = 1
|
||||
get() = field + 1
|
||||
set(n: Int) { field = n - 1 }
|
||||
|
||||
var oldSyntax: Int = 1
|
||||
get() = <!BACKING_FIELD_OLD_SYNTAX!>$oldSyntax<!> - 1
|
||||
set(arg) { <!BACKING_FIELD_OLD_SYNTAX!>$oldSyntax<!> = arg + 1 }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public final class Flower {
|
||||
public constructor Flower()
|
||||
public final var minusOne: kotlin.Int
|
||||
public final var oldSyntax: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -1362,6 +1362,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/backingField"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("CustomGetSet.kt")
|
||||
public void testCustomGetSet() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/CustomGetSet.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("CustomGetVal.kt")
|
||||
public void testCustomGetVal() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/CustomGetVal.kt");
|
||||
|
||||
+6
@@ -5650,6 +5650,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt535.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt560.kt")
|
||||
public void testKt560() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt560.kt");
|
||||
|
||||
@@ -38,10 +38,6 @@ public final class PropertyAccessTest extends SingleFileTranslationTest {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testBackendField() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testSetter() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
val a: Int = 1
|
||||
get() = field + 1
|
||||
|
||||
fun getA(): Int {
|
||||
return a
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.a != 2) return "A().a != 2, it: ${a.a}"
|
||||
if (a.getA() != 2) return "A().getA() != 2, it: ${a.getA()}"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user