[PL] Handle illegal fun interface SAM conversions
^KT-53967
This commit is contained in:
committed by
Space Team
parent
7f4d9ddde5
commit
1536bca1bb
+103
-6
@@ -1,3 +1,4 @@
|
||||
|
||||
fun getClassToEnumFoo(): ClassToEnum.Foo = ClassToEnum.Foo()
|
||||
inline fun getClassToEnumFooInline(): ClassToEnum.Foo = ClassToEnum.Foo()
|
||||
fun getClassToEnumFooAsAny(): Any = ClassToEnum.Foo()
|
||||
@@ -378,12 +379,6 @@ fun getSumFromDataClass(): Int {
|
||||
return x + y
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceToInterface(): FunctionalInterfaceToInterface {
|
||||
val worker = FunctionalInterfaceToInterface { /* do some work */ }
|
||||
worker.work()
|
||||
return worker
|
||||
}
|
||||
|
||||
fun instantiationOfAbstractClass() {
|
||||
// Accessing uninitialized members of abstract class is an UB. We shall not allow instantiating
|
||||
// abstract classes except for from their direct inheritors.
|
||||
@@ -424,3 +419,105 @@ class StableInheritorOfClassThatUsesPrivateTopLevelClass : AbstractIterator<Stri
|
||||
fun testStableInheritorOfClassThatUsesPrivateTopLevelClass(): String = buildString {
|
||||
for (s in StableInheritorOfClassThatUsesPrivateTopLevelClass()) append(s)
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceToInterface(answer: Int): FunctionalInterfaceToInterface {
|
||||
val worker = FunctionalInterfaceToInterface { answer }
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceToInterfaceAsObject(answer: Int): FunctionalInterfaceToInterface {
|
||||
val worker = object : FunctionalInterfaceToInterface {
|
||||
override fun answer() = answer
|
||||
}
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceToInterfaceAnswer(answer: Int): Int {
|
||||
return getFunctionalInterfaceToInterface(answer).answer()
|
||||
}
|
||||
|
||||
fun interface FunctionalInterfaceWith0AbstractFunctions : XAnswerDefault
|
||||
fun interface FunctionalInterfaceWith1AbstractFunction : XAnswer, XFunction1Default, XFunction2Default, XProperty1Default, XProperty2Default
|
||||
fun interface FunctionalInterfaceWith2AbstractFunctions : XAnswer, XFunction1, XFunction2Default, XProperty1Default, XProperty2Default
|
||||
fun interface FunctionalInterfaceWith3AbstractFunctions : XAnswer, XFunction1, XFunction2, XProperty1Default, XProperty2Default
|
||||
fun interface FunctionalInterfaceWithAbstractProperty : XAnswer, XFunction1Default, XFunction2Default, XProperty1, XProperty2Default
|
||||
|
||||
fun getFunctionalInterfaceWith0AbstractFunctions(answer: Int): FunctionalInterfaceWith0AbstractFunctions {
|
||||
val worker = FunctionalInterfaceWith0AbstractFunctions { answer }
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith0AbstractFunctionsAsObject(answer: Int): FunctionalInterfaceWith0AbstractFunctions {
|
||||
val worker = object : FunctionalInterfaceWith0AbstractFunctions {
|
||||
override fun answer() = answer
|
||||
}
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith0AbstractFunctionsAnswer(answer: Int): Int {
|
||||
return getFunctionalInterfaceWith0AbstractFunctions(answer).answer()
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith1AbstractFunction(answer: Int): FunctionalInterfaceWith1AbstractFunction {
|
||||
val worker = FunctionalInterfaceWith1AbstractFunction { answer }
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith1AbstractFunctionAsObject(answer: Int): FunctionalInterfaceWith1AbstractFunction {
|
||||
val worker = object : FunctionalInterfaceWith1AbstractFunction {
|
||||
override fun answer() = answer
|
||||
}
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith1AbstractFunctionAnswer(answer: Int): Int {
|
||||
return getFunctionalInterfaceWith1AbstractFunction(answer).answer()
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith2AbstractFunctions(answer: Int): FunctionalInterfaceWith2AbstractFunctions {
|
||||
val worker = FunctionalInterfaceWith2AbstractFunctions { answer }
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith2AbstractFunctionsAsObject(answer: Int): FunctionalInterfaceWith2AbstractFunctions {
|
||||
val worker = object : FunctionalInterfaceWith2AbstractFunctions {
|
||||
override fun answer() = answer
|
||||
}
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith2AbstractFunctionsAnswer(answer: Int): Int {
|
||||
return getFunctionalInterfaceWith2AbstractFunctions(answer).answer()
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith3AbstractFunctions(answer: Int): FunctionalInterfaceWith3AbstractFunctions {
|
||||
val worker = FunctionalInterfaceWith3AbstractFunctions { answer }
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith3AbstractFunctionsAsObject(answer: Int): FunctionalInterfaceWith3AbstractFunctions {
|
||||
val worker = object : FunctionalInterfaceWith3AbstractFunctions {
|
||||
override fun answer() = answer
|
||||
}
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWith3AbstractFunctionsAnswer(answer: Int): Int {
|
||||
return getFunctionalInterfaceWith3AbstractFunctions(answer).answer()
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWithAbstractProperty(answer: Int): FunctionalInterfaceWithAbstractProperty {
|
||||
val worker = FunctionalInterfaceWithAbstractProperty { answer }
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWithAbstractPropertyAsObject(answer: Int): FunctionalInterfaceWithAbstractProperty {
|
||||
val worker = object : FunctionalInterfaceWithAbstractProperty {
|
||||
override fun answer() = answer
|
||||
}
|
||||
return worker
|
||||
}
|
||||
|
||||
fun getFunctionalInterfaceWithAbstractPropertyAnswer(answer: Int): Int {
|
||||
return getFunctionalInterfaceWithAbstractProperty(answer).answer()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user