[FIR2IR] Fix check if interface is SAM

This commit is contained in:
simon.ogorodnik
2020-05-27 20:49:15 +03:00
parent aa5a5c954f
commit 8afbb4542b
5 changed files with 3 additions and 5 deletions
@@ -470,7 +470,8 @@ fun FirClass<*>.irOrigin(firProvider: FirProvider): IrDeclarationOrigin = when {
}
fun FirClass<*>.getSamIfAny(): FirSimpleFunction? =
declarations.filterIsInstance<FirSimpleFunction>().singleOrNull { it.modality == Modality.ABSTRACT }
declarations.filterIsInstance<FirSimpleFunction>()
.singleOrNull { it.modality == Modality.ABSTRACT && !it.isPublicInObject(checkOnlyName = true) }
val IrType.isSamType: Boolean
get() {
@@ -316,7 +316,7 @@ private fun FirRegularClass.hasMoreThenOneAbstractFunctionOrHasAbstractProperty(
// "methods that are members of I that do not have the same signature as any public instance method of the class Object"
// It means that if an interface declares `int hashCode()` then the method won't be taken into account when
// checking if the interface is SAM.
private fun FirSimpleFunction.isPublicInObject(checkOnlyName: Boolean): Boolean {
fun FirSimpleFunction.isPublicInObject(checkOnlyName: Boolean): Boolean {
if (name.asString() !in PUBLIC_METHOD_NAMES_IN_OBJECT) return false
if (checkOnlyName) return true
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME