[FIR] Use Function<R> as super type for all FunctionNtypes
This commit is contained in:
+10
-2
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
@@ -250,18 +251,25 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider:
|
||||
}
|
||||
|
||||
val superTypes = when (kind) {
|
||||
FunctionClassDescriptor.Kind.Function ->
|
||||
listOf(
|
||||
FirResolvedTypeRefImpl(
|
||||
source = null,
|
||||
ConeClassLikeLookupTagImpl(StandardClassIds.Function)
|
||||
.constructClassType(arrayOf(typeArguments.last().type), isNullable = false)
|
||||
)
|
||||
)
|
||||
|
||||
FunctionClassDescriptor.Kind.Function,
|
||||
FunctionClassDescriptor.Kind.SuspendFunction ->
|
||||
listOf(session.builtinTypes.anyType)
|
||||
|
||||
FunctionClassDescriptor.Kind.KFunction ->
|
||||
listOf(createSuperType(FunctionClassDescriptor.Kind.Function))
|
||||
|
||||
FunctionClassDescriptor.Kind.KSuspendFunction ->
|
||||
listOf(createSuperType(FunctionClassDescriptor.Kind.SuspendFunction))
|
||||
}
|
||||
replaceSuperTypeRefs(superTypes)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fun takeAnyFun(function: Function<*>) {}
|
||||
|
||||
fun test(block: () -> Unit) {
|
||||
<!INAPPLICABLE_CANDIDATE!>takeAnyFun<!>(block)
|
||||
takeAnyFun(block)
|
||||
}
|
||||
+1
-1
@@ -2,5 +2,5 @@ FILE: functionAndFunctionN.kt
|
||||
public final fun takeAnyFun(function: R|kotlin/Function<*>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(block: R|() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
<Inapplicable(INAPPLICABLE): [/takeAnyFun]>#(R|<local>/block|)
|
||||
R|/takeAnyFun|(R|<local>/block|)
|
||||
}
|
||||
Generated
+5
-5
@@ -83,6 +83,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/factoryFunctionOverloads.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionAndFunctionN.kt")
|
||||
public void testFunctionAndFunctionN() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionX.kt")
|
||||
public void testFunctionX() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/functionX.kt");
|
||||
@@ -607,11 +612,6 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/delegateTypeMismatch.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionAndFunctionN.kt")
|
||||
public void testFunctionAndFunctionN() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inapplicableRemoveAll.kt")
|
||||
public void testInapplicableRemoveAll() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/inapplicableRemoveAll.kt");
|
||||
|
||||
Reference in New Issue
Block a user