Skip to content

Commit b239239

Browse files
mglukhikhSpace Team
authored andcommitted
K2: build outer classes sequence in FirImplicitBodyResolve properly
Before this commit, we used classId-based methods which didn't work correctly on local classes / objects, thus provoking exceptions. Now we use lookupTag-based methods which don't have such problems. #KT-67993 Fixed (cherry picked from commit 865f6fa)
1 parent afc5b49 commit b239239

File tree

29 files changed

+217
-3
lines changed

29 files changed

+217
-3
lines changed

analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java

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

analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java

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

analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java

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

analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java

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

compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java

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

compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java

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

compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java

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

compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithFir2IrFakeOverrideGeneratorTestGenerated.java

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

compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java

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

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.resolve.FirRegularTowerDataContexts
1919
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
2020
import org.jetbrains.kotlin.fir.resolve.ScopeSession
2121
import org.jetbrains.kotlin.fir.resolve.providers.firProvider
22+
import org.jetbrains.kotlin.fir.resolve.toSymbol
2223
import org.jetbrains.kotlin.fir.resolve.transformers.AdapterForResolveProcessor
2324
import org.jetbrains.kotlin.fir.resolve.transformers.FirTransformerBasedResolveProcessor
2425
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
@@ -310,9 +311,10 @@ open class ReturnTypeCalculatorWithJump(
310311
val file = provider.getFirCallableContainerFile(symbol)
311312
val script = file?.declarations?.firstIsInstanceOrNull<FirScript>()
312313

313-
val outerClasses = generateSequence(symbol.containingClassLookupTag()?.classId) { classId ->
314-
classId.outerClassId
315-
}.mapTo(mutableListOf()) { provider.getFirClassifierByFqName(it) }
314+
val containingClassLookupTag = symbol.containingClassLookupTag()
315+
val outerClasses = generateSequence(containingClassLookupTag) { lookupTag ->
316+
lookupTag.toSymbol(session)?.getContainingClassLookupTag()
317+
}.mapTo(mutableListOf()) { it.toSymbol(session)?.fir }
316318

317319
if (file == null || outerClasses.any { it == null }) {
318320
return buildErrorTypeRef {

0 commit comments

Comments
 (0)