Skip to content

Commit 4e3129e

Browse files
yanexSpace Team
authored andcommitted
[Analysis API] Add 'ContextCollector' tests for assignment smart casts
^KT-70860
1 parent 4412edb commit 4e3129e

13 files changed

+317
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
Smart Casts:
21+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
22+
Types:
23+
kotlin.Nothing?
24+
25+
FILE: [ResolvedTo(IMPORTS)] onNullAssignment.kt
26+
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] [PartialBodyAnalysisStateKey=4(4/5) #1] fun main(): R|kotlin/Unit| {
27+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
28+
R|<local>/str| = String(not null)
29+
R|kotlin/io/println|(R|<local>/str|)
30+
R|<local>/str| = Null(null)
31+
println#(str#)
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
Smart Casts:
21+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
22+
Types:
23+
kotlin.Nothing?
24+
25+
FILE: [ResolvedTo(IMPORTS)] onNullAssignment.kt
26+
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] [PartialBodyAnalysisStateKey=4(4/5) #1] fun main(): R|kotlin/Unit| {
27+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
28+
R|<local>/str| = String(not null)
29+
R|kotlin/io/println|(R|<local>/str|)
30+
R|<local>/str| = Null(null)
31+
println#(str#)
32+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// WITH_STDLIB
2+
3+
fun main() {
4+
var str: String? = null
5+
str = "not null"
6+
println(str)
7+
<expr>str</expr> = null
8+
println(str)
9+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
Smart Casts:
21+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
22+
Types:
23+
kotlin.String
24+
25+
FILE: [ResolvedTo(IMPORTS)] onNullAssignment.kt
26+
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] [PartialBodyAnalysisStateKey=4(4/5) #1] fun main(): R|kotlin/Unit| {
27+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
28+
R|<local>/str| = String(not null)
29+
R|kotlin/io/println|(R|<local>/str|)
30+
R|<local>/str| = Null(null)
31+
println#(str#)
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
Smart Casts:
21+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
22+
Types:
23+
kotlin.Nothing?
24+
25+
FILE: [ResolvedTo(IMPORTS)] onNullAssignment2.kt
26+
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] [PartialBodyAnalysisStateKey=4(4/5) #1] fun main(): R|kotlin/Unit| {
27+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
28+
R|<local>/str| = String(not null)
29+
R|kotlin/io/println|(R|<local>/str|)
30+
R|<local>/str| = Null(null)
31+
println#(str#)
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
Smart Casts:
21+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
22+
Types:
23+
kotlin.Nothing?
24+
25+
FILE: [ResolvedTo(IMPORTS)] onNullAssignment2.kt
26+
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] [PartialBodyAnalysisStateKey=4(4/5) #1] fun main(): R|kotlin/Unit| {
27+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
28+
R|<local>/str| = String(not null)
29+
R|kotlin/io/println|(R|<local>/str|)
30+
R|<local>/str| = Null(null)
31+
println#(str#)
32+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// WITH_STDLIB
2+
3+
fun main() {
4+
var str: String? = null
5+
str = "not null"
6+
println(str)
7+
<expr>str = null</expr>
8+
println(str)
9+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
Smart Casts:
21+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
22+
Types:
23+
kotlin.String
24+
25+
FILE: [ResolvedTo(IMPORTS)] onNullAssignment2.kt
26+
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] [PartialBodyAnalysisStateKey=4(4/5) #1] fun main(): R|kotlin/Unit| {
27+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
28+
R|<local>/str| = String(not null)
29+
R|kotlin/io/println|(R|<local>/str|)
30+
R|<local>/str| = Null(null)
31+
println#(str#)
32+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
21+
FILE: [ResolvedTo(IMPORTS)] onNullAssignmentClosingBrace.kt
22+
public final [ResolvedTo(BODY_RESOLVE)] fun main(): R|kotlin/Unit| {
23+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
24+
R|<local>/str| = String(not null)
25+
R|kotlin/io/println|(R|<local>/str|)
26+
R|<local>/str| = Null(null)
27+
R|kotlin/io/println|(R|<local>/str|)
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Tower Data Context:
2+
Element 0
3+
Scope: FirDefaultStarImportingScope
4+
Element 1
5+
Scope: FirExplicitStarImportingScope
6+
Element 2
7+
Scope: FirDefaultSimpleImportingScope
8+
Element 3
9+
Scope: FirDefaultSimpleImportingScope
10+
Element 4
11+
Scope: FirPackageMemberScope
12+
Element 5
13+
Scope: FirExplicitSimpleImportingScope
14+
Element 6
15+
Scope: FirLocalScope
16+
Element 7
17+
Scope: FirLocalScope
18+
Properties:
19+
FirLocalPropertySymbol lvar str: R|kotlin/String?|
20+
21+
FILE: [ResolvedTo(IMPORTS)] onNullAssignmentClosingBrace.kt
22+
public final [ResolvedTo(BODY_RESOLVE)] fun main(): R|kotlin/Unit| {
23+
[ResolvedTo(BODY_RESOLVE)] lvar str: R|kotlin/String?| = Null(null)
24+
R|<local>/str| = String(not null)
25+
R|kotlin/io/println|(R|<local>/str|)
26+
R|<local>/str| = Null(null)
27+
R|kotlin/io/println|(R|<local>/str|)
28+
}

0 commit comments

Comments
 (0)