diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index e7ee5d59922..75c26fb8444 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirConstExpression import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference @@ -86,16 +87,17 @@ class ConversionTypeContext internal constructor( fun FirClassifierSymbol<*>.toSymbol( session: FirSession, classifierStorage: Fir2IrClassifierStorage, - typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT + typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT, + handleAnnotations: ((List) -> Unit)? = null ): IrClassifierSymbol { return when (this) { is FirTypeParameterSymbol -> { classifierStorage.getIrTypeParameterSymbol(this, typeContext) } is FirTypeAliasSymbol -> { - val typeAlias = fir - val coneClassLikeType = typeAlias.expandedTypeRef.coneType as ConeClassLikeType - coneClassLikeType.lookupTag.toSymbol(session)!!.toSymbol(session, classifierStorage) + handleAnnotations?.invoke(fir.expandedTypeRef.annotations) + val coneClassLikeType = fir.expandedTypeRef.coneType as ConeClassLikeType + coneClassLikeType.lookupTag.toSymbol(session)!!.toSymbol(session, classifierStorage, typeContext, handleAnnotations) } is FirClassSymbol -> { classifierStorage.getIrClassSymbol(this) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 688e77225cd..18138333a5e 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.expressions.classId import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -19,6 +20,7 @@ import org.jetbrains.kotlin.ir.types.IrTypeArgument import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection +import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.types.Variance @@ -84,13 +86,13 @@ class Fir2IrTypeConverter( return when (this) { is ConeKotlinErrorType -> createErrorType() is ConeLookupTagBasedType -> { - val classId = this.classId - val irSymbol = getBuiltInClassSymbol(classId) ?: run { - val firSymbol = this.lookupTag.toSymbol(session) ?: return createErrorType() - firSymbol.toSymbol(session, classifierStorage, typeContext) - } - val typeAnnotations: MutableList = mutableListOf() + val typeAnnotations = mutableListOf() typeAnnotations += with(annotationGenerator) { annotations.toIrAnnotations() } + val irSymbol = getBuiltInClassSymbol(classId) + ?: lookupTag.toSymbol(session)?.toSymbol(session, classifierStorage, typeContext) { + typeAnnotations += with(annotationGenerator) { it.toIrAnnotations() } + } + ?: return createErrorType() if (hasEnhancedNullability) { builtIns.enhancedNullabilityAnnotationConstructorCall()?.let { typeAnnotations += it diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 2bea9176c2b..b878b930906 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -38772,6 +38772,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @Test + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @Test @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { diff --git a/compiler/testData/codegen/box/typealias/extensionFunction.kt b/compiler/testData/codegen/box/typealias/extensionFunction.kt new file mode 100644 index 00000000000..7c1bda54df3 --- /dev/null +++ b/compiler/testData/codegen/box/typealias/extensionFunction.kt @@ -0,0 +1,8 @@ +typealias F = T.() -> R + +inline fun T.myRun(f: F) = f() + +fun box(): String { + val x = "K" + return "O".myRun { this + x } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 87c740b12ff..78043e67679 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -38978,6 +38978,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @Test + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @Test @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 668138782a5..6ec08af0bff 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -38772,6 +38772,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @Test + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @Test @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 0d1479d62d2..c3af176732e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -31333,6 +31333,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 610047dfa2a..791de4bd8af 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -26734,6 +26734,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 5ee340ea5bb..9a1556f7db5 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -26219,6 +26219,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 0011f4a413b..44ef736c75e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -26184,6 +26184,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 6d2b6c862c2..77f4dddc959 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -14490,6 +14490,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/typealias/enumEntryQualifier.kt"); } + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + runTest("compiler/testData/codegen/box/typealias/extensionFunction.kt"); + } + @TestMetadata("genericTypeAliasConstructor.kt") public void testGenericTypeAliasConstructor() throws Exception { runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor.kt");