CFA: detect captured writes more precisely
So #KT-14381 Fixed So #KT-13597 Fixed Also refactors captured writes detection inside DFA
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8fa739ed0f
commit
56e633e345
+21
-2
@@ -7,7 +7,7 @@ class Test {
|
||||
val t = object {
|
||||
fun some() {
|
||||
// See KT-13597
|
||||
a = "12"
|
||||
<!CAPTURED_VAL_INITIALIZATION!>a<!> = "12"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,27 @@ class Test4 {
|
||||
init {
|
||||
exec {
|
||||
// See KT-14381
|
||||
a = "12"
|
||||
<!CAPTURED_VAL_INITIALIZATION!>a<!> = "12"
|
||||
}
|
||||
a = "34"
|
||||
}
|
||||
}
|
||||
|
||||
// Additional tests to prevent something broken
|
||||
|
||||
class Test5 {
|
||||
|
||||
val y: Int
|
||||
|
||||
val z: String
|
||||
|
||||
init {
|
||||
val x: String
|
||||
x = ""
|
||||
z = x
|
||||
}
|
||||
|
||||
constructor(y: Int) {
|
||||
this.y = y
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+9
@@ -25,3 +25,12 @@ public final class Test4 {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Test5 {
|
||||
public constructor Test5(/*0*/ y: kotlin.Int)
|
||||
public final val y: kotlin.Int
|
||||
public final val z: 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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
class Your {
|
||||
init {
|
||||
var y: String? = "xyz"
|
||||
if (y != null) {
|
||||
// Bug that should be fixed
|
||||
// Problem: descriptorToDeclaration cannot get here init block by its descriptor
|
||||
// See PreliminaryDeclarationVisitor.getVisitorByVariable
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
constructor()
|
||||
}
|
||||
|
||||
class Normal {
|
||||
init {
|
||||
var y: String? = "xyz"
|
||||
if (y != null) {
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
|
||||
public final class Normal {
|
||||
public constructor Normal()
|
||||
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 final class Your {
|
||||
public constructor Your()
|
||||
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