Check whether the field is indeed being initialized
in checkFieldInExactlyOnceLambdaInitialization #KT-40691 Fixed
This commit is contained in:
+71
@@ -58,3 +58,74 @@ class Test {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts
|
||||
class Test1 {
|
||||
val a: String = ""
|
||||
val b: String = ""
|
||||
val c: String = ""
|
||||
val d: String = ""
|
||||
|
||||
init {
|
||||
inlineMe {
|
||||
a += "allowed"
|
||||
}
|
||||
crossinlineMe {
|
||||
b += "not allowed"
|
||||
}
|
||||
noinlineMe {
|
||||
c += "not allowed"
|
||||
}
|
||||
notinline {
|
||||
d += "not allowed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts
|
||||
class Test2 {
|
||||
val a: String = ""
|
||||
val b: String = ""
|
||||
val c: String = ""
|
||||
val d: String = ""
|
||||
|
||||
init {
|
||||
var blackhole = ""
|
||||
inlineMe {
|
||||
blackhole += a
|
||||
}
|
||||
crossinlineMe {
|
||||
blackhole += b
|
||||
}
|
||||
noinlineMe {
|
||||
blackhole += c
|
||||
}
|
||||
notinline {
|
||||
blackhole += d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts
|
||||
class Test4 {
|
||||
val a: String = ""
|
||||
val b: String = ""
|
||||
val c: String = ""
|
||||
val d: String = ""
|
||||
|
||||
init {
|
||||
var blackhole: String
|
||||
inlineMe {
|
||||
blackhole = a
|
||||
}
|
||||
crossinlineMe {
|
||||
blackhole = b
|
||||
}
|
||||
noinlineMe {
|
||||
blackhole = c
|
||||
}
|
||||
notinline {
|
||||
blackhole = d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+71
@@ -58,3 +58,74 @@ class Test {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts
|
||||
class Test1 {
|
||||
val a: String = ""
|
||||
val b: String = ""
|
||||
val c: String = ""
|
||||
val d: String = ""
|
||||
|
||||
init {
|
||||
inlineMe {
|
||||
<!VAL_REASSIGNMENT!>a<!> += "allowed"
|
||||
}
|
||||
crossinlineMe {
|
||||
<!CAPTURED_VAL_INITIALIZATION, VAL_REASSIGNMENT!>b<!> += "not allowed"
|
||||
}
|
||||
noinlineMe {
|
||||
<!CAPTURED_VAL_INITIALIZATION, VAL_REASSIGNMENT!>c<!> += "not allowed"
|
||||
}
|
||||
notinline {
|
||||
<!CAPTURED_VAL_INITIALIZATION, VAL_REASSIGNMENT!>d<!> += "not allowed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts
|
||||
class Test2 {
|
||||
val a: String = ""
|
||||
val b: String = ""
|
||||
val c: String = ""
|
||||
val d: String = ""
|
||||
|
||||
init {
|
||||
var blackhole = ""
|
||||
inlineMe {
|
||||
blackhole += a
|
||||
}
|
||||
crossinlineMe {
|
||||
blackhole += b
|
||||
}
|
||||
noinlineMe {
|
||||
blackhole += c
|
||||
}
|
||||
notinline {
|
||||
blackhole += d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts
|
||||
class Test4 {
|
||||
val a: String = ""
|
||||
val b: String = ""
|
||||
val c: String = ""
|
||||
val d: String = ""
|
||||
|
||||
init {
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>blackhole<!>: String
|
||||
inlineMe {
|
||||
blackhole = a
|
||||
}
|
||||
crossinlineMe {
|
||||
blackhole = b
|
||||
}
|
||||
noinlineMe {
|
||||
blackhole = c
|
||||
}
|
||||
notinline {
|
||||
blackhole = d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -22,3 +22,36 @@ package
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts public final class Test1 {
|
||||
public constructor Test1()
|
||||
public final val a: kotlin.String = ""
|
||||
public final val b: kotlin.String = ""
|
||||
public final val c: kotlin.String = ""
|
||||
public final val d: kotlin.String = ""
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts public final class Test2 {
|
||||
public constructor Test2()
|
||||
public final val a: kotlin.String = ""
|
||||
public final val b: kotlin.String = ""
|
||||
public final val c: kotlin.String = ""
|
||||
public final val d: kotlin.String = ""
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.contracts.ExperimentalContracts public final class Test4 {
|
||||
public constructor Test4()
|
||||
public final val a: kotlin.String = ""
|
||||
public final val b: kotlin.String = ""
|
||||
public final val c: kotlin.String = ""
|
||||
public final val d: kotlin.String = ""
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user