From 813e35643c61581889bc5548e65193164de808e0 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 25 Sep 2019 16:00:31 +0300 Subject: [PATCH] FIR resolve: fix constructor handling in qualifier scope Constructors aren't more visited twice in regular scopes --- .../jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt | 10 ++++++++-- .../fir/resolve/testData/resolve/nested/simple.txt | 4 ++-- compiler/fir/resolve/testData/resolve/problems2.txt | 2 +- .../ir/irText/expressions/objectAsCallable.fir.txt | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt index 54c928d5054..ae6bddceaec 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt @@ -238,7 +238,10 @@ class QualifiedReceiverTowerLevel( val processorForCallables: (FirCallableSymbol<*>) -> ProcessorAction = { val fir = it.fir - if (fir is FirCallableMemberDeclaration<*> && fir.isStatic || it.callableId.classId == null) { + if (fir is FirCallableMemberDeclaration<*> && fir.isStatic || + it.callableId.classId == null || + fir is FirConstructor && !fir.isInner + ) { @Suppress("UNCHECKED_CAST") processor.consumeCandidate(it as T, null, null) } else { @@ -300,7 +303,10 @@ private fun FirScope.processFunctionsAndConstructorsByName( return ProcessorAction.STOP } - return processFunctionsByName(name, processor) + return processFunctionsByName(name) { + if (it is FirConstructorSymbol) ProcessorAction.NEXT + else processor(it) + } } private fun FirScope.getFirstClassifierOrNull(name: Name): FirClassifierSymbol<*>? { diff --git a/compiler/fir/resolve/testData/resolve/nested/simple.txt b/compiler/fir/resolve/testData/resolve/nested/simple.txt index c924000a5b4..88a102e31e5 100644 --- a/compiler/fir/resolve/testData/resolve/nested/simple.txt +++ b/compiler/fir/resolve/testData/resolve/nested/simple.txt @@ -40,6 +40,6 @@ FILE: simple.kt public final fun test(): R|kotlin/Unit| { lval o: R|Owner| = R|/Owner.Owner|() R|/o|.R|/Owner.foo|() - lval n: = Q|Owner|.#() - R|/n|.#() + lval n: R|Owner.Nested| = Q|Owner|.R|/Owner.Nested.Nested|() + R|/n|.R|/Owner.Nested.baz|() } diff --git a/compiler/fir/resolve/testData/resolve/problems2.txt b/compiler/fir/resolve/testData/resolve/problems2.txt index 9fb5f9b2959..898fae88642 100644 --- a/compiler/fir/resolve/testData/resolve/problems2.txt +++ b/compiler/fir/resolve/testData/resolve/problems2.txt @@ -61,7 +61,7 @@ FILE: problems2.kt } public final fun test(): R|kotlin/Unit| { - Q|Some|.#(Int(42), R?C|kotlin/arrayOf|(String(alpha), String(omega))) + Q|Some|.R|/Some.WithPrimary.WithPrimary|(Int(42), R|kotlin/arrayOf|(String(alpha), String(omega))) } public final class KonanTarget : R|kotlin/Any| { public constructor(name: R|kotlin/String|): R|KonanTarget| { diff --git a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt index 3bca93519fc..842652e042e 100644 --- a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt @@ -103,7 +103,7 @@ FILE fqName: fileName:/objectAsCallable.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:private [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: #' type=IrErrorType CONST Int type=kotlin.Int value=42 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val]