From 99643e1b2d48a965b5170b61b65a9aa8de6d4b8c Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 19 Dec 2019 14:57:14 +0300 Subject: [PATCH] FIR: do not run full tower resolve on integer literal type --- .../src/org/jetbrains/kotlin/fir/FirCallResolver.kt | 3 ++- .../jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt | 7 ++++++- .../annotations/defaultValueMustBeConstant.fir.kt | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 75d2dfb86b2..1249cb54f4f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -137,7 +137,8 @@ class FirCallResolver( val result = towerResolver.runResolver( consumer, implicitReceiverStack.receiversAsReversed(), - shouldProcessExtensionsBeforeMembers = name in HIDES_MEMBERS_NAME_LIST + shouldProcessExtensionsBeforeMembers = name in HIDES_MEMBERS_NAME_LIST, + shouldProcessExplicitReceiverScopeOnly = explicitReceiver?.typeRef?.coneTypeSafe() != null ) val bestCandidates = result.bestCandidates() val reducedCandidates = if (result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt index dc011169304..aa55a34fd98 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt @@ -184,7 +184,8 @@ class FirTowerResolver( fun runResolver( consumer: TowerDataConsumer, implicitReceiverValues: List>, - shouldProcessExtensionsBeforeMembers: Boolean = false + shouldProcessExtensionsBeforeMembers: Boolean = false, + shouldProcessExplicitReceiverScopeOnly: Boolean = false ): CandidateCollector { this.implicitReceiverValues = implicitReceiverValues towerDataConsumer = consumer @@ -203,6 +204,10 @@ class FirTowerResolver( // fun test(f: Foo) { f.x } towerDataConsumer.consume(EMPTY, TowerScopeLevel.Empty, group++) + if (shouldProcessExplicitReceiverScopeOnly) { + return collector + } + // Member of local scope // fun test(x: Int) = x val nonEmptyLocalScopes = mutableListOf() diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.fir.kt index a3c86dac6b0..ad9dcbded21 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.fir.kt @@ -5,7 +5,7 @@ fun foo() = 1 val nonConst = foo() annotation class ValidAnn( - val p1: Int = 1 + CONST, + val p1: Int = 1 + CONST, val p2: String = "", val p3: KClass<*> = String::class, val p4: IntArray = intArrayOf(1, 2, 3),