[FIR] take ready implicit unit type instead of return type calculation
and assert that symbol is not a substitution/intersection override in the `compute` method otherwise. Because `fakeOverrideSubstitution` should be calculated for all real implicit types, no call to this method should actually happen. Otherwise, it can be problematic to create a session which would contain the full designation path: `provider.getFirCallableContainerFile(symbol)` returns `firFile` of a super class which might be from module `a`, when declaration and its outer classes are from module `b`. ^KTIJ-24105
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.callResolver
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.calls.KtCallInfo
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.stringRepresentation
|
||||
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
|
||||
import org.jetbrains.kotlin.analysis.test.framework.project.structure.ktModuleProvider
|
||||
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.psi.KtCallElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractMultiModuleResolveCallTest : AbstractAnalysisApiBasedTest() {
|
||||
final override fun doTestByModuleStructure(moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val (expression, _) = moduleStructure.modules.flatMap { module ->
|
||||
val ktFiles = testServices.ktModuleProvider.getModuleFiles(module).filterIsInstance<KtFile>()
|
||||
testServices.expressionMarkerProvider.getElementsOfTypeAtCarets<KtExpression>(ktFiles)
|
||||
}.single()
|
||||
|
||||
val actual = executeOnPooledThreadInReadAction {
|
||||
analyseForTest(expression) {
|
||||
resolveCall(expression)?.let { stringRepresentation(it) }
|
||||
}
|
||||
} ?: "null"
|
||||
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
||||
}
|
||||
|
||||
private fun KtAnalysisSession.resolveCall(element: PsiElement): KtCallInfo? = when (element) {
|
||||
is KtCallElement -> element.resolveCall()
|
||||
is KtElement -> element.resolveCall()
|
||||
else -> error("Selected element type (${element::class.simpleName}) is not supported for resolveCall()")
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user