KTIJ-28385 [AA] Support SAM constructors in computeImportableName
This allows to properly report them as used in `KtFirImportOptimizer` This change will also be important for properly fixing KTIJ-28167, since `computeImportableName` is also used in reference shortener ^KTIJ-28385 Fixed
This commit is contained in:
committed by
Space Team
parent
9ec469e3c3
commit
31291fc8fa
@@ -57,6 +57,9 @@ internal fun KtTypeNullability.toConeNullability() = when (this) {
|
|||||||
internal fun FirCallableSymbol<*>.computeImportableName(useSiteSession: FirSession): FqName? {
|
internal fun FirCallableSymbol<*>.computeImportableName(useSiteSession: FirSession): FqName? {
|
||||||
if (callableId.isLocal) return null
|
if (callableId.isLocal) return null
|
||||||
|
|
||||||
|
// SAM constructors are synthetic, but can be imported
|
||||||
|
if (origin is FirDeclarationOrigin.SamConstructor) return callableId.asSingleFqName()
|
||||||
|
|
||||||
// if classId == null, callable is topLevel
|
// if classId == null, callable is topLevel
|
||||||
val containingClassId = callableId.classId
|
val containingClassId = callableId.classId
|
||||||
?: return callableId.asSingleFqName()
|
?: return callableId.asSingleFqName()
|
||||||
|
|||||||
+12
@@ -232,6 +232,18 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGener
|
|||||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedInvokeOperatorImport.kt");
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedInvokeOperatorImport.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("usedNestedSamInterface_constructorCall.kt")
|
||||||
|
public void testUsedNestedSamInterface_constructorCall() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedNestedSamInterface_constructorCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("usedNestedSamInterface_constructorReference.kt")
|
||||||
|
public void testUsedNestedSamInterface_constructorReference() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedNestedSamInterface_constructorReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("usedObject_invokeOperator.kt")
|
@TestMetadata("usedObject_invokeOperator.kt")
|
||||||
public void testUsedObject_invokeOperator() throws Exception {
|
public void testUsedObject_invokeOperator() throws Exception {
|
||||||
|
|||||||
+12
@@ -232,6 +232,18 @@ public class FirStandaloneNormalAnalysisSourceModuleAnalysisApiImportOptimizerTe
|
|||||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedInvokeOperatorImport.kt");
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedInvokeOperatorImport.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("usedNestedSamInterface_constructorCall.kt")
|
||||||
|
public void testUsedNestedSamInterface_constructorCall() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedNestedSamInterface_constructorCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("usedNestedSamInterface_constructorReference.kt")
|
||||||
|
public void testUsedNestedSamInterface_constructorReference() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedNestedSamInterface_constructorReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("usedObject_invokeOperator.kt")
|
@TestMetadata("usedObject_invokeOperator.kt")
|
||||||
public void testUsedObject_invokeOperator() throws Exception {
|
public void testUsedObject_invokeOperator() throws Exception {
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
USED DECLARATIONS:
|
||||||
|
|
||||||
|
Declaration: dependency.Outer.NestedSAM
|
||||||
|
By names: [NestedSAM]
|
||||||
|
|
||||||
|
UNRESOLVED NAMES:
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// FILE: main.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
import dependency.Outer.NestedSAM
|
||||||
|
|
||||||
|
val handler = NestedSAM {}
|
||||||
|
|
||||||
|
// FILE: dependency.kt
|
||||||
|
package dependency
|
||||||
|
|
||||||
|
class Outer {
|
||||||
|
fun interface NestedSAM {
|
||||||
|
fun method()
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
USED DECLARATIONS:
|
||||||
|
|
||||||
|
Declaration: dependency.Outer.NestedSAM
|
||||||
|
By names: [NestedSAM]
|
||||||
|
|
||||||
|
UNRESOLVED NAMES:
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// FILE: main.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
import dependency.Outer.NestedSAM
|
||||||
|
|
||||||
|
val handler = ::NestedSAM
|
||||||
|
|
||||||
|
// FILE: dependency.kt
|
||||||
|
package dependency
|
||||||
|
|
||||||
|
class Outer {
|
||||||
|
fun interface NestedSAM {
|
||||||
|
fun method()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user