Skip to content

Commit 2f71bd2

Browse files
yanexSpace Team
authored andcommitted
[fir2ir] Add tests for code fragments returning Nothing
JVM backend transforms 'Nothing' return types to 'void' which the debugger doesn't expect. ^KT-70860
1 parent 17d4610 commit 2f71bd2

File tree

11 files changed

+238
-0
lines changed

11 files changed

+238
-0
lines changed

analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/compilerFacility/FirIdeNormalAnalysisLibrarySourceModuleCompilerFacilityTestGenerated.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/compilerFacility/FirIdeNormalAnalysisSourceModuleCompilerFacilityTestGenerated.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
MODULE_FRAGMENT
2+
FILE fqName:<root> fileName:fragment.kt
3+
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
4+
thisReceiver: VALUE_PARAMETER INSTANCE_RECEIVER kind:DispatchReceiver name:<this> type:<root>.CodeFragment
5+
CONSTRUCTOR visibility:public returnType:<root>.CodeFragment [primary]
6+
BLOCK_BODY
7+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
8+
FUN name:run visibility:public modality:FINAL returnType:kotlin.Nothing
9+
EXPRESSION_BODY
10+
BLOCK type=kotlin.Unit origin=null
11+
CALL 'public final fun call (): kotlin.Nothing declared in <root>.ContextKt' type=kotlin.Nothing origin=null
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// DUMP_CODE
2+
3+
// MODULE: context
4+
5+
//FILE: context.kt
6+
fun main() {
7+
<caret_context>call()
8+
}
9+
10+
fun call(): Nothing {
11+
doNotCall()
12+
}
13+
14+
fun doNotCall(): Nothing {
15+
error("Boo")
16+
}
17+
18+
// MODULE: main
19+
// MODULE_KIND: CodeFragment
20+
// CONTEXT_MODULE: context
21+
22+
// FILE: fragment.kt
23+
// CODE_FRAGMENT_KIND: EXPRESSION
24+
call()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// class version 52.0 (52)
2+
// access flags 0x31
3+
public final class CodeFragment {
4+
5+
// compiled from: fragment.kt
6+
7+
@Lkotlin/Metadata;(mv={2, 3, 0}, k=3, xi=48)
8+
9+
// access flags 0x1
10+
public <init>()V
11+
L0
12+
ALOAD 0
13+
INVOKESPECIAL java/lang/Object.<init> ()V
14+
RETURN
15+
L1
16+
LOCALVARIABLE this LCodeFragment; L0 L1 0
17+
MAXSTACK = 1
18+
MAXLOCALS = 1
19+
20+
// access flags 0x19
21+
public final static run()Ljava/lang/Void;
22+
@Lorg/jetbrains/annotations/NotNull;() // invisible
23+
L0
24+
LINENUMBER 24 L0
25+
INVOKESTATIC ContextKt.call ()Ljava/lang/Void;
26+
POP
27+
NEW kotlin/KotlinNothingValueException
28+
DUP
29+
INVOKESPECIAL kotlin/KotlinNothingValueException.<init> ()V
30+
ATHROW
31+
MAXSTACK = 2
32+
MAXLOCALS = 0
33+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
MODULE_FRAGMENT
2+
FILE fqName:<root> fileName:fragment.kt
3+
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
4+
thisReceiver: VALUE_PARAMETER INSTANCE_RECEIVER kind:DispatchReceiver name:<this> type:<root>.CodeFragment
5+
CONSTRUCTOR visibility:public returnType:<root>.CodeFragment [primary]
6+
BLOCK_BODY
7+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
8+
FUN name:run visibility:public modality:FINAL returnType:kotlin.Nothing?
9+
VALUE_PARAMETER kind:Regular name:p0 index:0 type:kotlin.String?
10+
EXPRESSION_BODY
11+
BLOCK type=kotlin.Nothing? origin=null
12+
GET_VAR 'p0: kotlin.String? declared in <root>.CodeFragment.run' type=kotlin.String? origin=null
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// DUMP_CODE
2+
3+
// MODULE: context
4+
5+
//FILE: context.kt
6+
fun main() {
7+
var str: String? = null
8+
str = "not null"
9+
println(str)
10+
<caret_context>str = null
11+
println(str)
12+
}
13+
14+
15+
// MODULE: main
16+
// MODULE_KIND: CodeFragment
17+
// CONTEXT_MODULE: context
18+
19+
// FILE: fragment.kt
20+
// CODE_FRAGMENT_KIND: EXPRESSION
21+
str
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// class version 52.0 (52)
2+
// access flags 0x31
3+
public final class CodeFragment {
4+
5+
// compiled from: fragment.kt
6+
7+
@Lkotlin/Metadata;(mv={2, 3, 0}, k=3, xi=48)
8+
9+
// access flags 0x1
10+
public <init>()V
11+
L0
12+
ALOAD 0
13+
INVOKESPECIAL java/lang/Object.<init> ()V
14+
RETURN
15+
L1
16+
LOCALVARIABLE this LCodeFragment; L0 L1 0
17+
MAXSTACK = 1
18+
MAXLOCALS = 1
19+
20+
// access flags 0x19
21+
public final static run(Ljava/lang/String;)Ljava/lang/Void;
22+
@Lorg/jetbrains/annotations/Nullable;() // invisible
23+
// annotable parameter count: 1 (invisible)
24+
@Lorg/jetbrains/annotations/Nullable;() // invisible, parameter 0
25+
L0
26+
LINENUMBER 21 L0
27+
ALOAD 0
28+
CHECKCAST java/lang/Void
29+
ARETURN
30+
L1
31+
LOCALVARIABLE p0 Ljava/lang/String; L0 L1 0
32+
MAXSTACK = 1
33+
MAXLOCALS = 1
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
MODULE_FRAGMENT
2+
FILE fqName:<root> fileName:fragment.kt
3+
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
4+
thisReceiver: VALUE_PARAMETER INSTANCE_RECEIVER kind:DispatchReceiver name:<this> type:<root>.CodeFragment
5+
CONSTRUCTOR visibility:public returnType:<root>.CodeFragment [primary]
6+
BLOCK_BODY
7+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
8+
FUN name:run visibility:public modality:FINAL returnType:kotlin.Nothing?
9+
VALUE_PARAMETER kind:Regular name:p0 index:0 type:kotlin.String?
10+
EXPRESSION_BODY
11+
BLOCK type=kotlin.Nothing? origin=null
12+
GET_VAR 'p0: kotlin.String? declared in <root>.CodeFragment.run' type=kotlin.String? origin=null
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// DUMP_CODE
2+
3+
// MODULE: context
4+
5+
//FILE: context.kt
6+
fun main() {
7+
var str: String? = null
8+
str = "not null"
9+
println(str)
10+
str = null
11+
<caret_context>println(str)
12+
}
13+
14+
15+
// MODULE: main
16+
// MODULE_KIND: CodeFragment
17+
// CONTEXT_MODULE: context
18+
19+
// FILE: fragment.kt
20+
// CODE_FRAGMENT_KIND: EXPRESSION
21+
str

0 commit comments

Comments
 (0)