diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/FunInterfaceConstructorReference.java b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/FunInterfaceConstructorReference.java new file mode 100644 index 00000000000..33ddabfdba4 --- /dev/null +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/FunInterfaceConstructorReference.java @@ -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: + *
+ * fun interface IFoo {
+ * fun foo()
+ * }
+ * val iFoo = IFoo { println("Hello!") } // calling fun interface constructor
+ * val iFooCtor = ::IFoo // callable reference to fun interface constructor
+ *
+ *
+ * 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");
+ }
+}
diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt
index df019f8d72e..8eb86926e6a 100644
--- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt
+++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt
@@ -3583,6 +3583,15 @@ public final class kotlin/jvm/internal/FloatSpreadBuilder : kotlin/jvm/internal/
public final fun toArray ()[F
}
+public class kotlin/jvm/internal/FunInterfaceConstructorReference : kotlin/jvm/internal/FunctionReference, java/io/Serializable {
+ public fun