Simplify function hierarchy in reflection

Get rid of all classes except kotlin.reflect.KFunction, which will be used to
represent all kinds of simple functions.

Lots of changes to test data are related to the fact that KFunction is not an
extension function (as opposed to KMemberFunction and KExtensionFunction who
were) and so a member or an extension function reference now requires all
arguments be passed to it in the parentheses, including receivers. This is
probably temporary until we support calling any function both as a free
function and as an extension. In JS, functions and extension functions are not
interchangeable, so tests on this behavior are removed until this is supported
This commit is contained in:
Alexander Udalov
2015-06-23 20:34:25 +03:00
parent 3549e1e035
commit c3b97e0668
113 changed files with 350 additions and 534 deletions
@@ -225,53 +225,35 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
@NotNull
public StackValue putInstanceOnStack(@NotNull final ExpressionCodegen codegen) {
return StackValue.operation(asmType, new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
if (isConst(closure)) {
v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor());
}
else {
v.anew(asmType);
v.dup();
return StackValue.operation(
functionReferenceTarget != null ? K_FUNCTION : asmType,
new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
if (isConst(closure)) {
v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor());
}
else {
v.anew(asmType);
v.dup();
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator);
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
}
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator);
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
}
if (functionReferenceTarget != null) {
equipFunctionReferenceWithReflection(v, functionReferenceTarget);
}
if (functionReferenceTarget != null) {
v.invokestatic(REFLECTION, "function", Type.getMethodDescriptor(K_FUNCTION, FUNCTION_REFERENCE), false);
}
return Unit.INSTANCE$;
}
});
return Unit.INSTANCE$;
}
}
);
}
private static void equipFunctionReferenceWithReflection(@NotNull InstructionAdapter v, @NotNull FunctionDescriptor target) {
DeclarationDescriptor container = target.getContainingDeclaration();
Type type;
if (container instanceof PackageFragmentDescriptor) {
type = target.getExtensionReceiverParameter() != null
? K_TOP_LEVEL_EXTENSION_FUNCTION
: K_TOP_LEVEL_FUNCTION;
}
else if (container instanceof ClassDescriptor) {
type = K_MEMBER_FUNCTION;
}
else {
type = K_LOCAL_FUNCTION;
}
Method method = method("function", K_FUNCTION, FUNCTION_REFERENCE);
v.invokestatic(REFLECTION, method.getName(), method.getDescriptor(), false);
StackValue.coerce(K_FUNCTION, type, v);
}
private void generateConstInstance() {
MethodVisitor mv = v.newMethod(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_SYNTHETIC, "<clinit>", "()V", null, ArrayUtil.EMPTY_STRING_ARRAY);
MethodVisitor mv = v.newMethod(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_SYNTHETIC, "<clinit>", "()V", null,
ArrayUtil.EMPTY_STRING_ARRAY);
InstructionAdapter iv = new InstructionAdapter(mv);
v.newField(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_FINAL | ACC_PUBLIC, JvmAbi.INSTANCE_FIELD, asmType.getDescriptor(),
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.codegen;
import kotlin.KotlinPackage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.state.GenerationState;
@@ -133,8 +134,14 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
}
private void computeAndSaveArguments(@NotNull List<? extends ValueArgument> fakeArguments, @NotNull ExpressionCodegen codegen) {
for (ValueParameterDescriptor parameter : callableDescriptor.getValueParameters()) {
ValueArgument fakeArgument = fakeArguments.get(parameter.getIndex());
int receivers = (referencedFunction.getDispatchReceiverParameter() != null ? 1 : 0) +
(referencedFunction.getExtensionReceiverParameter() != null ? 1 : 0);
List<ValueParameterDescriptor> parameters = KotlinPackage.drop(callableDescriptor.getValueParameters(), receivers);
for (int i = 0; i < parameters.size(); i++) {
ValueParameterDescriptor parameter = parameters.get(i);
ValueArgument fakeArgument = fakeArguments.get(i);
Type type = state.getTypeMapper().mapType(parameter);
int localIndex = codegen.myFrameMap.getIndex(parameter);
codegen.tempVariables.put(fakeArgument.getArgumentExpression(), StackValue.local(localIndex, type));
@@ -43,10 +43,6 @@ public class AsmTypes {
public static final Type K_DECLARATION_CONTAINER_TYPE = reflect("KDeclarationContainer");
public static final Type K_FUNCTION = reflect("KFunction");
public static final Type K_TOP_LEVEL_FUNCTION = reflect("KTopLevelFunction");
public static final Type K_MEMBER_FUNCTION = reflect("KMemberFunction");
public static final Type K_TOP_LEVEL_EXTENSION_FUNCTION = reflect("KTopLevelExtensionFunction");
public static final Type K_LOCAL_FUNCTION = reflect("KLocalFunction");
public static final Type K_MEMBER_PROPERTY_TYPE = reflect("KMemberProperty");
public static final Type K_MUTABLE_MEMBER_PROPERTY_TYPE = reflect("KMutableMemberProperty");
@@ -704,7 +704,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
boolean isExtension = extensionReceiver != null;
if (descriptor instanceof FunctionDescriptor) {
return createFunctionReferenceType(expression, context, (FunctionDescriptor) descriptor, receiverType, isExtension);
return createFunctionReferenceType(expression, context, (FunctionDescriptor) descriptor, receiverType);
}
else if (descriptor instanceof PropertyDescriptor) {
return createPropertyReferenceType(expression, context, (PropertyDescriptor) descriptor, receiverType, isExtension);
@@ -722,16 +722,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
@NotNull JetCallableReferenceExpression expression,
@NotNull ExpressionTypingContext context,
@NotNull FunctionDescriptor descriptor,
@Nullable JetType receiverType,
boolean isExtension
@Nullable JetType receiverType
) {
//noinspection ConstantConditions
JetType type = components.reflectionTypes.getKFunctionType(
Annotations.EMPTY,
receiverType,
getValueParametersTypes(descriptor.getValueParameters()),
descriptor.getReturnType(),
isExtension
descriptor.getReturnType()
);
AnonymousFunctionDescriptor functionDescriptor = new AnonymousFunctionDescriptor(
@@ -1,9 +1,9 @@
import kotlin.jvm.functions.Function2;
import kotlin.reflect.KMemberFunction;
import kotlin.reflect.KFunction;
public class J {
public static String go() {
KMemberFunction<K, String> fun = K.Companion.getRef();
KFunction<String> fun = K.Companion.getRef();
Object result = ((Function2) fun).invoke(new K(), "KO");
return (String) result;
}
@@ -6,4 +6,4 @@ class B : A() {
override fun foo() = "OK"
}
fun box(): String = B().(A::foo)()
fun box(): String = (A::foo)(B())
@@ -1,5 +1,5 @@
fun box(): String {
if (true.(Boolean::not)() != false) return "Fail 1"
if (false.(Boolean::not)() != true) return "Fail 2"
if ((Boolean::not)(true) != false) return "Fail 1"
if ((Boolean::not)(false) != true) return "Fail 2"
return "OK"
}
@@ -1,7 +1,7 @@
class A {
fun foo(k: Int) = k
fun result() = this.(::foo)(111)
fun result() = (::foo)(this, 111)
}
fun box(): String {
@@ -3,7 +3,7 @@ class A {
fun k(k: Int) = k
}
fun A.foo() = this.(::o)() + this.(A::k)(222)
fun A.foo() = (::o)(this) + (A::k)(this, 222)
fun box(): String {
val result = A().foo()
@@ -4,5 +4,5 @@ class A {
fun box(): String {
val x = A::foo
return A().x()
return x(A())
}
@@ -4,5 +4,5 @@ class A {
fun box(): String {
val x = A::foo
return A().x("OK")
return x(A(), "OK")
}
@@ -9,6 +9,6 @@ class A {
fun box(): String {
val a = A()
val x = A::foo
a.x()
x(a)
return a.result
}
@@ -9,6 +9,6 @@ class A {
fun box(): String {
val a = A()
val x = A::foo
a.x("OK")
x(a, "OK")
return a.result
}
@@ -3,7 +3,7 @@ enum class E {
}
fun box(): String {
val i = E.I.(E::name)()
val i = (E::name)(E.I)
if (i != "I") return "Fail $i"
return "OK"
}
@@ -1,3 +1,3 @@
class A
fun box() = if (A().(A::equals)(A())) "Fail" else "OK"
fun box() = if ((A::equals)(A(), A())) "Fail" else "OK"
@@ -1,5 +1,5 @@
class A {
fun result() = this.(::foo)("OK")
fun result() = (::foo)(this, "OK")
}
fun A.foo(x: String) = x
@@ -1,6 +1,6 @@
class A
fun A.foo() = this.(A::bar)("OK")
fun A.foo() = (A::bar)(this, "OK")
fun A.bar(x: String) = x
@@ -4,5 +4,5 @@ fun A.foo() = "OK"
fun box(): String {
val x = A::foo
return A().x()
return x(A())
}
@@ -4,5 +4,5 @@ fun A.foo(result: String) = result
fun box(): String {
val x = A::foo
return A().x("OK")
return x(A(), "OK")
}
@@ -9,6 +9,6 @@ fun A.foo() {
fun box(): String {
val a = A()
val x = A::foo
a.x()
x(a)
return a.result
}
@@ -9,6 +9,6 @@ fun A.foo(newResult: String) {
fun box(): String {
val a = A()
val x = A::foo
a.x("OK")
x(a, "OK")
return a.result
}
@@ -2,4 +2,4 @@ class A<T>(val t: T) {
fun foo(): T = t
}
fun box() = A("OK").(A<String>::foo)()
fun box() = (A<String>::foo)(A("OK"))
@@ -4,7 +4,7 @@ class A {
val k = 222
}
fun result() = this.(A::Inner)().o + this.(::Inner)().k
fun result() = (A::Inner)(this).o + (::Inner)(this).k
}
fun box(): String {
@@ -5,7 +5,7 @@ class A {
}
}
fun A.foo() = this.(A::Inner)().o + this.(::Inner)().k
fun A.foo() = (A::Inner)(this).o + (::Inner)(this).k
fun box(): String {
val result = A().foo()
@@ -6,7 +6,7 @@ class A {
}
fun box(): String {
val result = (::A)().(A::Inner)().o + A().(A::Inner)().k
val result = (A::Inner)((::A)()).o + (A::Inner)(A()).k
if (result != 333) return "Fail $result"
return "OK"
}
@@ -3,7 +3,7 @@ class A {
}
fun box(): String {
val result = (::A)().(A::Inner)(111).result + A().(A::Inner)(222).result
val result = (A::Inner)((::A)(), 111).result + (A::Inner)(A(), 222).result
if (result != 333) return "Fail $result"
return "OK"
}
@@ -8,5 +8,5 @@ class Outer {
fun box(): String {
val f = Outer.Inner::foo
return Outer().Inner().f()
return f(Outer().Inner())
}
@@ -4,5 +4,5 @@ fun box(): String {
}
val ref = Local::foo
return Local().ref()
return ref(Local())
}
@@ -7,5 +7,5 @@ enum class E : Named {
}
fun box(): String {
return E.OK.(Named::name)()
return (Named::name)(E.OK)
}
@@ -2,5 +2,5 @@ class A
fun box(): String {
fun A.foo() = "OK"
return A().(A::foo)()
return (A::foo)(A())
}
@@ -1,5 +1,5 @@
fun box(): String {
class A
fun A.foo() = "OK"
return (::A)().(A::foo)()
return (A::foo)((::A)())
}
@@ -1,4 +1,4 @@
fun box(): String {
fun Int.is42With(that: Int) = this + 2 * that == 42
return if (16.(Int::is42With)(13)) "OK" else "Fail"
return if ((Int::is42With)(16, 13)) "OK" else "Fail"
}
@@ -6,6 +6,6 @@ fun box(): String {
fun A.ext() { result = "OK" }
val f = A::ext
A().f()
f(A())
return result
}
@@ -4,5 +4,5 @@ fun box(): String {
}
val ref = Id<String>::invoke
return Id<String>().ref("OK")
return ref(Id<String>(), "OK")
}
@@ -7,5 +7,5 @@ fun box(): String {
val member = Local::foo
val instance = Local()
return instance.member()
return member(instance)
}
@@ -8,6 +8,6 @@ object A {
fun box(): String {
val x = A::foo
A.x()
x(A)
return A.result
}
@@ -8,6 +8,6 @@ object A {
fun box(): String {
val x = A::foo
A.x("OK")
x(A, "OK")
return A.result
}
@@ -1,7 +1,7 @@
class A {
private fun foo() = "OK"
fun bar() = this.(::foo)()
fun bar() = (::foo)(this)
}
fun box() = A().bar()
@@ -4,7 +4,7 @@ interface T {
class B : T {
inner class C {
fun bar() = this@B.(::foo)()
fun bar() = (::foo)(this@B)
}
}
@@ -6,4 +6,4 @@ class B : A {
override fun foo() = "OK"
}
fun box() = B().(A::foo)()
fun box() = (A::foo)(B())
@@ -28,15 +28,15 @@ object A {
}
fun box(): String {
if (A.(A::test1)() != "OK") return "fail 1"
if ((A::test1)(A) != "OK") return "fail 1"
if (A.(A::test2)() != "OK") return "fail 2"
if ((A::test2)(A) != "OK") return "fail 2"
if (A.(A::test3)() != "1OK") return "fail 3"
if ((A::test3)(A) != "1OK") return "fail 3"
if (A.(A::test4)() != "1OK") return "fail 4"
if ((A::test4)(A) != "1OK") return "fail 4"
if (((A::c).get(A)) != "OK") return "fail 5"
return "OK"
}
}
@@ -3,8 +3,8 @@ class Z{
fun a(s: Int) {}
fun b() {
Z().(Z::a)(1)
(Z::a)(Z(), 1)
}
}
// 1 invoke \(LZ;I\)V
// 1 invoke \(LZ;I\)V
@@ -5,5 +5,5 @@ open class A {
}
fun test() {
A.B.(A::foo)()
}
(A::foo)(A.B)
}
@@ -22,7 +22,7 @@ fun main() {
val y = first.A::bar
val z = A::baz
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
}
@@ -14,7 +14,7 @@ fun A.baz() {}
package other
import kotlin.reflect.KExtensionFunction0
import kotlin.reflect.KFunction1
import first.A
import first.foo
@@ -24,5 +24,5 @@ fun main() {
first.A::<!UNRESOLVED_REFERENCE!>bar<!>
A::<!UNRESOLVED_REFERENCE!>baz<!>
checkSubtype<KExtensionFunction0<A, Unit>>(x)
}
checkSubtype<KFunction1<A, Unit>>(x)
}
@@ -8,9 +8,9 @@ class A {
val y = ::bar
val z = ::baz
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
}
}
@@ -9,9 +9,9 @@ fun A.main() {
val y = ::bar
val z = ::baz
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
}
fun A.foo() {}
@@ -10,9 +10,9 @@ class A {
val y = ::bar
val z = ::baz
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
}
}
@@ -13,11 +13,11 @@ fun main() {
val y = A::bar
val z = A::baz
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
checkSubtype<KExtensionFunction<A, Unit>>(x)
checkSubtype<KExtensionFunction<A, Unit>>(y)
checkSubtype<KExtensionFunction<A, String>>(z)
checkSubtype<KFunction<Unit>>(x)
checkSubtype<KFunction<Unit>>(y)
checkSubtype<KFunction<String>>(z)
}
@@ -8,5 +8,5 @@ class A {
fun A?.foo() {}
val f: KMemberFunction0<A, Unit> = A::foo
val g: KExtensionFunction0<A, Unit> = A?::foo
val f: KFunction1<A, Unit> = A::foo
val g: KFunction1<A, Unit> = A?::foo
@@ -1,7 +1,7 @@
package
internal val f: kotlin.reflect.KMemberFunction0<A, kotlin.Unit>
internal val g: kotlin.reflect.KExtensionFunction0<A, kotlin.Unit>
internal val f: kotlin.reflect.KFunction1<A, kotlin.Unit>
internal val g: kotlin.reflect.KFunction1<A, kotlin.Unit>
internal fun A?.foo(): kotlin.Unit
internal final class A {
@@ -1,6 +1,6 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberFunction0
import kotlin.reflect.KFunction1
class A<T>(val t: T) {
fun foo(): T = t
@@ -9,5 +9,5 @@ class A<T>(val t: T) {
fun bar() {
val x = A<String>::foo
checkSubtype<KMemberFunction0<A<String>, String>>(x)
checkSubtype<KFunction1<A<String>, String>>(x)
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KMemberFunction0
import kotlin.reflect.KFunction1
class A {
inner class Inner
@@ -9,8 +9,8 @@ class A {
val x = ::Inner
val y = A::Inner
checkSubtype<KMemberFunction0<A, A.Inner>>(x)
checkSubtype<KMemberFunction0<A, Inner>>(y)
checkSubtype<KFunction1<A, A.Inner>>(x)
checkSubtype<KFunction1<A, Inner>>(y)
}
companion object {
@@ -18,7 +18,7 @@ class A {
::<!INACCESSIBLE_OUTER_CLASS_EXPRESSION!>Inner<!>
val y = A::Inner
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
checkSubtype<KFunction1<A, A.Inner>>(y)
}
}
}
@@ -28,6 +28,6 @@ class B {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
checkSubtype<KFunction1<A, A.Inner>>(y)
}
}
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KMemberFunction0
import kotlin.reflect.KFunction1
class A {
inner class Inner
@@ -10,13 +10,13 @@ fun A.main() {
val x = ::Inner
val y = A::Inner
checkSubtype<KMemberFunction0<A, A.Inner>>(x)
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
checkSubtype<KFunction1<A, A.Inner>>(x)
checkSubtype<KFunction1<A, A.Inner>>(y)
}
fun Int.main() {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
}
checkSubtype<KFunction1<A, A.Inner>>(y)
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KMemberFunction0
import kotlin.reflect.KFunction1
class A {
inner class Inner
@@ -10,5 +10,5 @@ fun main() {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
}
checkSubtype<KFunction1<A, A.Inner>>(y)
}
@@ -9,10 +9,10 @@ class D {
// FILE: b.kt
import kotlin.reflect.KMemberFunction0
import kotlin.reflect.KFunction1
fun main() {
val x = a.b.c.D::foo
checkSubtype<KMemberFunction0<a.b.c.D, Int>>(x)
checkSubtype<KFunction1<a.b.c.D, Int>>(x)
}
@@ -9,10 +9,10 @@ class D<E, F> {
// FILE: b.kt
import kotlin.reflect.KMemberFunction2
import kotlin.reflect.KFunction3
fun main() {
val x = a.b.c.D<String, Int>::foo
checkSubtype<KMemberFunction2<a.b.c.D<String, Int>, String, Int, a.b.c.D<String, Int>>>(x)
checkSubtype<KFunction3<a.b.c.D<String, Int>, String, Int, a.b.c.D<String, Int>>>(x)
}
@@ -12,8 +12,8 @@ class A {
val y = ::bar
val z = ::baz
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
}
}
@@ -13,7 +13,7 @@ fun A.main() {
val y = ::bar
val z = ::baz
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
}
@@ -14,8 +14,8 @@ class B {
val y = ::bar
val z = ::baz
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
}
}
@@ -13,11 +13,11 @@ fun main() {
val y = A::bar
val z = A::baz
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
checkSubtype<KFunction1<A, Unit>>(x)
checkSubtype<KFunction2<A, Int, Unit>>(y)
checkSubtype<KFunction1<A, String>>(z)
checkSubtype<KMemberFunction<A, Unit>>(x)
checkSubtype<KMemberFunction<A, Unit>>(y)
checkSubtype<KMemberFunction<A, String>>(z)
checkSubtype<KFunction<Unit>>(x)
checkSubtype<KFunction<Unit>>(y)
checkSubtype<KFunction<String>>(z)
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberFunction0
import kotlin.reflect.KFunction1
class A {
fun foo() = 42
@@ -11,5 +11,5 @@ fun A.foo() {}
fun main() {
val x = A::foo
checkSubtype<KMemberFunction0<A, Int>>(x)
checkSubtype<KFunction1<A, Int>>(x)
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberFunction0
import kotlin.reflect.KFunction1
fun foo() {}
@@ -10,6 +10,6 @@ class A {
fun main() {
val x = ::foo
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KFunction1<A, Unit>>(x)
}
}
@@ -25,6 +25,6 @@ fun main() {
val z = AA::bazbaz
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KMemberFunction0<AA, Int>>(y)
checkSubtype<KExtensionFunction1<AA, String, Unit>>(z)
checkSubtype<KFunction1<AA, Int>>(y)
checkSubtype<KFunction2<AA, String, Unit>>(z)
}
@@ -5,7 +5,7 @@ internal fun block(): kotlin.Unit
internal fun expression(): UsefulClass
internal fun invoker(): kotlin.Unit
internal fun reflection(): kotlin.reflect.KFunction1<kotlin.Int, UsefulClass>
internal fun reflection2(): kotlin.reflect.KMemberFunction0<UsefulClass, kotlin.Unit>
internal fun reflection2(): kotlin.reflect.KFunction1<UsefulClass, kotlin.Unit>
kotlin.deprecated(value = "does nothing good") internal fun kotlin.Any.doNothing(): kotlin.String
internal final class Delegation {