KT-47939 FunInterfaceConstructorReference
This commit is contained in:
committed by
TeamCityServer
parent
2d088196ce
commit
d5da130d4b
+57
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.jvm.internal;
|
||||||
|
|
||||||
|
import kotlin.SinceKotlin;
|
||||||
|
import kotlin.reflect.KFunction;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Superclass for instances of functional interface constructor references:
|
||||||
|
* <pre>
|
||||||
|
* fun interface IFoo {
|
||||||
|
* fun foo()
|
||||||
|
* }
|
||||||
|
* val iFoo = IFoo { println("Hello!") } // calling fun interface constructor
|
||||||
|
* val iFooCtor = ::IFoo // callable reference to fun interface constructor
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* Doesn't support reflection yet.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"rawtypes", "WeakerAccess", "unused"})
|
||||||
|
@SinceKotlin(version = "1.7")
|
||||||
|
public class FunInterfaceConstructorReference extends FunctionReference implements Serializable {
|
||||||
|
private final Class funInterface;
|
||||||
|
|
||||||
|
public FunInterfaceConstructorReference(Class funInterface) {
|
||||||
|
super(1);
|
||||||
|
this.funInterface = funInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof FunInterfaceConstructorReference)) return false;
|
||||||
|
FunInterfaceConstructorReference other = (FunInterfaceConstructorReference) o;
|
||||||
|
return funInterface.equals(other.funInterface);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return funInterface.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "fun interface " + funInterface.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected KFunction getReflected() {
|
||||||
|
throw new UnsupportedOperationException("Functional interface constructor does not support reflection");
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -3583,6 +3583,15 @@ public final class kotlin/jvm/internal/FloatSpreadBuilder : kotlin/jvm/internal/
|
|||||||
public final fun toArray ()[F
|
public final fun toArray ()[F
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class kotlin/jvm/internal/FunInterfaceConstructorReference : kotlin/jvm/internal/FunctionReference, java/io/Serializable {
|
||||||
|
public fun <init> (Ljava/lang/Class;)V
|
||||||
|
public fun equals (Ljava/lang/Object;)Z
|
||||||
|
protected synthetic fun getReflected ()Lkotlin/reflect/KCallable;
|
||||||
|
protected fun getReflected ()Lkotlin/reflect/KFunction;
|
||||||
|
public fun hashCode ()I
|
||||||
|
public fun toString ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract interface class kotlin/jvm/internal/FunctionAdapter {
|
public abstract interface class kotlin/jvm/internal/FunctionAdapter {
|
||||||
public abstract fun getFunctionDelegate ()Lkotlin/Function;
|
public abstract fun getFunctionDelegate ()Lkotlin/Function;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user