[FIR2IR] Expand typealias in callable reference receiver generation

^KT-56750 Fixed
This commit is contained in:
Kirill Rakhman
2023-03-01 10:54:04 +01:00
committed by Space Team
parent 3ec032212c
commit d00513599b
14 changed files with 80 additions and 2 deletions
@@ -698,10 +698,11 @@ class CallAndReferenceGenerator(
): IrExpression? {
val classSymbol = (qualifier.typeRef.coneType as? ConeClassLikeType)?.lookupTag?.toSymbol(session)
if (callableReferenceAccess != null && classSymbol is FirRegularClassSymbol) {
val classIdMatched = classSymbol.classId == qualifier.classId
val classId = qualifier.symbol?.fullyExpandedClass(session)?.classId
val classIdMatched = classSymbol.classId == classId
if (!classIdMatched) {
// Check whether we need get companion object as dispatch receiver
if (!classSymbol.fir.isCompanion || classSymbol.classId.outerClassId != qualifier.classId) {
if (!classSymbol.fir.isCompanion || classSymbol.classId.outerClassId != classId) {
return null
}
val resolvedReference = callableReferenceAccess.calleeReference as FirResolvedNamedReference
@@ -3794,6 +3794,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/callableReference/bound/syntheticExtensionOnLHS.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -3794,6 +3794,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/callableReference/bound/syntheticExtensionOnLHS.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,7 @@
object Thing {
fun something(thing: String) = thing
}
typealias ThingAlias = Thing
fun box() = "OK".run(ThingAlias::something)
@@ -3650,6 +3650,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/callableReference/bound/syntheticExtensionOnLHS.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -3794,6 +3794,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/callableReference/bound/syntheticExtensionOnLHS.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -3186,6 +3186,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/callableReference/bound/syntheticExtensionOnLHS.kt");
}
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -2456,6 +2456,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -2510,6 +2510,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -2510,6 +2510,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -2510,6 +2510,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
runTest("compiler/testData/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -2599,6 +2599,12 @@ public class K2NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes
runTest("compiler/testData/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -2568,6 +2568,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
runTest("compiler/testData/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt");
}
@Test
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@@ -2226,6 +2226,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt");
}
@TestMetadata("typeAliasObjectBoundReference.kt")
public void testTypeAliasObjectBoundReference() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/bound/typeAliasObjectBoundReference.kt");
}
@TestMetadata("compiler/testData/codegen/box/callableReference/bound/equals")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)