diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt index 1c34f98dbe3..17ab73f78a2 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt @@ -5,6 +5,10 @@ package org.jetbrains.kotlin.fir.types +import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract + fun ConeKotlinType.render(): String { val nullabilitySuffix = if (this !is ConeKotlinErrorType && this !is ConeClassErrorType) nullability.suffix else "" return when (this) { @@ -17,12 +21,7 @@ fun ConeKotlinType.render(): String { append(lookupTag.classId.asString()) if (typeArguments.isNotEmpty()) { append(typeArguments.joinToString(prefix = "<", postfix = ">") { - when (it) { - ConeStarProjection -> "*" - is ConeKotlinTypeProjectionIn -> "in ${it.type.render()}" - is ConeKotlinTypeProjectionOut -> "out ${it.type.render()}" - is ConeKotlinType -> it.render() - } + it.render() }) } } @@ -49,3 +48,43 @@ fun ConeKotlinType.render(): String { is ConeStubType -> "stub type: $variable" } + nullabilitySuffix } + +private fun ConeKotlinTypeProjection.render(): String { + return when (this) { + ConeStarProjection -> "*" + is ConeKotlinTypeProjectionIn -> "in ${type.render()}" + is ConeKotlinTypeProjectionOut -> "out ${type.render()}" + is ConeKotlinType -> render() + } +} + +fun ConeKotlinType.renderFunctionType(kind: FunctionClassDescriptor.Kind?, isExtension: Boolean): String { + if (!kind.withPrettyRender()) return render() + return buildString { + if (kind == FunctionClassDescriptor.Kind.SuspendFunction) { + append("suspend ") + } + val (receiver, otherTypeArguments) = if (isExtension && typeArguments.first() != ConeStarProjection) { + typeArguments.first() to typeArguments.drop(1) + } else { + null to typeArguments.toList() + } + val arguments = otherTypeArguments.subList(0, otherTypeArguments.size - 1) + val returnType = otherTypeArguments.last() + if (receiver != null) { + append(receiver.render()) + append(".") + } + append(arguments.joinToString(", ", "(", ")") { it.render() }) + append(" -> ") + append(returnType.render()) + } +} + +@UseExperimental(ExperimentalContracts::class) +fun FunctionClassDescriptor.Kind?.withPrettyRender(): Boolean { + contract { + returns(true) implies (this@withPrettyRender != null) + } + return this != null && this != FunctionClassDescriptor.Kind.KSuspendFunction && this != FunctionClassDescriptor.Kind.KFunction +} \ No newline at end of file diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 87d530a8aec..3788b997e1a 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -31,10 +31,7 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeParameterModifier import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeProjectionModifier import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* -import org.jetbrains.kotlin.fir.types.FirDelegatedTypeRef -import org.jetbrains.kotlin.fir.types.FirTypeProjection -import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.FirUserTypeRef +import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens.* @@ -1463,7 +1460,7 @@ class DeclarationsConverter( FirResolvedTypeRefImpl( null, ConeClassTypeImpl( - ConeClassLikeLookupTagImpl(ClassId.fromString("kotlin/ExtensionFunctionType")), + ConeClassLikeLookupTagImpl(ClassId.fromString(EXTENSION_FUNCTION_ANNOTATION)), emptyArray(), false ) diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index c40753380af..8fb8fbf5f7e 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.impl.FirLabelImpl import org.jetbrains.kotlin.fir.references.impl.* import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.types.EXTENSION_FUNCTION_ANNOTATION import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.* @@ -1376,7 +1377,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder FirResolvedTypeRefImpl( null, ConeClassTypeImpl( - ConeClassLikeLookupTagImpl(ClassId.fromString("kotlin/ExtensionFunctionType")), + ConeClassLikeLookupTagImpl(ClassId.fromString(EXTENSION_FUNCTION_ANNOTATION)), emptyArray(), false ) diff --git a/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt b/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt index c29b4d55fd5..985d857b989 100644 --- a/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt +++ b/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt @@ -172,10 +172,5 @@ abstract class AbstractRawFirBuilderTestCase : KtParsingTestCase( } -private val FirElement.isExtensionFunctionAnnotationCall: Boolean get() = (this as? FirAnnotationCall)?.let { - (it.annotationTypeRef as? FirResolvedTypeRef)?.let { - (it.type as? ConeClassLikeType)?.let { - it.lookupTag.classId.asString() == "kotlin/ExtensionFunctionType" - } - } -} == true +private val FirElement.isExtensionFunctionAnnotationCall: Boolean + get() = (this as? FirAnnotationCall)?.isExtensionFunctionAnnotationCall == true diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArguments.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArguments.kt index b54f44cb084..c5405ab216d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArguments.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArguments.kt @@ -21,14 +21,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystem import org.jetbrains.kotlin.resolve.calls.model.PostponedResolvedAtomMarker import org.jetbrains.kotlin.utils.addToStdlib.safeAs -fun FirTypeRef.isExtensionFunctionType(): Boolean { - return annotations.any { - (it.annotationTypeRef as? FirResolvedTypeRef)?.let { - it.type.toString() == "kotlin/ExtensionFunctionType" - } == true - } -} - fun Candidate.preprocessLambdaArgument( csBuilder: ConstraintSystemBuilder, argument: FirAnonymousFunction, @@ -88,18 +80,12 @@ private val ConeKotlinType.isSuspendFunctionType: Boolean } private fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef): ConeKotlinType? { - if (isFunctionalTypeWithReceiver(expectedTypeRef)) { + if (expectedTypeRef.isExtensionFunctionType()) { return (this.typeArguments.first() as ConeTypedProjection).type } return null } -private fun isFunctionalTypeWithReceiver(typeRef: FirTypeRef) = - typeRef.annotations.any { - val coneTypeSafe = it.annotationTypeRef.coneTypeSafe() ?: return@any false - coneTypeSafe.lookupTag.classId.asString() == "kotlin/ExtensionFunctionType" - } - val ConeKotlinType.returnType: ConeKotlinType? get() { require(this is ConeClassType) diff --git a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt index 67ffe9d8bd9..085792077c5 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt +++ b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt @@ -1,9 +1,9 @@ FILE: lambda.kt - public final fun foo(f: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun foo(f: R|() -> kotlin/Unit|): R|kotlin/Unit| { } - public final fun bar(x: R|kotlin/Int|, f: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun bar(x: R|kotlin/Int|, f: R|() -> kotlin/Unit|): R|kotlin/Unit| { } - public final fun baz(f: R|kotlin/Function0|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| { + public final fun baz(f: R|() -> kotlin/Unit|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| { } public final fun test(): R|kotlin/Unit| { R|/foo|( = foo@fun (): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/arguments/overloadWithDefault.txt b/compiler/fir/resolve/testData/resolve/arguments/overloadWithDefault.txt index 81308b0c0c9..2dc8330d1fd 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/overloadWithDefault.txt +++ b/compiler/fir/resolve/testData/resolve/arguments/overloadWithDefault.txt @@ -2,7 +2,7 @@ FILE: overloadWithDefault.kt public abstract interface A : R|kotlin/Any| { public abstract fun foo(b: R|kotlin/Boolean| = Boolean(false)): R|A| - public abstract fun foo(block: R|kotlin/Function0|): R|A| + public abstract fun foo(block: R|() -> kotlin/Boolean|): R|A| } public final fun test(a: R|A|): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/cast.txt b/compiler/fir/resolve/testData/resolve/cast.txt index 91ead3cc831..393fae0d9e4 100644 --- a/compiler/fir/resolve/testData/resolve/cast.txt +++ b/compiler/fir/resolve/testData/resolve/cast.txt @@ -3,23 +3,23 @@ FILE: cast.kt public get(): R|kotlin/Int| public final val y: R|kotlin/Any| = (Int(2) as R|kotlin/Any|) public get(): R|kotlin/Any| - public final val f: R|kotlin/Function0| = fun (): R|kotlin/Any| { + public final val f: R|() -> kotlin/Any| = fun (): R|kotlin/Any| { ^ (Int(3) as R|kotlin/Any|) } - public get(): R|kotlin/Function0| - public final val g: R|kotlin/Function0| = fun (): R|kotlin/Unit| { + public get(): R|() -> kotlin/Any| + public final val g: R|() -> kotlin/Unit| = fun (): R|kotlin/Unit| { Unit } - public get(): R|kotlin/Function0| - public final val h: R|kotlin/Function1| = fun (_: R|kotlin/String|): R|kotlin/Boolean| { + public get(): R|() -> kotlin/Unit| + public final val h: R|(kotlin/String) -> kotlin/Boolean| = fun (_: R|kotlin/String|): R|kotlin/Boolean| { Boolean(false) } - public get(): R|kotlin/Function1| - public final val hError: R|kotlin/Function1| = fun (_: R|class error: No type for parameter|): R|kotlin/Boolean| { + public get(): R|(kotlin/String) -> kotlin/Boolean| + public final val hError: R|(class error: No type for parameter) -> kotlin/Boolean| = fun (_: R|class error: No type for parameter|): R|kotlin/Boolean| { Boolean(true) } - public get(): R|kotlin/Function1| + public get(): R|(class error: No type for parameter) -> kotlin/Boolean| diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.txt b/compiler/fir/resolve/testData/resolve/cfg/jumps.txt index 3416d239cee..1a5901309e6 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.txt @@ -50,7 +50,7 @@ FILE: jumps.kt } } - public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|() -> kotlin/Unit|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final fun test_6(): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot b/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot index e3c84b682ce..87fb0fe314b 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot @@ -110,7 +110,7 @@ digraph lambdas_kt { subgraph cluster_13 { color=blue 36 [label="Enter block"]; - 37 [label="Variable declaration: lval lambda: R|kotlin/Function0|"]; + 37 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"]; 38 [label="Exit block"]; } 39 [label="Exit when branch result"]; diff --git a/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt b/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt index 69f23b8ee5f..24fa31028c0 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt @@ -1,5 +1,5 @@ FILE: lambdas.kt - public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|() -> kotlin/Unit|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final fun test_1(x: R|kotlin/Any?|): R|kotlin/Unit| { @@ -16,7 +16,7 @@ FILE: lambdas.kt public final fun test_2(x: R|kotlin/Any?|): R|kotlin/Unit| { when () { (R|/x| is R|kotlin/Int|) -> { - lval lambda: R|kotlin/Function0| = fun (): R|kotlin/Int| { + lval lambda: R|() -> kotlin/Int| = fun (): R|kotlin/Int| { R|/x|.R|kotlin/Int.inc|() } @@ -24,7 +24,7 @@ FILE: lambdas.kt } } - public final inline fun getInt(block: R|kotlin/Function0|): R|kotlin/Int| { + public final inline fun getInt(block: R|() -> kotlin/Unit|): R|kotlin/Int| { R|/block|.R|FakeOverride|() ^getInt Int(1) } diff --git a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt index a181cc2d8e9..2416514e27b 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt @@ -1,5 +1,5 @@ FILE: propertiesAndInitBlocks.kt - public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|() -> kotlin/Unit|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final val x1: R|kotlin/Int| = Int(1) diff --git a/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt b/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt index 7a3c8cf5cb4..ed9fc5719bd 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt @@ -16,7 +16,7 @@ FILE: extensionPropertyInLambda.kt public set(v: R|T|): R|kotlin/Unit| { this@R|/C|.R|/C.x| = R|/v| } - public final fun use(f: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun use(f: R|() -> kotlin/String|): R|kotlin/Unit| { } public final fun test1(): R|kotlin/Unit| { R|/use|( = use@fun (): R|kotlin/String| { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.txt index 6b3f2ecc410..a0dbdbf1cf1 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.txt @@ -1,6 +1,6 @@ FILE: propertyFromParameter.kt public final class Bar : R|kotlin/Any| { - public constructor(name: R|kotlin/Function0|): R|Bar| { + public constructor(name: R|() -> kotlin/String|): R|Bar| { super() } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt b/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt index 1f0e228efc1..ec7be20d201 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt @@ -1,11 +1,11 @@ FILE: lambda.kt - public final fun foo(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun foo(block: R|() -> kotlin/Unit|): R|kotlin/Unit| { } - public final fun bar(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun bar(block: R|() -> kotlin/String|): R|kotlin/Unit| { } - public final fun itIs(block: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun itIs(block: R|(kotlin/String) -> kotlin/String|): R|kotlin/Unit| { } - public final fun multipleArgs(block: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun multipleArgs(block: R|(kotlin/String, kotlin/String) -> kotlin/String|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { R|/foo|( = foo@fun (): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt index 9434ca87de5..8f4156205c1 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt @@ -3,13 +3,13 @@ FILE: lambdaWithReceiver.kt public abstract fun foo(): R|kotlin/Unit| } - public final fun myWith(receiver: R|T|, block: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function1|): R|kotlin/Unit| { + public final fun myWith(receiver: R|T|, block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| { R|/receiver|.#() } - public final fun R|T|.myApply(block: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function1|): R|kotlin/Unit| { + public final fun R|T|.myApply(block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| { this@R|/myApply|.#() } - public final fun withA(block: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function1|): R|kotlin/Unit| { + public final fun withA(block: R|A.() -> kotlin/Unit|): R|kotlin/Unit| { } public final fun test_1(): R|kotlin/Unit| { R|/withA|( = withA@fun R|A|.(): R|kotlin/Unit| { @@ -29,7 +29,7 @@ FILE: lambdaWithReceiver.kt } ) } - public final fun complexLambda(block: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function2|): R|kotlin/Unit| { + public final fun complexLambda(block: R|kotlin/Int.(kotlin/String) -> kotlin/Unit|): R|kotlin/Unit| { } public final fun test_4(): R|kotlin/Unit| { R|/complexLambda|( = complexLambda@fun R|kotlin/Int|.(it: R|kotlin/String|): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/ft.txt b/compiler/fir/resolve/testData/resolve/ft.txt index a96bea8efb5..d2764d353b1 100644 --- a/compiler/fir/resolve/testData/resolve/ft.txt +++ b/compiler/fir/resolve/testData/resolve/ft.txt @@ -1,5 +1,5 @@ FILE: ft.kt public abstract interface KMutableProperty1 : R|KProperty1| { } - public abstract interface KProperty1 : R|kotlin/Function1| { + public abstract interface KProperty1 : R|(T) -> kotlin/Int| { } diff --git a/compiler/fir/resolve/testData/resolve/functionTypes.txt b/compiler/fir/resolve/testData/resolve/functionTypes.txt index c3213480f73..8033d060184 100644 --- a/compiler/fir/resolve/testData/resolve/functionTypes.txt +++ b/compiler/fir/resolve/testData/resolve/functionTypes.txt @@ -1,15 +1,15 @@ FILE: functionTypes.kt - public final fun simpleRun(f: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun simpleRun(f: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { ^simpleRun R|/f|.R|FakeOverride|(^simpleRun Unit) } - public final fun R|kotlin/collections/List|.simpleMap(f: R|kotlin/Function1|): R|R| { + public final fun R|kotlin/collections/List|.simpleMap(f: R|(T) -> R|): R|R| { } - public final fun simpleWith(t: R|T|, f: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function1|): R|kotlin/Unit| { + public final fun simpleWith(t: R|T|, f: R|T.() -> kotlin/Unit|): R|kotlin/Unit| { ^simpleWith R|/t|.#() } public abstract interface KMutableProperty1 : R|KProperty1|, R|KMutableProperty| { } - public abstract interface KProperty1 : R|KProperty|, R|kotlin/Function1| { + public abstract interface KProperty1 : R|KProperty|, R|(T) -> R| { } public abstract interface KProperty : R|kotlin/Any| { } diff --git a/compiler/fir/resolve/testData/resolve/localObject.txt b/compiler/fir/resolve/testData/resolve/localObject.txt index 0fa64d5feba..8deefc649e1 100644 --- a/compiler/fir/resolve/testData/resolve/localObject.txt +++ b/compiler/fir/resolve/testData/resolve/localObject.txt @@ -1,5 +1,5 @@ FILE: localObject.kt - public final fun run(block: R|kotlin/Function0|): R|T| { + public final fun run(block: R|() -> T|): R|T| { ^run R|/block|.R|FakeOverride|() } public abstract interface Foo : R|kotlin/Any| { diff --git a/compiler/fir/resolve/testData/resolve/samConstructors/kotlinSam.txt b/compiler/fir/resolve/testData/resolve/samConstructors/kotlinSam.txt index 4a8dc4b11cb..3cfe5ee3b2f 100644 --- a/compiler/fir/resolve/testData/resolve/samConstructors/kotlinSam.txt +++ b/compiler/fir/resolve/testData/resolve/samConstructors/kotlinSam.txt @@ -14,7 +14,7 @@ FILE: kotlinSam.kt >(R|/it|, Int(1)) } )) - lval x: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/samConstructors/realConstructorFunction.txt b/compiler/fir/resolve/testData/resolve/samConstructors/realConstructorFunction.txt index 7f067524235..88fdeba9231 100644 --- a/compiler/fir/resolve/testData/resolve/samConstructors/realConstructorFunction.txt +++ b/compiler/fir/resolve/testData/resolve/samConstructors/realConstructorFunction.txt @@ -1,7 +1,7 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } - public final fun MyRunnable(x: R|kotlin/Function1|): R|kotlin/Int| { + public final fun MyRunnable(x: R|(kotlin/Int) -> kotlin/Boolean|): R|kotlin/Int| { ^MyRunnable Int(1) } public final fun main(): R|kotlin/Unit| { @@ -13,7 +13,7 @@ FILE: main.kt >(R|/it|, Int(1)) } )) - lval x: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/samConstructors/simple.txt b/compiler/fir/resolve/testData/resolve/samConstructors/simple.txt index c81f8054ce8..c78555d1a4b 100644 --- a/compiler/fir/resolve/testData/resolve/samConstructors/simple.txt +++ b/compiler/fir/resolve/testData/resolve/samConstructors/simple.txt @@ -10,7 +10,7 @@ FILE: main.kt >(R|/it|, Int(1)) } )) - lval x: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt b/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt index f42d744e935..6ce510fe066 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt @@ -29,7 +29,7 @@ FILE: kotlinSam.kt public final fun foo4(m: R|Derived|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - lval f: R|kotlin/Function1| = fun (t: R|kotlin/Int|): R|kotlin/Boolean| { + lval f: R|(kotlin/Int) -> kotlin/Boolean| = fun (t: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/t|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt b/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt index 1177e9563f9..cedcacf33fb 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt @@ -10,7 +10,7 @@ FILE: main.kt >(#, Int(1)) } ) - lval x: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/samConversions/samSupertype.txt b/compiler/fir/resolve/testData/resolve/samConversions/samSupertype.txt index f86162da2fa..db0ff600ba3 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/samSupertype.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/samSupertype.txt @@ -10,7 +10,7 @@ FILE: main.kt >(R|/it|, Int(1)) } ) - lval x: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/samConversions/samSupertypeWithOverride.txt b/compiler/fir/resolve/testData/resolve/samConversions/samSupertypeWithOverride.txt index d550a436ef5..0e330b694e5 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/samSupertypeWithOverride.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/samSupertypeWithOverride.txt @@ -10,7 +10,7 @@ FILE: main.kt >(R|/it|, Int(1)) } ) - lval x: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/samConversions/simple.txt b/compiler/fir/resolve/testData/resolve/samConversions/simple.txt index f86162da2fa..db0ff600ba3 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/simple.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/simple.txt @@ -10,7 +10,7 @@ FILE: main.kt >(R|/it|, Int(1)) } ) - lval x: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.txt b/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.txt index 8554874eae0..69c9a3d1286 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.txt @@ -8,7 +8,7 @@ FILE: implicitReceivers.kt } } - public final fun R|T|.with(block: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function1|): R|kotlin/Unit| { + public final fun R|T|.with(block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| { } public final fun R|kotlin/Any?|.test_1(): R|kotlin/Unit| { when () { diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt index d8746ba4288..a03728e273e 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt @@ -7,7 +7,7 @@ FILE: inPlaceLambdas.kt public abstract fun bar(): R|kotlin/Unit| } - public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|() -> kotlin/Unit|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final fun test_1(x: R|kotlin/Any?|): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/beyoundCalls.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/beyoundCalls.txt index 208d6f8e00c..96bc8fde8aa 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/beyoundCalls.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/beyoundCalls.txt @@ -12,9 +12,9 @@ FILE: beyoundCalls.kt ^foobaz R|kotlin/TODO|() } public final fun foo(): R|kotlin/Unit| { - lval x: R|kotlin/Function1| = ::R|/bar| + lval x: R|(kotlin/String) -> kotlin/Int| = ::R|/bar| lval y: = ::# lval z: R|kotlin/reflect/KFunction1| = ::R|/baz| - lval w: R|kotlin/Function1| = ::R|/foobaz| + lval w: R|(kotlin/String) -> kotlin/Int| = ::R|/foobaz| ::R|/baz| } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/companions.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/companions.txt index f46a2d2059a..fb606eeb259 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/companions.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/companions.txt @@ -41,13 +41,13 @@ FILE: main.kt } } - public final fun foo1(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo1(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo2(x: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun foo2(x: R|(KotlinClass, kotlin/CharSequence) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo3(x: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun foo3(x: R|(KotlinClass, kotlin/CharSequence) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo3(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo3(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { R|/foo1|(Q|KotlinClass|::R|/KotlinClass.Companion.baz|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/constructors.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/constructors.txt index d6587033234..1837452e0b7 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/constructors.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/constructors.txt @@ -9,7 +9,7 @@ FILE: constructors.kt } } - public final fun user(f: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun user(f: R|(kotlin/Int) -> Klass|): R|kotlin/Unit| { } public final fun fn(): R|kotlin/Unit| { R|/user|(::R|/Klass.Klass|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/differentLevels.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/differentLevels.txt index 55714d65af2..af7c9bd034f 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/differentLevels.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/differentLevels.txt @@ -1,5 +1,5 @@ FILE: differentLevels.kt - public final fun foo(x: R|kotlin/Function0|, y: R|kotlin/Int|): R|kotlin/Unit| { + public final fun foo(x: R|() -> kotlin/Int|, y: R|kotlin/Int|): R|kotlin/Unit| { } public final fun bar(x: R|kotlin/String|): R|kotlin/Int| { ^bar Int(1) @@ -9,7 +9,7 @@ FILE: differentLevels.kt ^bar Int(1) } - local final fun foo(x: R|kotlin/Function1|, y: R|kotlin/String|): R|kotlin/Unit| { + local final fun foo(x: R|(kotlin/String) -> kotlin/Int|, y: R|kotlin/String|): R|kotlin/Unit| { } R|/foo|(::R|/bar|, Int(1)) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/extensionReceiverInference.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/extensionReceiverInference.txt index 41fb39ff613..4720e5b995f 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/extensionReceiverInference.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/extensionReceiverInference.txt @@ -12,7 +12,7 @@ FILE: extensionReceiverInference.kt public final fun R|X|.baz(): R|kotlin/Int| { ^baz Int(1) } - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(A) -> kotlin/Int|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { R|/foo|(Q|A|::R|/prop|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.txt index 35acb943f3b..41dfc57cd75 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.txt @@ -3,7 +3,7 @@ FILE: ambiguityWhenNoApplicableCallableReferenceCandidate.kt } public final fun foo(y: R|kotlin/String|): R|kotlin/Unit| { } - public final fun bar(f: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun bar(f: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { } public final fun test(): R|kotlin/Unit| { R|/bar|(::#) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/applicableCallableReferenceFromDistantScope.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/applicableCallableReferenceFromDistantScope.txt index 7ecaa8d8c9b..8a6f2cf50a0 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/applicableCallableReferenceFromDistantScope.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/applicableCallableReferenceFromDistantScope.txt @@ -12,7 +12,7 @@ FILE: applicableCallableReferenceFromDistantScope.kt public final fun foo(b: R|kotlin/Boolean|): R|kotlin/Unit| { } - public final fun bar(f: R|kotlin/Function1|): R|T| { + public final fun bar(f: R|(T) -> kotlin/Unit|): R|T| { ^bar R|kotlin/TODO|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt index bac374f7a4b..de2ece8938a 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt @@ -26,7 +26,7 @@ FILE: chooseCallableReferenceDependingOnInferredReceiver.kt } } - public final fun bar(f: R|kotlin/Function1|): R|T| { + public final fun bar(f: R|(T) -> kotlin/Unit|): R|T| { ^bar R|kotlin/TODO|() } public final fun test(): R|kotlin/Unit| { @@ -43,6 +43,6 @@ FILE: chooseCallableReferenceDependingOnInferredReceiver.kt } ) } - public final inline fun myWith(receiver: R|T|, block: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function1|): R|R| { + public final inline fun myWith(receiver: R|T|, block: R|T.() -> R|): R|R| { ^myWith R|kotlin/TODO|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt index f6bd5dbda9c..b4db0c91619 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt @@ -11,7 +11,7 @@ FILE: eagerAndPostponedCallableReferences.kt } public final fun singleB(a: R|B|): R|kotlin/Unit| { } - public final fun foo(f: R|kotlin/Function1|, g: R|kotlin/Function1|): R|T| { + public final fun foo(f: R|(T) -> kotlin/Unit|, g: R|(T) -> kotlin/Unit|): R|T| { ^foo R|kotlin/TODO|() } public final fun test(): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerResolveOfSingleCallableReference.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerResolveOfSingleCallableReference.txt index 405ee2ff960..5d489fe71fc 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerResolveOfSingleCallableReference.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/eagerResolveOfSingleCallableReference.txt @@ -26,6 +26,6 @@ FILE: eagerResolveOfSingleCallableReference.kt public final fun test(ls: R|Out|): R|kotlin/Unit| { R|/ls|.R|/reduce|(::R|/Or.Or|) } - public final fun R|Out|.reduce(operation: R|kotlin/Function2|): R|S| { + public final fun R|Out|.reduce(operation: R|(S, T) -> S|): R|S| { ^reduce R|kotlin/TODO|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/multipleOutersAndMultipleCallableReferences.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/multipleOutersAndMultipleCallableReferences.txt index e7b43e2144b..0b08efeae24 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/multipleOutersAndMultipleCallableReferences.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/multipleOutersAndMultipleCallableReferences.txt @@ -13,9 +13,9 @@ FILE: multipleOutersAndMultipleCallableReferences.kt public final fun foo(y: R|kotlin/String|): R|Inv| { ^foo R|kotlin/TODO|() } - public final fun bar(f: R|kotlin/Function1>|, p: R|kotlin/String| = String()): R|kotlin/Unit| { + public final fun bar(f: R|(T) -> Inv|, p: R|kotlin/String| = String()): R|kotlin/Unit| { } - public final fun bar(f: R|kotlin/Function1>|, p: R|kotlin/Int| = Int(4)): R|kotlin/Unit| { + public final fun bar(f: R|(T) -> Inv|, p: R|kotlin/Int| = Int(4)): R|kotlin/Unit| { } public final fun test(): R|kotlin/Unit| { R|/bar|(::R|/foo|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/overloadsBound.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/overloadsBound.txt index b2ec3180d1e..16fa9f23a30 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/overloadsBound.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/overloadsBound.txt @@ -11,7 +11,7 @@ FILE: overloadsBound.kt } } - public final fun foo(p: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(p: R|(kotlin/String) -> kotlin/Unit|): R|kotlin/Unit| { } public final fun bar(c: R|C|): R|kotlin/Unit| { R|/foo|(R|/c|::R|/C.xf1|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/postponedResolveOfManyCallableReference.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/postponedResolveOfManyCallableReference.txt index bc88ceaa0cc..dbdb1207338 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/postponedResolveOfManyCallableReference.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/postponedResolveOfManyCallableReference.txt @@ -7,10 +7,10 @@ FILE: postponedResolveOfManyCallableReference.kt } public final fun foo(b: R|B|): R|kotlin/Unit| { } - public final fun bar1(f: R|kotlin/Function1|): R|T| { + public final fun bar1(f: R|(T) -> kotlin/Unit|): R|T| { ^bar1 R|kotlin/TODO|() } - public final fun bar2(f: R|kotlin/Function1|, e: R|T|): R|kotlin/Unit| { + public final fun bar2(f: R|(T) -> kotlin/Unit|, e: R|T|): R|kotlin/Unit| { } public final fun test(a: R|A|, b: R|B|): R|kotlin/Unit| { lval expectedType1: R|A| = R|/bar1|(::R|/foo|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.txt index 8a3707ffe9e..50048dd39ac 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.txt @@ -5,9 +5,9 @@ FILE: resolveCallableReferencesAfterAllSimpleArguments.kt } public final fun fooB(b: R|B|): R|kotlin/Unit| { } - public final fun bar(f: R|kotlin/Function1|, e: R|T|): R|kotlin/Unit| { + public final fun bar(f: R|(T) -> kotlin/Unit|, e: R|T|): R|kotlin/Unit| { } - public final fun baz(e: R|T|, f: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun baz(e: R|T|, f: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { } public final fun test(a: R|A|, b: R|B|): R|kotlin/Unit| { #(R|/a|, ::R|/fooB|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/withGenericFun.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/withGenericFun.txt index b908576d876..842ad8c1c1e 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/withGenericFun.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/fromBasicDiagnosticTests/withGenericFun.txt @@ -1,5 +1,5 @@ FILE: withGenericFun.kt - public final fun apply(x: R|T|, f: R|kotlin/Function1|): R|R| { + public final fun apply(x: R|T|, f: R|(T) -> R|): R|R| { ^apply R|/f|.R|FakeOverride|(R|/x|) } public final fun foo(i: R|kotlin/Int|): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt index 2de4452dbb3..6b1a5cd05f0 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt @@ -1,8 +1,8 @@ FILE: implicitTypes.kt - public final fun use(x: R|kotlin/Function1|): R|kotlin/Function1| { + public final fun use(x: R|(T) -> R|): R|(T) -> R| { ^use R|/x| } - public final fun foo(): R|kotlin/Function1| { + public final fun foo(): R|(kotlin/String) -> kotlin/Int| { ^foo R|/use|(::R|/bar|) } public final fun bar(x: R|kotlin/String|): R|kotlin/Int| { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromCallableReferenceType.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromCallableReferenceType.txt index 60da2371c93..bcfe9d226e2 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromCallableReferenceType.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromCallableReferenceType.txt @@ -1,7 +1,7 @@ FILE: inferenceFromCallableReferenceType.kt - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(T) -> E|): R|kotlin/Unit| { } - public final fun foo2(x: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun foo2(x: R|(A, T) -> E|): R|kotlin/Unit| { } public final class A : R|kotlin/Any| { public constructor(): R|A| { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromExpectedType.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromExpectedType.txt index e664dd9b04a..817138b31e0 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromExpectedType.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/inferenceFromExpectedType.txt @@ -1,7 +1,7 @@ FILE: inferenceFromExpectedType.kt - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo2(x: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun foo2(x: R|(A, kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } public final class A : R|kotlin/Any| { public constructor(): R|A| { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/javaStatic.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/javaStatic.txt index 4e777c388a8..729b75b0a9a 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/javaStatic.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/javaStatic.txt @@ -1,11 +1,11 @@ FILE: main.kt - public final fun foo1(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo1(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo2(x: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun foo2(x: R|(JavaClass, kotlin/CharSequence) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo3(x: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun foo3(x: R|(JavaClass, kotlin/CharSequence) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo3(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo3(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { R|/foo1|(Q|JavaClass|::R|/JavaClass.bar|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyCandidatesInference.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyCandidatesInference.txt index c7b5d155dd0..3b8dcb7083c 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyCandidatesInference.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyCandidatesInference.txt @@ -1,5 +1,5 @@ FILE: manyCandidatesInference.kt - public final fun foo(x: R|kotlin/Function0|, y: R|kotlin/Int|): R|kotlin/Unit| { + public final fun foo(x: R|() -> T|, y: R|kotlin/Int|): R|kotlin/Unit| { } public final fun bar(x: R|E|): R|kotlin/Int| { ^bar Int(1) @@ -9,7 +9,7 @@ FILE: manyCandidatesInference.kt ^bar Int(1) } - local final fun foo(x: R|kotlin/Function1|, y: R|kotlin/String|): R|kotlin/Unit| { + local final fun foo(x: R|(kotlin/String) -> kotlin/Int|, y: R|kotlin/String|): R|kotlin/Unit| { } R|/foo|(::R|/bar|, Int(1)) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerCandidates.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerCandidates.txt index f96d6585f4e..049d0aa3d13 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerCandidates.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerCandidates.txt @@ -1,5 +1,5 @@ FILE: manyInnerCandidates.kt - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } public final fun bar(y: R|kotlin/Any|): R|kotlin/Int| { ^bar Int(1) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerManyOuterCandidates.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerManyOuterCandidates.txt index bca7c51c845..9da1a04edcc 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerManyOuterCandidates.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnerManyOuterCandidates.txt @@ -1,7 +1,7 @@ FILE: manyInnerManyOuterCandidates.kt - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo(x: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun foo(x: R|() -> kotlin/Int|): R|kotlin/Unit| { } public final fun bar(): R|kotlin/Int| { ^bar Int(1) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt index 1447c09b482..38a5da03347 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt @@ -1,7 +1,7 @@ FILE: manyInnermanyOuterCandidatesAmbiguity.kt - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo(x: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun foo(x: R|() -> kotlin/Int|): R|kotlin/Unit| { } public final fun bar(): R|kotlin/Int| { ^bar Int(1) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyOuterCandidates.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyOuterCandidates.txt index fe57e04fc4a..fb698bb9710 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyOuterCandidates.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyOuterCandidates.txt @@ -1,7 +1,7 @@ FILE: manyOuterCandidates.kt - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo(x: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun foo(x: R|() -> kotlin/Int|): R|kotlin/Unit| { } public final fun bar(): R|kotlin/Int| { ^bar Int(1) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/properties.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/properties.txt index ac2731445e7..0424ade1338 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/properties.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/properties.txt @@ -14,13 +14,13 @@ FILE: properties.kt public get(): R|kotlin/Int| { ^ Int(1) } - public final fun foo1(x: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun foo1(x: R|() -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo2(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo2(x: R|(A) -> kotlin/Int|): R|kotlin/Unit| { } - public final fun foo3(x: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun foo3(x: R|() -> R|): R|kotlin/Unit| { } - public final fun foo4(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo4(x: R|(T) -> R|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { R|/foo1|(::R|/bar|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleClassReceiver.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleClassReceiver.txt index 6367d064cfa..dbf42c90b5b 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleClassReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleClassReceiver.txt @@ -8,7 +8,7 @@ FILE: simpleClassReceiver.kt } } - public final fun foo(x: R|kotlin/Function2|): R|kotlin/Unit| { + public final fun foo(x: R|(A, kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { R|/foo|(Q|A|::R|/A.bar|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleExpressionReceiver.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleExpressionReceiver.txt index 9a0613edc5b..5208a816ee6 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleExpressionReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleExpressionReceiver.txt @@ -8,7 +8,7 @@ FILE: simpleExpressionReceiver.kt } } - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { lval a: R|A| = R|/A.A|() diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleNoReceiver.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleNoReceiver.txt index 6d657c9c61b..8b03259bc40 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleNoReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/simpleNoReceiver.txt @@ -1,5 +1,5 @@ FILE: simpleNoReceiver.kt - public final fun foo(x: R|kotlin/Function1|): R|kotlin/Unit| { + public final fun foo(x: R|(kotlin/String) -> kotlin/Int|): R|kotlin/Unit| { } public final fun bar(x: R|kotlin/String|): R|kotlin/Int| { } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt index 88bafc01a88..e4bb07e37e1 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt @@ -33,7 +33,7 @@ FILE: callsInPlace.kt } ) } - public final inline fun myRun(block1: R|kotlin/Function0|, block2: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun myRun(block1: R|() -> kotlin/Unit|, block2: R|() -> kotlin/Unit|): R|kotlin/Unit| { R|/block1|.R|FakeOverride|() R|/block2|.R|FakeOverride|() } @@ -55,7 +55,7 @@ FILE: callsInPlace.kt } ) } - public final fun myDummyRun(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun myDummyRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final fun test_8(): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/functionX.txt b/compiler/fir/resolve/testData/resolve/stdlib/functionX.txt index 46f5700a8d5..6e210fa0409 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/functionX.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/functionX.txt @@ -4,12 +4,12 @@ FILE: functionX.kt } public get(): R|kotlin/jvm/functions/Function0| - public final val y: R|kotlin/Function1| = fun (it: R|kotlin/String|): R|kotlin/String| { + public final val y: R|(kotlin/String) -> kotlin/String| = fun (it: R|kotlin/String|): R|kotlin/String| { R|/it| } - public get(): R|kotlin/Function1| - public final class MyFunction : R|kotlin/Function2| { + public get(): R|(kotlin/String) -> kotlin/String| + public final class MyFunction : R|(kotlin/Int, kotlin/String) -> kotlin/Unit| { public constructor(): R|MyFunction| { super() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/FunctionTypeInJava.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/FunctionTypeInJava.txt index 606141f70ec..ba3e88bc745 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/FunctionTypeInJava.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/FunctionTypeInJava.txt @@ -12,7 +12,7 @@ FILE: main.kt R|/it|.R|kotlin/Int.plus|(Int(3)).R|kotlin/Any.toString|() } ) - lval y: R|kotlin/Function1| = fun (x: R|kotlin/Int|): R|kotlin/String| { + lval y: R|(kotlin/Int) -> kotlin/String| = fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Any.toString|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt b/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt index 72876a2221d..63206c87984 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt @@ -11,6 +11,6 @@ FILE: mapList.kt } ) } - public final inline fun R|T|.applyX(block: @R|kotlin/ExtensionFunctionType|() R|kotlin/Function1|): R|T| { + public final inline fun R|T|.applyX(block: R|T.() -> kotlin/Unit|): R|T| { R|kotlin/TODO|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt b/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt index f616d969d6d..59077492b15 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt @@ -1,6 +1,6 @@ FILE: recursiveBug.kt public final class Foo : R|kotlin/Any| { - public constructor(name: R|kotlin/Function0|): R|Foo| { + public constructor(name: R|() -> kotlin/String|): R|Foo| { super() } @@ -14,7 +14,7 @@ FILE: recursiveBug.kt public get(): R|kotlin/Int| } - public final fun bar(name: R|kotlin/Function0|): R|kotlin/Unit| { + public final fun bar(name: R|() -> kotlin/String|): R|kotlin/Unit| { lval result: R|kotlin/String| = R|kotlin/run|( = run@fun (): R|kotlin/String| { R|/name|.R|FakeOverride|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/typeParameterDerived.txt b/compiler/fir/resolve/testData/resolve/stdlib/typeParameterDerived.txt index fe0692011f8..79e35c54b58 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/typeParameterDerived.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/typeParameterDerived.txt @@ -1,5 +1,5 @@ FILE: typeParameterDerived.kt - public final inline fun R|kotlin/collections/MutableMap|.getOrPut(key: R|K|, defaultValue: R|kotlin/Function1|, postCompute: R|kotlin/Function1|): R|V| { + public final inline fun R|kotlin/collections/MutableMap|.getOrPut(key: R|K|, defaultValue: R|(K) -> VA|, postCompute: R|(VA) -> kotlin/Unit|): R|V| { lval value: R|V| = this@R|kotlin/collections/Map|.R|FakeOverride|(R|/key|) ^getOrPut when () { ==(R|/value|, Null(null)) -> { diff --git a/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt b/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt index 460c0a93171..60bddc99304 100644 --- a/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt @@ -1,5 +1,5 @@ FILE: whenAsReceiver.kt - public final fun R|T|.also(block: R|kotlin/Function0|): R|R| { + public final fun R|T|.also(block: R|() -> R|): R|R| { ^also when (lval : R|kotlin/Nothing?| = Null(null)) { ==($subj$, Null(null)) -> { throw #() diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 13cc794a367..e7b21c896d6 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -5,6 +5,8 @@ package org.jetbrains.kotlin.fir +import org.jetbrains.kotlin.builtins.functions.BuiltInFictitiousFunctionClassFactory +import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget @@ -736,13 +738,27 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { } override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { - resolvedTypeRef.annotations.renderAnnotations() + val kind = resolvedTypeRef.functionTypeKind + val annotations = if (kind.withPrettyRender()) { + resolvedTypeRef.annotations.dropExtensionFunctionAnnotation() + } else { + resolvedTypeRef.annotations + } + annotations.renderAnnotations() print("R|") val coneType = resolvedTypeRef.type - print(coneType.render()) + print(coneType.renderFunctionType(kind, resolvedTypeRef.isExtensionFunctionType())) print("|") } + private val FirResolvedTypeRef.functionTypeKind: FunctionClassDescriptor.Kind? + get() { + val classId = (type as? ConeClassLikeType)?.lookupTag?.classId ?: return null + return BuiltInFictitiousFunctionClassFactory.getFunctionalClassKind( + classId.shortClassName.asString(), classId.packageFqName + ) + } + override fun visitUserTypeRef(userTypeRef: FirUserTypeRef) { userTypeRef.annotations.renderAnnotations() for ((index, qualifier) in userTypeRef.qualifier.withIndex()) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt index 0d827aac5c4..2d2cfa1618e 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt @@ -5,6 +5,8 @@ package org.jetbrains.kotlin.fir.types +import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef import org.jetbrains.kotlin.name.ClassId @@ -32,4 +34,26 @@ val FirFunctionTypeRef.parametersCount: Int get() = if (receiverTypeRef != null) valueParameters.size + 1 else - valueParameters.size \ No newline at end of file + valueParameters.size + +const val EXTENSION_FUNCTION_ANNOTATION = "kotlin/ExtensionFunctionType" + +fun FirTypeRef.isExtensionFunctionType(): Boolean { + return annotations.any { + it.isExtensionFunctionAnnotationCall + } +} + +val FirAnnotationCall.isExtensionFunctionAnnotationCall: Boolean + get() = (this as? FirAnnotationCall)?.let { + (it.annotationTypeRef as? FirResolvedTypeRef)?.let { + (it.type as? ConeClassLikeType)?.let { + it.lookupTag.classId.asString() == EXTENSION_FUNCTION_ANNOTATION + } + } + } == true + + +fun List.dropExtensionFunctionAnnotation(): List { + return filterNot { it.isExtensionFunctionAnnotationCall } +} \ No newline at end of file