[FIR] Properly match expect fun interfaces with java interfaces
This commit is contained in:
committed by
Space Team
parent
1418a2bcb8
commit
29afd0dc97
+6
-1
@@ -79,8 +79,13 @@ class FirExpectActualMatchingContext(
|
|||||||
get() = asSymbol().resolvedStatus.isInline
|
get() = asSymbol().resolvedStatus.isInline
|
||||||
override val RegularClassSymbolMarker.isValue: Boolean
|
override val RegularClassSymbolMarker.isValue: Boolean
|
||||||
get() = asSymbol().resolvedStatus.isInline
|
get() = asSymbol().resolvedStatus.isInline
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In this context java interfaces should be considered as not fun interface, so they will be later checked by [isNotSamInterface] function
|
||||||
|
*/
|
||||||
override val RegularClassSymbolMarker.isFun: Boolean
|
override val RegularClassSymbolMarker.isFun: Boolean
|
||||||
get() = asSymbol().resolvedStatus.isFun
|
get() = asSymbol().takeUnless { it.origin is FirDeclarationOrigin.Java }?.resolvedStatus?.isFun ?: false
|
||||||
|
|
||||||
override val ClassLikeSymbolMarker.typeParameters: List<TypeParameterSymbolMarker>
|
override val ClassLikeSymbolMarker.typeParameters: List<TypeParameterSymbolMarker>
|
||||||
get() = asSymbol().typeParameterSymbols
|
get() = asSymbol().typeParameterSymbols
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -367,7 +367,12 @@ internal abstract class IrExpectActualMatchingContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun RegularClassSymbolMarker.isNotSamInterface(): Boolean {
|
override fun RegularClassSymbolMarker.isNotSamInterface(): Boolean {
|
||||||
// TODO: is it correct for java classes?
|
/*
|
||||||
|
* This is incorrect for java classes (because all java interfaces are considered as fun interfaces),
|
||||||
|
* but it's fine to not to check if some java interfaces is really SAM or not, because if one
|
||||||
|
* tries to actualize `expect fun interface` with typealias to non-SAM java interface, frontend
|
||||||
|
* will report an error and IR matching won't be invoked
|
||||||
|
*/
|
||||||
return !asIr().isFun
|
return !asIr().isFun
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
@@ -25,8 +25,19 @@ expect fun interface F5 {
|
|||||||
fun run()
|
fun run()
|
||||||
}<!>
|
}<!>
|
||||||
|
|
||||||
|
expect fun interface F7 {
|
||||||
|
fun run()
|
||||||
|
}
|
||||||
|
|
||||||
// MODULE: m2-jvm()()(m1-common)
|
// MODULE: m2-jvm()()(m1-common)
|
||||||
|
|
||||||
|
// FILE: NotSam.java
|
||||||
|
public interface NotSam {
|
||||||
|
void run();
|
||||||
|
void somehtingElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
actual fun interface F1 {
|
actual fun interface F1 {
|
||||||
actual fun run()
|
actual fun run()
|
||||||
}
|
}
|
||||||
@@ -52,3 +63,5 @@ interface F6Typealias {
|
|||||||
}
|
}
|
||||||
|
|
||||||
<!ACTUAL_WITHOUT_EXPECT!>actual typealias F6 = F6Typealias<!>
|
<!ACTUAL_WITHOUT_EXPECT!>actual typealias F6 = F6Typealias<!>
|
||||||
|
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual typealias F7 = NotSam<!>
|
||||||
|
|||||||
+13
@@ -25,8 +25,19 @@ expect fun interface F6 {
|
|||||||
fun run()
|
fun run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect fun interface F7 {
|
||||||
|
fun run()
|
||||||
|
}
|
||||||
|
|
||||||
// MODULE: m2-jvm()()(m1-common)
|
// MODULE: m2-jvm()()(m1-common)
|
||||||
|
|
||||||
|
// FILE: NotSam.java
|
||||||
|
public interface NotSam {
|
||||||
|
void run();
|
||||||
|
void somehtingElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
actual fun interface F1 {
|
actual fun interface F1 {
|
||||||
actual fun run()
|
actual fun run()
|
||||||
}
|
}
|
||||||
@@ -52,3 +63,5 @@ interface F6Typealias {
|
|||||||
}
|
}
|
||||||
|
|
||||||
<!ACTUAL_WITHOUT_EXPECT!>actual<!> typealias F6 = F6Typealias
|
<!ACTUAL_WITHOUT_EXPECT!>actual<!> typealias F6 = F6Typealias
|
||||||
|
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual<!> typealias F7 = NotSam
|
||||||
|
|||||||
Reference in New Issue
Block a user