FIR: make KFunctionX derived from KFunction

This commit is contained in:
Mikhail Glukhikh
2020-04-16 16:21:01 +03:00
parent 4bb6410ce3
commit 96d8b0bea3
25 changed files with 27 additions and 39 deletions
@@ -48,6 +48,7 @@ object StandardClassIds {
val KMutableProperty1 = "KMutableProperty1".reflectId()
val KProperty2 = "KProperty2".reflectId()
val KMutableProperty2 = "KMutableProperty2".reflectId()
val KFunction = "KFunction".reflectId()
val Comparable = "Comparable".baseId()
val Number = "Number".baseId()
@@ -227,20 +227,28 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider:
}
superTypeRefs += when (kind) {
FunctionClassDescriptor.Kind.Function ->
FunctionClassDescriptor.Kind.Function -> listOf(
buildResolvedTypeRef {
type = ConeClassLikeLookupTagImpl(StandardClassIds.Function)
.constructClassType(arrayOf(typeArguments.last().type), isNullable = false)
}
)
FunctionClassDescriptor.Kind.SuspendFunction ->
FunctionClassDescriptor.Kind.SuspendFunction -> listOf(
session.builtinTypes.anyType
)
FunctionClassDescriptor.Kind.KFunction ->
FunctionClassDescriptor.Kind.KFunction -> listOf(
buildResolvedTypeRef {
type = ConeClassLikeLookupTagImpl(StandardClassIds.KFunction)
.constructClassType(arrayOf(typeArguments.last().type), isNullable = false)
},
createSuperType(FunctionClassDescriptor.Kind.Function)
)
FunctionClassDescriptor.Kind.KSuspendFunction ->
FunctionClassDescriptor.Kind.KSuspendFunction -> listOf(
createSuperType(FunctionClassDescriptor.Kind.SuspendFunction)
)
}
addDeclaration(
buildSimpleFunction {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_SOURCEMAP_REMAPPING
fun box(): String {
@@ -1,5 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun box(): String {
fun OK() {}
@@ -1,5 +1,4 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
import kotlin.test.*
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TODO: investigate should it be ran for JS or not
// TARGET_BACKEND: JVM
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS, NATIVE
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR, JS, NATIVE
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_REFLECT
import kotlin.test.assertEquals
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_JDK6
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_JDK6
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
@@ -17,7 +17,7 @@ fun main() {
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(x)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(y)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<String>>(z)
checkSubtype<KFunction<Unit>>(x)
checkSubtype<KFunction<Unit>>(y)
checkSubtype<KFunction<String>>(z)
}
@@ -17,7 +17,7 @@ fun main() {
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(x)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(y)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<String>>(z)
checkSubtype<KFunction<Unit>>(x)
checkSubtype<KFunction<Unit>>(y)
checkSubtype<KFunction<String>>(z)
}
@@ -57,17 +57,17 @@ FILE fqName:<root> fileName:/funWithDefaultParametersAsKCallableStar.kt
BLOCK_BODY
FUN name:testDefaultsOnlyStar visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useKCallableStar]>#' type=IrErrorType
FUNCTION_REFERENCE 'public final fun defaultsOnly (x: kotlin.String): kotlin.Int declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Int> origin=null reflectionTarget=<same>
CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
fn: FUNCTION_REFERENCE 'public final fun defaultsOnly (x: kotlin.String): kotlin.Int declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Int> origin=null reflectionTarget=<same>
FUN name:testRegularAndDefaultsStar visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useKCallableStar]>#' type=IrErrorType
FUNCTION_REFERENCE 'public final fun regularAndDefaults (x1: kotlin.String, x2: kotlin.String): kotlin.Int declared in <root>' type=kotlin.reflect.KFunction1<kotlin.String, kotlin.Int> origin=null reflectionTarget=<same>
CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
fn: FUNCTION_REFERENCE 'public final fun regularAndDefaults (x1: kotlin.String, x2: kotlin.String): kotlin.Int declared in <root>' type=kotlin.reflect.KFunction1<kotlin.String, kotlin.Int> origin=null reflectionTarget=<same>
FUN name:testVarargsStar visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useKCallableStar]>#' type=IrErrorType
FUNCTION_REFERENCE 'public final fun varargs (vararg xs: kotlin.String): kotlin.Int declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Array<out kotlin.String>, kotlin.Int> origin=null reflectionTarget=<same>
CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
fn: FUNCTION_REFERENCE 'public final fun varargs (vararg xs: kotlin.String): kotlin.Int declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Array<out kotlin.String>, kotlin.Int> origin=null reflectionTarget=<same>
FUN name:testCtorStar visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useKCallableStar]>#' type=IrErrorType
FUNCTION_REFERENCE 'public constructor <init> (x: kotlin.String) [primary] declared in <root>.C' type=kotlin.reflect.KFunction0<<root>.C> origin=null reflectionTarget=<same>
CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
fn: FUNCTION_REFERENCE 'public constructor <init> (x: kotlin.String) [primary] declared in <root>.C' type=kotlin.reflect.KFunction0<<root>.C> origin=null reflectionTarget=<same>