fixup! [FIR] do not create FirParameter for catch parameter
diff --git a/analysis/low-level-api-fir/testdata/getOrBuildFir/expressions/tryExpression.txt b/analysis/low-level-api-fir/testdata/getOrBuildFir/expressions/tryExpression.txt
index 26eb2ec..d8766d2 100644
--- a/analysis/low-level-api-fir/testdata/getOrBuildFir/expressions/tryExpression.txt
+++ b/analysis/low-level-api-fir/testdata/getOrBuildFir/expressions/tryExpression.txt
@@ -6,7 +6,7 @@
try {
Int(1)
}
-catch (lval e: R|kotlin/Throwable| = STUB) {
+catch (e: R|kotlin/Throwable|) {
}
finally {
}
\ No newline at end of file
diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/tryInLambda.fir.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/tryInLambda.fir.txt
index 08b4e0e..208d820 100644
--- a/compiler/fir/analysis-tests/testData/resolve/arguments/tryInLambda.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/arguments/tryInLambda.fir.txt
@@ -9,7 +9,7 @@
try {
lval x: R|kotlin/Int| = Int(1)
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
R|/foo|()
}
diff --git a/compiler/fir/analysis-tests/testData/resolve/catchParameter.fir.txt b/compiler/fir/analysis-tests/testData/resolve/catchParameter.fir.txt
index 669c1505..21dfc85 100644
--- a/compiler/fir/analysis-tests/testData/resolve/catchParameter.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/catchParameter.fir.txt
@@ -3,39 +3,39 @@
public final fun <T : R|kotlin/Throwable|> test(): R|kotlin/Unit| {
try {
}
- catch (lval e: R|kotlin/NullPointerException| = STUB) {
+ catch (e: R|kotlin/NullPointerException|) {
}
try {
}
- catch (lval e: R|T| = STUB) {
+ catch (e: R|T|) {
}
try {
}
- catch (lval e: R|() -> kotlin/Int| = STUB) {
+ catch (e: R|() -> kotlin/Int|) {
}
try {
}
- catch (lval e: R|StringType| = STUB) {
+ catch (e: R|StringType|) {
}
try {
}
- catch (lval e: R|kotlin/Int| = STUB) {
+ catch (e: R|kotlin/Int|) {
}
try {
}
- catch (lval e: R|kotlin/Throwable| = STUB) {
+ catch (e: R|kotlin/Throwable|) {
}
}
public final inline fun <reified T> anotherTest(): R|kotlin/Unit| {
try {
}
- catch (lval e: R|T| = STUB) {
+ catch (e: R|T|) {
}
}
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/complex.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/complex.dot
index 31b9ced..4a4323b 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/complex.dot
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/complex.dot
@@ -68,7 +68,7 @@
subgraph cluster_12 {
color=blue
27 [label="Catch enter"];
- 28 [label="Variable declaration: lval closeException: R|kotlin/Throwable|"];
+ 28 [label="Variable declaration: closeException: R|kotlin/Throwable|"];
subgraph cluster_13 {
color=blue
29 [label="Enter block"];
@@ -112,7 +112,7 @@
try {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
- catch (lval closeException: R|kotlin/Throwable| = STUB) {
+ catch (closeException: R|kotlin/Throwable|) {
R|<local>/cause|.R|kotlin/Throwable.addSuppressed|(R|<local>/closeException|)
}
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/complex.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/complex.fir.txt
index aceb666..b16f73c 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/complex.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/complex.fir.txt
@@ -14,7 +14,7 @@
try {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
- catch (lval closeException: R|kotlin/Throwable| = STUB) {
+ catch (closeException: R|kotlin/Throwable|) {
R|<local>/cause|.R|kotlin/Throwable.addSuppressed|(R|<local>/closeException|)
}
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot
index 138e624..ee65cb4 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot
@@ -153,7 +153,7 @@
subgraph cluster_18 {
color=blue
49 [label="Catch enter"];
- 50 [label="Variable declaration: lval e: R|kotlin/Exception|"];
+ 50 [label="Variable declaration: e: R|kotlin/Exception|"];
subgraph cluster_19 {
color=blue
51 [label="Enter block"];
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.fir.txt
index 229ee4d7..132738b 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.fir.txt
@@ -23,7 +23,7 @@
}
)
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
String()
}
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot
index 4375a99..6f79da2 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot
@@ -269,7 +269,7 @@
subgraph cluster_27 {
color=blue
87 [label="Catch enter"];
- 88 [label="Variable declaration: lval e: R|kotlin/Exception|"];
+ 88 [label="Variable declaration: e: R|kotlin/Exception|"];
subgraph cluster_28 {
color=blue
89 [label="Enter block"];
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.fir.txt
index ebcd308d..74fc9b5 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.fir.txt
@@ -48,7 +48,7 @@
public final val x4: R|kotlin/Int| = try {
Int(1)
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
Int(2)
}
finally {
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.dot
index 3f8b824..0a04084 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.dot
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.dot
@@ -27,7 +27,7 @@
subgraph cluster_5 {
color=blue
9 [label="Catch enter"];
- 10 [label="Variable declaration: lval e: R|kotlin/Exception|"];
+ 10 [label="Variable declaration: e: R|kotlin/Exception|"];
subgraph cluster_6 {
color=blue
11 [label="Enter block"];
@@ -40,7 +40,7 @@
subgraph cluster_7 {
color=blue
16 [label="Catch enter"];
- 17 [label="Variable declaration: lval e: R|kotlin/RuntimeException|"];
+ 17 [label="Variable declaration: e: R|kotlin/RuntimeException|"];
subgraph cluster_8 {
color=blue
18 [label="Enter block"];
@@ -107,7 +107,7 @@
subgraph cluster_14 {
color=blue
34 [label="Catch enter"];
- 35 [label="Variable declaration: lval e: R|kotlin/Exception|"];
+ 35 [label="Variable declaration: e: R|kotlin/Exception|"];
subgraph cluster_15 {
color=blue
36 [label="Enter block"];
@@ -224,7 +224,7 @@
subgraph cluster_31 {
color=blue
84 [label="Catch enter"];
- 85 [label="Variable declaration: lval e: R|kotlin/RuntimeException|"];
+ 85 [label="Variable declaration: e: R|kotlin/RuntimeException|"];
subgraph cluster_32 {
color=blue
86 [label="Enter block"];
@@ -237,7 +237,7 @@
subgraph cluster_33 {
color=blue
95 [label="Catch enter"];
- 96 [label="Variable declaration: lval e: R|kotlin/Exception|"];
+ 96 [label="Variable declaration: e: R|kotlin/Exception|"];
subgraph cluster_34 {
color=blue
97 [label="Enter block"];
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.fir.txt
index ce5b16c..e372bbf 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/tryCatch.fir.txt
@@ -3,10 +3,10 @@
try {
lval x: R|kotlin/Int| = Int(1)
}
- catch (lval e: R|kotlin/RuntimeException| = STUB) {
+ catch (e: R|kotlin/RuntimeException|) {
lval y: R|kotlin/Int| = Int(2)
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
lval z: R|kotlin/Int| = Int(3)
}
@@ -15,7 +15,7 @@
lval x: R|kotlin/Int| = try {
Int(1)
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
Int(2)
}
@@ -37,10 +37,10 @@
}
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
continue@@@[Boolean(true)]
}
- catch (lval e: R|kotlin/RuntimeException| = STUB) {
+ catch (e: R|kotlin/RuntimeException|) {
break@@@[Boolean(true)]
}
diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.fir.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.fir.txt
index e84a250..4f54179 100644
--- a/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.fir.txt
@@ -23,7 +23,7 @@
lval z: R|kotlin/Int| = @R|MyAnn|() try {
R|<local>/x|
}
- catch (lval t: R|kotlin/Throwable| = STUB) {
+ catch (t: R|kotlin/Throwable|) {
Int(0)
}
diff --git a/compiler/fir/analysis-tests/testData/resolve/tryInference.fir.txt b/compiler/fir/analysis-tests/testData/resolve/tryInference.fir.txt
index 1844a09..11c0470 100644
--- a/compiler/fir/analysis-tests/testData/resolve/tryInference.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/tryInference.fir.txt
@@ -10,7 +10,7 @@
R|/takeA|(try {
R|/materialize|<R|A|>()
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
R|/materialize|<R|A|>()
}
finally {
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/errorsInUnreachable.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/errorsInUnreachable.fir.txt
index 367e6bd..94589a6 100644
--- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/errorsInUnreachable.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/errorsInUnreachable.fir.txt
@@ -8,7 +8,7 @@
R|<local>/x|.R|kotlin/Boolean.not|()
lval a: R|kotlin/Int| = R|<local>/x1|.R|kotlin/text/toInt|()
}
- catch (lval e: R|kotlin/Exception| = STUB) {
+ catch (e: R|kotlin/Exception|) {
^case String(OK)
}
diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirPropertyInitializationAnalyzer.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirPropertyInitializationAnalyzer.kt
index dd04a84..5ffba0d 100644
--- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirPropertyInitializationAnalyzer.kt
+++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirPropertyInitializationAnalyzer.kt
@@ -8,18 +8,19 @@
import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange
import org.jetbrains.kotlin.contracts.description.canBeRevisited
import org.jetbrains.kotlin.contracts.description.isDefinitelyVisited
+import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
+import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.analysis.cfa.util.PathAwarePropertyInitializationInfo
import org.jetbrains.kotlin.fir.analysis.cfa.util.PropertyInitializationInfo
import org.jetbrains.kotlin.fir.analysis.cfa.util.TraverseDirection
import org.jetbrains.kotlin.fir.analysis.cfa.util.traverse
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
-import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
-import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.utils.isLateInit
import org.jetbrains.kotlin.fir.declarations.utils.referredPropertySymbol
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
+import org.jetbrains.kotlin.fir.isCatchParameter
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
@@ -37,16 +38,22 @@
context: CheckerContext
) {
val localData = data.filter {
- val symbolFir = (it.key.fir as? FirVariableSymbol<*>)?.fir
- symbolFir == null || symbolFir.initializer == null && symbolFir.delegate == null
+ val symbol = it.key.fir as? FirVariableSymbol<*>
+ symbol == null || !symbol.isInitialized()
}
- val localProperties = properties.filterTo(mutableSetOf()) { it.fir.initializer == null && it.fir.delegate == null }
+ val localProperties = properties.filterNotTo(mutableSetOf()) { it.isInitialized() }
val reporterVisitor = PropertyReporter(localData, localProperties, capturedWrites, reporter, context)
graph.traverse(TraverseDirection.Forward, reporterVisitor)
}
+ private fun FirVariableSymbol<*>.isInitialized(): Boolean {
+ return fir.initializer != null
+ || fir.delegate != null
+ || this is FirPropertySymbol && fir.isCatchParameter == true
+ }
+
private class PropertyReporter(
val data: Map<CFGNode<*>, PathAwarePropertyInitializationInfo>,
val localProperties: Set<FirPropertySymbol>,
diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt
index 41a562a..f3386f3 100644
--- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt
+++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt
@@ -1212,7 +1212,6 @@
isVar = false
status = FirResolvedDeclarationStatusImpl(Visibilities.Local, Modality.FINAL, EffectiveVisibility.Local)
isLocal = true
- initializer = buildExpressionStub { }
this.name = parameter.name
symbol = FirPropertySymbol(CallableId(name))
annotations += parameter.annotations
diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
index 39ab101..cb3c796 100644
--- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
+++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
@@ -1992,7 +1992,6 @@
isVar = false
status = FirResolvedDeclarationStatusImpl(Visibilities.Local, Modality.FINAL, EffectiveVisibility.Local)
isLocal = true
- initializer = buildExpressionStub { }
this.name = name
symbol = FirPropertySymbol(CallableId(name))
for (annotationEntry in ktParameter.annotationEntries) {
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRenderer.kt
index c3501c7..baef45f 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRenderer.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRenderer.kt
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir.renderer
import org.jetbrains.kotlin.fir.declarations.*
+import org.jetbrains.kotlin.fir.isCatchParameter
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
open class FirDeclarationRenderer {
@@ -32,8 +33,12 @@
is FirAnonymousFunction -> (declaration.label?.let { "${it.name}@" } ?: "") + "fun"
is FirSimpleFunction -> "fun"
is FirProperty -> {
- val prefix = if (declaration.isLocal) "l" else ""
- prefix + if (declaration.isVal) "val" else "var"
+ if (declaration.isCatchParameter == true) {
+ ""
+ } else {
+ val prefix = if (declaration.isLocal) "l" else ""
+ prefix + if (declaration.isVal) "val" else "var"
+ }
}
is FirPropertyAccessor -> if (declaration.isGetter) "get" else "set"
is FirField -> "field"
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt
index cc1954e..35cfb8c 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt
@@ -181,7 +181,9 @@
annotationRenderer?.render(callableDeclaration)
visitMemberDeclaration(callableDeclaration)
val receiverParameter = callableDeclaration.receiverParameter
- print(" ")
+ if (callableDeclaration !is FirProperty || callableDeclaration.isCatchParameter != true) {
+ print(" ")
+ }
if (receiverParameter != null) {
annotationRenderer?.render(receiverParameter, AnnotationUseSiteTarget.RECEIVER)
receiverParameter.typeRef.accept(this)