AA: take into account type arguments if available

...when computing receiver type for double colon expression
This commit is contained in:
Jinseong Jeon
2024-01-22 12:48:39 -08:00
committed by Space Team
parent 2429d09edd
commit 42e8245007
9 changed files with 82 additions and 2 deletions
@@ -76,6 +76,18 @@ public class Fe10IdeNormalAnalysisSourceModuleDoubleColonReceiverTypeTestGenerat
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_type.kt");
}
@Test
@TestMetadata("methodReference_typeArgument.kt")
public void testMethodReference_typeArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument.kt");
}
@Test
@TestMetadata("methodReference_typeArgument_startProjection.kt")
public void testMethodReference_typeArgument_startProjection() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument_startProjection.kt");
}
@Test
@TestMetadata("methodReference_variable.kt")
public void testMethodReference_variable() throws Exception {
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.analysis.api.fir.components
import org.jetbrains.kotlin.analysis.api.components.KtBuiltinTypes
import org.jetbrains.kotlin.analysis.api.components.KtTypeProvider
import org.jetbrains.kotlin.analysis.api.components.buildClassType
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
import org.jetbrains.kotlin.analysis.api.fir.symbols.KtFirNamedClassOrObjectSymbol
import org.jetbrains.kotlin.analysis.api.fir.symbols.KtFirSymbol
@@ -197,7 +196,10 @@ internal class KtFirTypeProvider(
explicitReceiver.resolvedType.asKtType()
}
is FirResolvedQualifier -> {
explicitReceiver.classId?.let { analysisSession.buildClassType(it) }
explicitReceiver.symbol?.toLookupTag()?.constructType(
explicitReceiver.typeArguments.map { it.toConeTypeProjection() }.toTypedArray(),
isNullable = false
)?.asKtType()
?: fir.resolvedType.getReceiverOfReflectionType()?.asKtType()
}
else -> {
@@ -76,6 +76,18 @@ public class FirIdeDependentAnalysisSourceModuleDoubleColonReceiverTypeTestGener
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_type.kt");
}
@Test
@TestMetadata("methodReference_typeArgument.kt")
public void testMethodReference_typeArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument.kt");
}
@Test
@TestMetadata("methodReference_typeArgument_startProjection.kt")
public void testMethodReference_typeArgument_startProjection() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument_startProjection.kt");
}
@Test
@TestMetadata("methodReference_variable.kt")
public void testMethodReference_variable() throws Exception {
@@ -76,6 +76,18 @@ public class FirIdeNormalAnalysisSourceModuleDoubleColonReceiverTypeTestGenerate
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_type.kt");
}
@Test
@TestMetadata("methodReference_typeArgument.kt")
public void testMethodReference_typeArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument.kt");
}
@Test
@TestMetadata("methodReference_typeArgument_startProjection.kt")
public void testMethodReference_typeArgument_startProjection() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument_startProjection.kt");
}
@Test
@TestMetadata("methodReference_variable.kt")
public void testMethodReference_variable() throws Exception {
@@ -76,6 +76,18 @@ public class FirStandaloneNormalAnalysisSourceModuleDoubleColonReceiverTypeTestG
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_type.kt");
}
@Test
@TestMetadata("methodReference_typeArgument.kt")
public void testMethodReference_typeArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument.kt");
}
@Test
@TestMetadata("methodReference_typeArgument_startProjection.kt")
public void testMethodReference_typeArgument_startProjection() throws Exception {
runTest("analysis/analysis-api/testData/components/typeInfoProvider/doubleColonReceiverType/methodReference_typeArgument_startProjection.kt");
}
@Test
@TestMetadata("methodReference_variable.kt")
public void testMethodReference_variable() throws Exception {
@@ -0,0 +1,13 @@
// FILE: MyInterface.kt
package test.pkg
interface MyInterface<T> {
fun sam(): T
}
// FILE: main.kt
import test.pkg.MyInterface
fun test() = MyInterface<String>:<caret>:sam
@@ -0,0 +1,2 @@
expression: MyInterface<String>::sam
receiver:: type: test.pkg.MyInterface<kotlin.String>
@@ -0,0 +1,13 @@
// FILE: MyInterface.kt
package test.pkg
interface MyInterface<T> {
fun sam(): T
}
// FILE: main.kt
import test.pkg.MyInterface
fun test() = MyInterface<*>:<caret>:sam
@@ -0,0 +1,2 @@
expression: MyInterface<*>::sam
receiver:: type: test.pkg.MyInterface<*>