Old backing field with dollar is now forbidden
This commit is contained in:
@@ -556,7 +556,7 @@ public class JetFlowInformationProvider {
|
||||
if ((containingDeclaration instanceof ClassDescriptor)
|
||||
&& DescriptorUtils.isAncestor(containingDeclaration, declarationDescriptor, false)) {
|
||||
if (element instanceof JetSimpleNameExpression) {
|
||||
report(Errors.BACKING_FIELD_USAGE_DEPRECATED.on((JetSimpleNameExpression) element), cxtx);
|
||||
report(Errors.BACKING_FIELD_USAGE_FORBIDDEN.on((JetSimpleNameExpression) element), cxtx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -346,8 +346,8 @@ public interface Errors {
|
||||
DiagnosticFactory0<JetProperty> PRIVATE_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, PRIVATE_MODIFIER);
|
||||
DiagnosticFactory0<JetProperty> BACKING_FIELD_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_SYNTAX_DEPRECATED = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_USAGE_DEPRECATED = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_OLD_SYNTAX = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_USAGE_FORBIDDEN = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_LATEINIT_MODIFIER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_LATEINIT_MODIFIER_IMMUTABLE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
+2
-2
@@ -169,8 +169,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(INACCESSIBLE_BACKING_FIELD, "The backing field is not accessible here");
|
||||
MAP.put(NOT_PROPERTY_BACKING_FIELD, "The referenced variable is not a property and doesn't have backing field");
|
||||
|
||||
MAP.put(BACKING_FIELD_SYNTAX_DEPRECATED, "This backing field syntax is deprecated, use 'field' instead");
|
||||
MAP.put(BACKING_FIELD_USAGE_DEPRECATED, "Backing field usage is deprecated here, soon it will be possible only in property accessors");
|
||||
MAP.put(BACKING_FIELD_OLD_SYNTAX, "This backing field syntax is forbidden, use 'field' instead");
|
||||
MAP.put(BACKING_FIELD_USAGE_FORBIDDEN, "Backing field usage is forbidden here");
|
||||
|
||||
MAP.put(MIXING_NAMED_AND_POSITIONED_ARGUMENTS, "Mixing named and positioned arguments is not allowed");
|
||||
MAP.put(ARGUMENT_PASSED_TWICE, "An argument is already passed for this parameter");
|
||||
|
||||
@@ -655,7 +655,7 @@ public class BodyResolver {
|
||||
// This check may be considered redundant as long as $x is only accessible from accessors to $x
|
||||
if (descriptor == propertyDescriptor) { // TODO : original?
|
||||
trace.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor); // TODO: this trace?
|
||||
trace.report(Errors.BACKING_FIELD_SYNTAX_DEPRECATED.on(simpleNameExpression));
|
||||
trace.report(Errors.BACKING_FIELD_OLD_SYNTAX.on(simpleNameExpression));
|
||||
}
|
||||
}
|
||||
if (descriptor instanceof SyntheticFieldDescriptor) {
|
||||
|
||||
@@ -2,7 +2,7 @@ class C() {
|
||||
public var f: Int
|
||||
|
||||
init {
|
||||
$f = 610
|
||||
f = 610
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
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"
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package demo
|
||||
|
||||
public open class Identifier<T>(myName : T?, myHasDollar : Boolean) {
|
||||
private val myName : T?
|
||||
private var myHasDollar : Boolean
|
||||
private var myNullable : Boolean = true
|
||||
|
||||
init {
|
||||
$myName = myName
|
||||
$myHasDollar = myHasDollar
|
||||
}
|
||||
|
||||
open public fun getName() : T? {
|
||||
return myName
|
||||
}
|
||||
|
||||
companion object {
|
||||
open public fun <T> init(name : T?) : Identifier<T> {
|
||||
val __ = Identifier<T>(name, false)
|
||||
return __
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var i3 : Identifier<*>? = Identifier.init<String?>("name")
|
||||
System.out?.println("Hello, " + i3?.getName())
|
||||
return "OK"
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class Test {
|
||||
var prop4 : Int = 13
|
||||
|
||||
fun incProp4() {
|
||||
$prop4++
|
||||
prop4++
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ open class B(init: String) : A("1") {
|
||||
}
|
||||
|
||||
fun getWithBackingFieldProperty(): String {
|
||||
return $property
|
||||
return property
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class A {
|
||||
fun test2() : Int {
|
||||
r2++
|
||||
++r2
|
||||
return $r2
|
||||
return r2
|
||||
}
|
||||
|
||||
var r3: Int = 1;
|
||||
@@ -32,7 +32,7 @@ class A {
|
||||
fun test3() : Int {
|
||||
r3++
|
||||
++r3
|
||||
return $r3
|
||||
return r3
|
||||
}
|
||||
|
||||
var r4: Int = 1;
|
||||
@@ -49,7 +49,7 @@ class A {
|
||||
r4++
|
||||
holder += ":"
|
||||
++r4
|
||||
return $r4
|
||||
return r4
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ fun box() : String {
|
||||
|
||||
val p2 = A.test2()
|
||||
var holderValue = A.holder
|
||||
if (p2 != 3 || holderValue != "getR2getR2getR2") return "fail 2: $p2 ${holderValue}"
|
||||
if (p2 != 3 || holderValue != "getR2getR2getR2getR2") return "fail 2: $p2 ${holderValue}"
|
||||
|
||||
A.holder = ""
|
||||
val p3 = A.test3()
|
||||
@@ -68,7 +68,7 @@ fun box() : String {
|
||||
|
||||
A.holder = ""
|
||||
val p4 = A.test4()
|
||||
if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4") return "fail 4: $p4 ${A.holder}"
|
||||
if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4getR4") return "fail 4: $p4 ${A.holder}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -18,7 +18,7 @@ object A {
|
||||
fun test2() : Int {
|
||||
r2++
|
||||
++r2
|
||||
return $r2
|
||||
return r2
|
||||
}
|
||||
|
||||
var r3: Int = 1;
|
||||
@@ -30,7 +30,7 @@ object A {
|
||||
fun test3() : Int {
|
||||
r3++
|
||||
++r3
|
||||
return $r3
|
||||
return r3
|
||||
}
|
||||
|
||||
var r4: Int = 1;
|
||||
@@ -47,7 +47,7 @@ object A {
|
||||
r4++
|
||||
holder += ":"
|
||||
++r4
|
||||
return $r4
|
||||
return r4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ fun box() : String {
|
||||
|
||||
val p2 = A.test2()
|
||||
val holderValue = A.holder
|
||||
if (p2 != 3 || holderValue != "getR2getR2getR2") return "fail 2: $p2 ${holderValue}"
|
||||
if (p2 != 3 || holderValue != "getR2getR2getR2getR2") return "fail 2: $p2 ${holderValue}"
|
||||
|
||||
A.holder = ""
|
||||
val p3 = A.test3()
|
||||
@@ -65,7 +65,7 @@ fun box() : String {
|
||||
|
||||
A.holder = ""
|
||||
val p4 = A.test4()
|
||||
if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4") return "fail 4: $p4 ${A.holder}"
|
||||
if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4getR4") return "fail 4: $p4 ${A.holder}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package one_extends_base
|
||||
|
||||
open class Base<T>(name : T?) {
|
||||
var myName : T?
|
||||
init {
|
||||
$myName = name
|
||||
}
|
||||
}
|
||||
open class One<T, K>(name : T?, second : K?) : Base<T?>(name) {
|
||||
var mySecond : K?
|
||||
init {
|
||||
$mySecond = second
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if(One<String, Int>("ola", 0).myName == "ola") "OK" else "fail"
|
||||
@@ -11,9 +11,8 @@ interface NoC {
|
||||
}
|
||||
|
||||
class WithC() {
|
||||
val x : Int
|
||||
val x : Int = 1
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 1
|
||||
<!UNRESOLVED_REFERENCE!>$y<!> = 2
|
||||
val <!UNUSED_VARIABLE!>b<!> = x
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface NoC {
|
||||
public final class WithC {
|
||||
public constructor WithC()
|
||||
public final val a: kotlin.Int
|
||||
public final val x: kotlin.Int
|
||||
public final val x: kotlin.Int = 1
|
||||
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
|
||||
|
||||
@@ -24,7 +24,6 @@ class WithCPI_Dup(<!UNUSED_PARAMETER!>x<!> : Int) {
|
||||
|
||||
class WithCPI(x : Int) {
|
||||
val a = 1
|
||||
val b : Int = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!>
|
||||
val xy : Int = x
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ public final class WithC2 : WithC1 {
|
||||
public final class WithCPI {
|
||||
public constructor WithCPI(/*0*/ x: kotlin.Int)
|
||||
public final val a: kotlin.Int = 1
|
||||
public final val b: kotlin.Int = 1
|
||||
public final val xy: 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
|
||||
|
||||
+1
-4
@@ -5,10 +5,7 @@ open class `$$$$$`() {
|
||||
open class `$`() {
|
||||
}
|
||||
open class `$$`(`$$$$` : `$$$$$`?) : `$`() {
|
||||
val `$$$` : `$$$$$`?
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$`$$$`<!> = `$$$$`
|
||||
}
|
||||
val `$$$` : `$$$$$`? = `$$$$`
|
||||
open public fun `$$$$$$`() : `$$$$$`? {
|
||||
return `$$$`
|
||||
}
|
||||
|
||||
+4
-4
@@ -14,16 +14,16 @@ var x : Int = 1 + <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
|
||||
class Test() {
|
||||
var a : Int = 111
|
||||
var b : Int get() = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!>; set(x) {a = x; <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!> = x}
|
||||
var b : Int get() = <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!>; set(x) {a = x; <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!> = x}
|
||||
|
||||
init {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!> = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!>
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$a<!> = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!> = <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!>
|
||||
<!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!> = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
a = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
}
|
||||
|
||||
fun f() {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!> = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!>
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!> = <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!>
|
||||
a = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
}
|
||||
public val i = 1
|
||||
|
||||
@@ -130,13 +130,4 @@ fun testObject() : Trait {
|
||||
return o
|
||||
}
|
||||
|
||||
fun testBackingFieldsNotMarked() {
|
||||
val <!UNUSED_VARIABLE!>a<!> = object {
|
||||
val x : Int
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun doSmth(<!UNUSED_PARAMETER!>i<!> : Int) {}
|
||||
|
||||
@@ -2,7 +2,6 @@ package
|
||||
|
||||
package unused_variables {
|
||||
public fun doSmth(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun testBackingFieldsNotMarked(): kotlin.Unit
|
||||
public fun testFunctionLiterals(): kotlin.Unit
|
||||
public fun testInnerFunctions(): kotlin.Unit
|
||||
public fun testObject(): unused_variables.Trait
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
class Flower() {
|
||||
|
||||
var minusOne: Int = 1
|
||||
get() = field + 1
|
||||
set(n: Int) { field = n - 1 }
|
||||
|
||||
var oldSyntax: Int = 1
|
||||
get() = <!BACKING_FIELD_SYNTAX_DEPRECATED!>$oldSyntax<!> - 1
|
||||
set(arg) { <!BACKING_FIELD_SYNTAX_DEPRECATED!>$oldSyntax<!> = arg + 1 }
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class ReadForward() {
|
||||
init {
|
||||
val <!UNUSED_VARIABLE!>x<!> = <!BACKING_FIELD_USAGE_DEPRECATED, UNINITIALIZED_VARIABLE!>$a<!>
|
||||
}
|
||||
|
||||
val a = 1
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package
|
||||
|
||||
public final class ReadForward {
|
||||
public constructor ReadForward()
|
||||
public final val a: kotlin.Int = 1
|
||||
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
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
class ReadForward() {
|
||||
val a = <!BACKING_FIELD_USAGE_DEPRECATED, UNINITIALIZED_VARIABLE!>$b<!>
|
||||
val b = 1
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public final class ReadForward {
|
||||
public constructor ReadForward()
|
||||
public final val a: kotlin.Int = 1
|
||||
public final val b: kotlin.Int = 1
|
||||
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
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
class ReadByAnotherPropertyInitializer() {
|
||||
val a = 1
|
||||
init {
|
||||
val <!UNUSED_VARIABLE!>x<!> = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!>
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package
|
||||
|
||||
public final class ReadByAnotherPropertyInitializer {
|
||||
public constructor ReadByAnotherPropertyInitializer()
|
||||
public final val a: kotlin.Int = 1
|
||||
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
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
class ReadByAnotherPropertyInitializer() {
|
||||
val a = 1
|
||||
val b = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!>
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public final class ReadByAnotherPropertyInitializer {
|
||||
public constructor ReadByAnotherPropertyInitializer()
|
||||
public final val a: kotlin.Int = 1
|
||||
public final val b: kotlin.Int = 1
|
||||
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
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
class ReadByAnotherPropertyInitializer() {
|
||||
val a = 1
|
||||
fun ff() = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!>
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public final class ReadByAnotherPropertyInitializer {
|
||||
public constructor ReadByAnotherPropertyInitializer()
|
||||
public final val a: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun ff(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-172
@@ -1,172 +0,0 @@
|
||||
//KT-462 Consider allowing initializing properties via property names when it is safe
|
||||
//KT-598 Allow to use backing fields after this expression
|
||||
|
||||
package kt462
|
||||
|
||||
abstract class TestInitializationWithoutBackingField() {
|
||||
val valWithBackingField : Int
|
||||
init {
|
||||
valWithBackingField = 2
|
||||
}
|
||||
|
||||
val valWithoutBackingField : Int
|
||||
get() = 42
|
||||
init {
|
||||
<!VAL_REASSIGNMENT!>valWithoutBackingField<!> = 45
|
||||
}
|
||||
|
||||
var finalDefaultVar : Int
|
||||
init {
|
||||
finalDefaultVar = 3
|
||||
}
|
||||
|
||||
open var openVar : Int
|
||||
init {
|
||||
<!INITIALIZATION_USING_BACKING_FIELD_OPEN_SETTER!>openVar<!> = 4
|
||||
}
|
||||
|
||||
var varWithCustomSetter : Int
|
||||
set(v: Int) {
|
||||
field = v
|
||||
}
|
||||
init {
|
||||
<!INITIALIZATION_USING_BACKING_FIELD_CUSTOM_SETTER!>varWithCustomSetter<!> = 3
|
||||
}
|
||||
|
||||
var varWithoutBackingField : Int
|
||||
get() = 3
|
||||
set(v: Int) {}
|
||||
init {
|
||||
varWithoutBackingField = 4
|
||||
}
|
||||
|
||||
abstract var abstractVar : Int
|
||||
init {
|
||||
abstractVar = 34
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TestInitializationThroughBackingField() {
|
||||
val valWithBackingField : Int
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$valWithBackingField<!> = 2
|
||||
}
|
||||
|
||||
val valWithoutBackingField : Int
|
||||
get() = 42
|
||||
init {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$valWithoutBackingField<!> = 45
|
||||
}
|
||||
|
||||
var finalDefaultVar : Int
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$finalDefaultVar<!> = 3
|
||||
}
|
||||
|
||||
open var openVar : Int
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$openVar<!> = 4
|
||||
}
|
||||
|
||||
var varWithCustomSetter : Int
|
||||
set(v: Int) {
|
||||
field = v
|
||||
}
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$varWithCustomSetter<!> = 3
|
||||
}
|
||||
|
||||
var varWithoutBackingField : Int
|
||||
get() = 3
|
||||
set(v: Int) {}
|
||||
init {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$varWithoutBackingField<!> = 4
|
||||
}
|
||||
|
||||
abstract var abstractVar : Int
|
||||
init {
|
||||
<!NO_BACKING_FIELD_ABSTRACT_PROPERTY!>$abstractVar<!> = 34
|
||||
}
|
||||
}
|
||||
|
||||
class TestBackingFieldsVisibility() {
|
||||
var a : Int = 712
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$a<!> = 37
|
||||
this.$a = 357
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$a<!> = 334
|
||||
this.$a = 347
|
||||
}
|
||||
|
||||
fun foo(a: TestBackingFieldsVisibility) {
|
||||
val <!UNUSED_VARIABLE!>b<!> : Int = 3
|
||||
<!UNRESOLVED_REFERENCE!>$b<!> = 342
|
||||
<!INACCESSIBLE_BACKING_FIELD!>a.$a<!> = 3
|
||||
}
|
||||
|
||||
val x = <!INACCESSIBLE_BACKING_FIELD!>$topLevelVar<!>
|
||||
|
||||
inner class Inner() {
|
||||
val z = this@TestBackingFieldsVisibility.<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!>
|
||||
}
|
||||
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val w = 11
|
||||
get() = field //test there is no second error here
|
||||
}
|
||||
|
||||
val topLevelVar = 11
|
||||
|
||||
class T() {
|
||||
val z : Int get() = 42
|
||||
|
||||
init {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>this.$z<!> = 34
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>this.$z<!> = 343
|
||||
}
|
||||
|
||||
val a = object {
|
||||
val x = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$z<!>
|
||||
init {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$z<!> = 23
|
||||
}
|
||||
}
|
||||
|
||||
var x: Int = 2
|
||||
get() {
|
||||
val <!UNUSED_VARIABLE!>o<!> = object {
|
||||
init {
|
||||
field = 34
|
||||
}
|
||||
fun foo() {
|
||||
field = 23
|
||||
}
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
var r: Int = <!BACKING_FIELD_USAGE_DEPRECATED!>$x<!>
|
||||
set(v: Int) {
|
||||
if (true) {
|
||||
field = 33
|
||||
}
|
||||
else {
|
||||
field = 35
|
||||
}
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 34
|
||||
val <!UNUSED_VARIABLE!>o<!> = object {
|
||||
val y = <!BACKING_FIELD_USAGE_DEPRECATED!>$x<!>
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 422
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package
|
||||
|
||||
package kt462 {
|
||||
public val topLevelVar: kotlin.Int = 11
|
||||
|
||||
public final class T {
|
||||
public constructor T()
|
||||
public final val a: kotlin.Any
|
||||
public final var r: kotlin.Int
|
||||
public final var x: kotlin.Int
|
||||
public final val z: kotlin.Int
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class TestBackingFieldsVisibility {
|
||||
public constructor TestBackingFieldsVisibility()
|
||||
public final var a: kotlin.Int
|
||||
public abstract val w: kotlin.Int = 11
|
||||
public final val x: kotlin.Int = 11
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public final fun foo(/*0*/ a: kt462.TestBackingFieldsVisibility): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final inner class Inner {
|
||||
public constructor Inner()
|
||||
public final val z: kotlin.Int = 11
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class TestInitializationThroughBackingField {
|
||||
public constructor TestInitializationThroughBackingField()
|
||||
public abstract var abstractVar: kotlin.Int
|
||||
public final var finalDefaultVar: kotlin.Int
|
||||
public open var openVar: kotlin.Int
|
||||
public final val valWithBackingField: kotlin.Int
|
||||
public final val valWithoutBackingField: kotlin.Int
|
||||
public final var varWithCustomSetter: kotlin.Int
|
||||
public final var varWithoutBackingField: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class TestInitializationWithoutBackingField {
|
||||
public constructor TestInitializationWithoutBackingField()
|
||||
public abstract var abstractVar: kotlin.Int
|
||||
public final var finalDefaultVar: kotlin.Int
|
||||
public open var openVar: kotlin.Int
|
||||
public final val valWithBackingField: kotlin.Int
|
||||
public final val valWithoutBackingField: kotlin.Int
|
||||
public final var varWithCustomSetter: kotlin.Int
|
||||
public final var varWithoutBackingField: 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
|
||||
}
|
||||
}
|
||||
Vendored
+20
-20
@@ -113,16 +113,16 @@ val z = 10
|
||||
|
||||
class AnonymousInitializers(var a: String, val b: String) {
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$a<!> = "30"
|
||||
a = "30"
|
||||
a = "s"
|
||||
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED, VAL_REASSIGNMENT!>$b<!> = "3"
|
||||
<!VAL_REASSIGNMENT!>b<!> = "3"
|
||||
b = "tt" //repeat for b
|
||||
}
|
||||
|
||||
val i: Int
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$i<!> = 121
|
||||
i = 121
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -134,7 +134,7 @@ class AnonymousInitializers(var a: String, val b: String) {
|
||||
get() = 20
|
||||
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED, VAL_REASSIGNMENT!>$i<!> = 13
|
||||
<!VAL_REASSIGNMENT!>i<!> = 13
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$j<!> = 30
|
||||
<!VAL_REASSIGNMENT!>j<!> = 34
|
||||
}
|
||||
@@ -145,31 +145,31 @@ class AnonymousInitializers(var a: String, val b: String) {
|
||||
k = "a"
|
||||
}
|
||||
else {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$k<!> = "b"
|
||||
k = "b"
|
||||
}
|
||||
}
|
||||
|
||||
val l: String
|
||||
init {
|
||||
if (1 < 3) {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$l<!> = "a"
|
||||
l = "a"
|
||||
}
|
||||
else {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$l<!> = "b"
|
||||
l = "b"
|
||||
}
|
||||
}
|
||||
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val o: String<!>
|
||||
init {
|
||||
if (1 < 3) {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$o<!> = "a"
|
||||
o = "a"
|
||||
}
|
||||
}
|
||||
|
||||
var m: Int = 30
|
||||
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$m<!> = 400
|
||||
m = 400
|
||||
}
|
||||
|
||||
val n: Int
|
||||
@@ -177,7 +177,7 @@ class AnonymousInitializers(var a: String, val b: String) {
|
||||
init {
|
||||
while (<!UNINITIALIZED_VARIABLE!>n<!> == 0) {
|
||||
}
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$n<!> = 10
|
||||
n = 10
|
||||
while (n == 0) {
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ class LocalValsVsProperties(val a: Int, w: Int) : Open(a, w) {
|
||||
val x : Int
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val y : Int<!>
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 1
|
||||
x = 1
|
||||
val <!UNUSED_VARIABLE!>b<!> = x
|
||||
}
|
||||
val b = a
|
||||
@@ -214,7 +214,7 @@ class LocalValsVsProperties(val a: Int, w: Int) : Open(a, w) {
|
||||
var yy : Int
|
||||
init {
|
||||
<!VAL_REASSIGNMENT!>w<!> += 1
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$yy<!> = w
|
||||
yy = w
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,8 +223,8 @@ class Outer() {
|
||||
var b : Int
|
||||
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$a<!> = 1
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$b<!> = 1
|
||||
a = 1
|
||||
b = 1
|
||||
}
|
||||
|
||||
inner class Inner() {
|
||||
@@ -242,7 +242,7 @@ class Outer() {
|
||||
|
||||
class ForwardAccessToBackingField() { //kt-147
|
||||
val a = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, UNINITIALIZED_VARIABLE!>$a<!> // error
|
||||
val b = <!BACKING_FIELD_USAGE_DEPRECATED, UNINITIALIZED_VARIABLE!>$c<!> // error
|
||||
val b = <!UNINITIALIZED_VARIABLE!>c<!> // error
|
||||
val c = 1
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ class ClassObject() {
|
||||
val x : Int
|
||||
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 1
|
||||
x = 1
|
||||
}
|
||||
|
||||
|
||||
@@ -268,8 +268,8 @@ fun foo() {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val y : Int<!>
|
||||
val z : Int
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 1
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$z<!> = 3
|
||||
x = 1
|
||||
z = 3
|
||||
}
|
||||
fun foo() {
|
||||
<!VAL_REASSIGNMENT!>y<!> = 10
|
||||
@@ -288,7 +288,7 @@ class TestObjectExpression() {
|
||||
if (true)
|
||||
x = 12
|
||||
else
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 1
|
||||
x = 1
|
||||
}
|
||||
fun inner1() {
|
||||
<!VAL_REASSIGNMENT!>y<!> = 101
|
||||
@@ -308,7 +308,7 @@ object TestObjectDeclaration {
|
||||
val x : Int
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val y : Int<!>
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$x<!> = 1
|
||||
x = 1
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package h
|
||||
class Square() {
|
||||
var size : Double =
|
||||
<!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$area<!> = size * size
|
||||
<!BACKING_FIELD_USAGE_FORBIDDEN!>$area<!> = size * size
|
||||
}
|
||||
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var area : Double<!>
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
class WithC() {
|
||||
val a = 1
|
||||
val b = <!BACKING_FIELD_USAGE_DEPRECATED!>$a<!> // error here, but must not be
|
||||
val b = a
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class Creature() {
|
||||
var bbb : Int
|
||||
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$bbb<!> = 1
|
||||
bbb = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Creature() {
|
||||
var ccc : Int
|
||||
|
||||
init {
|
||||
<!BACKING_FIELD_USAGE_DEPRECATED!>$ccc<!> = 2
|
||||
ccc = 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// http://youtrack.jetbrains.net/issue/KT-421
|
||||
// KT-421 Strange 'unresolved' bug with backing fields
|
||||
|
||||
class A() {
|
||||
val c = 1
|
||||
val a = <!UNINITIALIZED_VARIABLE!>b<!>
|
||||
val b = <!BACKING_FIELD_USAGE_DEPRECATED!>$c<!> // '$c' is unresolved
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final val a: kotlin.Int = 1
|
||||
public final val b: kotlin.Int = 1
|
||||
public final val c: kotlin.Int = 1
|
||||
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
|
||||
}
|
||||
+1
-1
@@ -18,7 +18,7 @@ class Test {
|
||||
var prop4 : Int = 13
|
||||
|
||||
fun incProp4() {
|
||||
$prop4++
|
||||
prop4++
|
||||
}
|
||||
|
||||
public var prop5 : Int = 14
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ interface Test {
|
||||
var prop4 : Int = 13
|
||||
|
||||
fun incProp4() {
|
||||
$prop4++
|
||||
prop4++
|
||||
}
|
||||
|
||||
public var prop5 : Int = 14
|
||||
|
||||
@@ -1362,12 +1362,6 @@ 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");
|
||||
@@ -1458,12 +1452,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt462BackingFieldsResolve.kt")
|
||||
public void testKt462BackingFieldsResolve() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/kt462BackingFieldsResolve.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt782packageLevel.kt")
|
||||
public void testKt782packageLevel() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/kt782packageLevel.kt");
|
||||
@@ -1476,36 +1464,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadForwardInAnonymous.kt")
|
||||
public void testReadForwardInAnonymous() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadForwardInAnonymous.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadForwardInPropertyInitializer.kt")
|
||||
public void testReadForwardInPropertyInitializer() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadForwardInPropertyInitializer.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadInAnonymous.kt")
|
||||
public void testReadInAnonymous() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadInAnonymous.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadInAnotherPropertyIntializer.kt")
|
||||
public void testReadInAnotherPropertyIntializer() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadInAnotherPropertyIntializer.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadInFunction.kt")
|
||||
public void testReadInFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadInFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadNonexistentAbstractPropertyInAnonymous.kt")
|
||||
public void testReadNonexistentAbstractPropertyInAnonymous() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadNonexistentAbstractPropertyInAnonymous.kt");
|
||||
@@ -12852,12 +12810,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt421Scopes.kt")
|
||||
public void testKt421Scopes() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/scopes/kt421Scopes.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt587.kt")
|
||||
public void testKt587() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/scopes/kt587.kt");
|
||||
|
||||
-18
@@ -5650,24 +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");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt640.kt")
|
||||
public void testKt640() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt640.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt694.kt")
|
||||
public void testKt694() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt694.kt");
|
||||
@@ -7768,12 +7756,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt511.kt")
|
||||
public void testKt511() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/typeInfo/kt511.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveTypeInfo.kt")
|
||||
public void testPrimitiveTypeInfo() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/typeInfo/primitiveTypeInfo.kt");
|
||||
|
||||
@@ -85,7 +85,7 @@ public open class ObjectValue(value: Any?, asmType: Type): AbstractValue<Any?>(v
|
||||
class NewObjectValue(asmType: Type): ObjectValue(null, asmType) {
|
||||
override var value: Any? = null
|
||||
get(): Any? {
|
||||
return $value ?: throw IllegalStateException("Trying to access an unitialized object: $this")
|
||||
return field ?: throw IllegalStateException("Trying to access an unitialized object: $this")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class KotlinHistoryHighlighter(private val runner: KotlinConsoleRunner )
|
||||
else
|
||||
runner.changeConsoleEditorIndicator(ReplIcons.EDITOR_INDICATOR)
|
||||
|
||||
$isReadLineMode = value
|
||||
field = value
|
||||
}
|
||||
|
||||
fun printNewCommandInHistory(trimmedCommandText: String) {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe
|
||||
ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION,
|
||||
Errors.DEPRECATED_SYMBOL_WITH_MESSAGE,
|
||||
Errors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION,
|
||||
Errors.BACKING_FIELD_SYNTAX_DEPRECATED,
|
||||
Errors.BACKING_FIELD_OLD_SYNTAX,
|
||||
Errors.OPERATOR_MODIFIER_REQUIRED,
|
||||
Errors.INFIX_MODIFIER_REQUIRED,
|
||||
Errors.CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS,
|
||||
|
||||
@@ -324,9 +324,9 @@ public class QuickFixRegistrar : QuickFixContributor {
|
||||
|
||||
NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION.registerFactory(ConstFixFactory)
|
||||
|
||||
BACKING_FIELD_SYNTAX_DEPRECATED.registerFactory(MigrateBackingFieldSyntaxFix)
|
||||
BACKING_FIELD_USAGE_DEPRECATED.registerFactory(MigrateBackingFieldUsageFix)
|
||||
BACKING_FIELD_USAGE_DEPRECATED.registerFactory(IntroduceBackingPropertyFix)
|
||||
BACKING_FIELD_OLD_SYNTAX.registerFactory(MigrateBackingFieldSyntaxFix)
|
||||
BACKING_FIELD_USAGE_FORBIDDEN.registerFactory(MigrateBackingFieldUsageFix)
|
||||
BACKING_FIELD_USAGE_FORBIDDEN.registerFactory(IntroduceBackingPropertyFix)
|
||||
|
||||
OPERATOR_MODIFIER_REQUIRED.registerFactory(ModifierFixFactory(JetTokens.OPERATOR_KEYWORD))
|
||||
INFIX_MODIFIER_REQUIRED.registerFactory(ModifierFixFactory(JetTokens.INFIX_KEYWORD))
|
||||
|
||||
@@ -66,7 +66,7 @@ public open class JetChangeInfo(
|
||||
if (value != null && value !in newParameters) {
|
||||
newParameters.add(value)
|
||||
}
|
||||
$receiverParameterInfo = value
|
||||
field = value
|
||||
}
|
||||
|
||||
private val newParameters = parameterInfos.toArrayList()
|
||||
@@ -155,7 +155,7 @@ public open class JetChangeInfo(
|
||||
|
||||
public var primaryPropagationTargets: Collection<PsiElement> = emptyList()
|
||||
set(value: Collection<PsiElement>) {
|
||||
$primaryPropagationTargets = value
|
||||
field = value
|
||||
|
||||
val result = LinkedHashSet<UsageInfo>()
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class JetChangeSignatureData(
|
||||
override val receiver: JetParameterInfo?
|
||||
|
||||
init {
|
||||
$receiver = createReceiverInfoIfNeeded()
|
||||
receiver = createReceiverInfoIfNeeded()
|
||||
|
||||
val valueParameters = when {
|
||||
baseDeclaration is JetFunction -> baseDeclaration.getValueParameters()
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class JetMutableMethodDescriptor(override val original: JetMethodDescript
|
||||
if (value != null && value !in parameters) {
|
||||
parameters.add(value)
|
||||
}
|
||||
$receiver = value
|
||||
field = value
|
||||
}
|
||||
|
||||
public fun addParameter(parameter: JetParameterInfo) {
|
||||
|
||||
+2
-2
@@ -101,7 +101,7 @@ public class KotlinInplaceParameterIntroducer(
|
||||
var addedRange: TextRange? = null
|
||||
private set
|
||||
|
||||
var text: String
|
||||
var text: String = ""
|
||||
private set
|
||||
|
||||
val rangesToRemove: List<TextRange> get() = _rangesToRemove
|
||||
@@ -163,7 +163,7 @@ public class KotlinInplaceParameterIntroducer(
|
||||
}
|
||||
}
|
||||
|
||||
$text = builder.toString()
|
||||
text = builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class KotlinInplacePropertyIntroducer(
|
||||
set(value: ExtractionTarget) {
|
||||
if (value == currentTarget) return
|
||||
|
||||
$currentTarget = value
|
||||
field = value
|
||||
runWriteActionAndRestartRefactoring {
|
||||
with (extractionResult.config) {
|
||||
extractionResult = copy(generatorOptions = generatorOptions.copy(target = currentTarget)).generateDeclaration(property)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ interface NoC {
|
||||
class WithC() {
|
||||
val x : Int
|
||||
init {
|
||||
<warning descr="[BACKING_FIELD_USAGE_DEPRECATED] Backing field usage is deprecated here, soon it will be possible only in property accessors">$x</warning> = 1
|
||||
<error>$x</error> = 1
|
||||
<error>$y</error> = 2
|
||||
val <warning>b</warning> = x
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ class WithCPI_Dup(<warning>x</warning> : Int) {
|
||||
|
||||
class WithCPI(x : Int) {
|
||||
val a = 1
|
||||
val b : Int = <warning descr="[BACKING_FIELD_USAGE_DEPRECATED] Backing field usage is deprecated here, soon it will be possible only in property accessors">$a</warning>
|
||||
val b : Int = <error>$a</error>
|
||||
val xy : Int = x
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
|
||||
class WithC() {
|
||||
val a = 1
|
||||
val b = <warning descr="[BACKING_FIELD_USAGE_DEPRECATED] Backing field usage is deprecated here, soon it will be possible only in property accessors">$a</warning> // error here, but must not be
|
||||
val b = <error>$a</error> // error here, but must not be
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class A {
|
||||
return 1
|
||||
}
|
||||
set(i: Int) {
|
||||
$prop = i
|
||||
field = i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ val <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="K
|
||||
|
||||
val <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_PROPERTY_WITH_BACKING_FIELD">y</info></info> : <info textAttributesKey="KOTLIN_CLASS">Int</info> = 1
|
||||
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() {
|
||||
return 5.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">sq</info></info> + <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_BACKING_FIELD_ACCESS">$y</info></info> + <info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">x</info></info>
|
||||
return 5.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">sq</info></info> + <info textAttributesKey="KOTLIN_LOCAL_VARIABLE"><info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE">field</info></info> + <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">x</info></info>
|
||||
}
|
||||
|
||||
class <info textAttributesKey="KOTLIN_CLASS">Foo</info>(val <info textAttributesKey="KOTLIN_PARAMETER"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY"><info textAttributesKey="KOTLIN_PROPERTY_WITH_BACKING_FIELD">a</info></info></info> : <info textAttributesKey="KOTLIN_CLASS">Int</info>, <info textAttributesKey="KOTLIN_PARAMETER">b</info> : <info textAttributesKey="KOTLIN_CLASS">String</info>) {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
class Foo {
|
||||
var <caret>x = ""
|
||||
get() = $x + "!"
|
||||
set(value) { $x = value + "!" }
|
||||
|
||||
fun foo(): String {
|
||||
return $x
|
||||
}
|
||||
get() = field + "!"
|
||||
set(value) { field = value + "!" }
|
||||
}
|
||||
|
||||
@@ -3,8 +3,4 @@ class Foo {
|
||||
var x: String
|
||||
get() = _x + "!"
|
||||
set(value) { _x = value + "!" }
|
||||
|
||||
fun foo(): String {
|
||||
return _x
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class A {
|
||||
var a: Int
|
||||
var b: Int
|
||||
|
||||
init {
|
||||
<caret>$a = 1
|
||||
b = 2
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
class A {
|
||||
var a: Int =<caret> 1
|
||||
var b: Int
|
||||
|
||||
init {
|
||||
b = 2
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// "Make 'i' not abstract" "true"
|
||||
class B {
|
||||
<caret>abstract val i: Int = 0
|
||||
get() = $i
|
||||
get() = field
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// "Make 'i' not abstract" "true"
|
||||
class B {
|
||||
val i: Int = 0
|
||||
get() = $i
|
||||
get() = field
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class Exp(p1: String) {
|
||||
val /*rename*/prop11: String = p1
|
||||
get(): String {
|
||||
return $prop11
|
||||
return field
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class Exp(p1: String) {
|
||||
val /*rename*/prop1: String = p1
|
||||
get(): String {
|
||||
return $prop1
|
||||
return field
|
||||
}
|
||||
}
|
||||
@@ -5493,12 +5493,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/moveAssignmentToInitializer"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("backingField.kt")
|
||||
public void testBackingField() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/backingField.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("comment.kt")
|
||||
public void testComment() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/comment.kt");
|
||||
|
||||
@@ -72,10 +72,10 @@ abstract class Element {
|
||||
set(value) {
|
||||
// do not assign prototypes to singleton instances
|
||||
if (canBeSingleton) {
|
||||
$prototypes = listOf()
|
||||
field = listOf()
|
||||
return
|
||||
}
|
||||
$prototypes = value
|
||||
field = value
|
||||
}
|
||||
|
||||
protected open val canBeSingleton: Boolean
|
||||
|
||||
@@ -10,8 +10,8 @@ import bar.*
|
||||
get() = /*c:foo.A*/b
|
||||
|
||||
var d: /*c:foo.A c:foo.A.Companion p:foo*/String = "ddd"
|
||||
get() = /*c:foo.A*/$d
|
||||
set(v) { /*c:foo.A*/$d = v }
|
||||
get() = field
|
||||
set(v) { field = v }
|
||||
|
||||
fun foo() {
|
||||
/*c:foo.A*/a
|
||||
|
||||
@@ -60,10 +60,6 @@ public class DefaultArgumentsTest extends SingleFileTranslationTest {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testOverrideValWithDefaultValue() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testVirtualCallWithDefArg() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package foo
|
||||
|
||||
open class A(open val bar: Int = 2) {
|
||||
val barA = $bar
|
||||
}
|
||||
|
||||
class B(override val bar: Int = 3) : A()
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
if (b.bar != 3) return "b.bar != 3, it: " + b.bar
|
||||
if (b.barA != 2) return "b.barA != 2, it: " + b.barA
|
||||
return "OK"
|
||||
}
|
||||
@@ -2,7 +2,7 @@ class C() {
|
||||
public var f: Int
|
||||
|
||||
init {
|
||||
$f = 610
|
||||
f = 610
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class A(var a: Int) {
|
||||
init {
|
||||
$a = 3
|
||||
a = 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class A() {
|
||||
fun lold() = true
|
||||
val p: () -> Boolean
|
||||
init {
|
||||
$p = { { lold() }() }
|
||||
p = { { lold() }() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ class A {
|
||||
get() = field + 1
|
||||
|
||||
fun getA(): Int {
|
||||
return $a
|
||||
return a
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.a != 2) return "A().a != 2, it: ${a.a}"
|
||||
if (a.getA() != 1) return "A().getA() != 1, it: ${a.getA()}"
|
||||
if (a.getA() != 2) return "A().getA() != 2, it: ${a.getA()}"
|
||||
return "OK"
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class A {
|
||||
var aaR = 0
|
||||
init {
|
||||
a = 1
|
||||
$aa = 2
|
||||
aa = 2
|
||||
|
||||
aR = a
|
||||
aaR = aa
|
||||
@@ -29,7 +29,7 @@ class B {
|
||||
var aaR = 0
|
||||
init {
|
||||
a = 3
|
||||
$aa = 4
|
||||
aa = 4
|
||||
|
||||
aR = a
|
||||
aaR = aa
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
class Test() {
|
||||
var a: Int
|
||||
init {
|
||||
$a = 3
|
||||
a = 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user