[FE] Prohibit expect fun interface to have non-fun actual counterpart

In K1 .isFun is always false for Java classes, so extra check
is added for that. This is not needed for K2, because .isFun is
true for all Java classes. Here it is not necessary to check
that interface has only one method, because such check will be
done in the place where interface implementation is created.

^KT-39362 Fixed
This commit is contained in:
Roman Efremov
2023-04-04 16:02:39 +02:00
committed by Space Team
parent 59d126abc5
commit 456d3e0f42
12 changed files with 170 additions and 1 deletions
@@ -19,3 +19,11 @@ expect class C4<F>
expect abstract class ExtendsNumber : Number
expect fun interface FunInterface {
fun run()
}
expect fun interface FunInterface2 {
fun run()
}
@@ -19,3 +19,13 @@ actual typealias C4<F> = C4Impl<F>
class C4Impl<F : Number>
actual abstract class ExtendsNumber : Any()
actual interface FunInterface {
actual fun run()
}
interface FunInterface2Typealias {
fun run()
}
actual typealias FunInterface2 = FunInterface2Typealias
@@ -113,3 +113,15 @@ The following declaration is incompatible because some supertypes are missing in
actual abstract class ExtendsNumber : Any()
^
compiler/testData/multiplatform/incompatibleClasses/jvm.kt:23:1: error: actual interface 'FunInterface' has no corresponding expected declaration
The following declaration is incompatible because actual declaration for fun expect interface is not a functional interface:
public expect fun interface FunInterface
actual interface FunInterface {
^
compiler/testData/multiplatform/incompatibleClasses/jvm.kt:31:1: error: actual typealias 'FunInterface2' has no corresponding expected declaration
The following declaration is incompatible because actual declaration for fun expect interface is not a functional interface:
public expect fun interface FunInterface2
actual typealias FunInterface2 = FunInterface2Typealias
^