[FIR] JvmMappedScope: don't add Java methods if Kotlin ones are here
This commit is contained in:
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.scopes.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
class JvmMappedScope(
|
||||
private val declaredMemberScope: FirScope,
|
||||
@@ -21,14 +22,23 @@ class JvmMappedScope(
|
||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||
val visibleMethods = signatures.visibleMethodSignaturesByName[name]
|
||||
?: return declaredMemberScope.processFunctionsByName(name, processor)
|
||||
|
||||
val declared = mutableListOf<FirNamedFunctionSymbol>()
|
||||
declaredMemberScope.processFunctionsByName(name) { symbol ->
|
||||
declared.addIfNotNull(symbol as FirNamedFunctionSymbol)
|
||||
processor(symbol)
|
||||
}
|
||||
|
||||
val declaredSignatures by lazy {
|
||||
declared.mapTo(mutableSetOf()) { it.fir.computeJvmDescriptorReplacingKotlinToJava() }
|
||||
}
|
||||
|
||||
javaMappedClassUseSiteScope.processFunctionsByName(name) { symbol ->
|
||||
val jvmSignature = symbol.fir.computeJvmDescriptorReplacingKotlinToJava()
|
||||
if (jvmSignature in visibleMethods) {
|
||||
if (jvmSignature in visibleMethods && jvmSignature !in declaredSignatures) {
|
||||
processor(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
declaredMemberScope.processFunctionsByName(name, processor)
|
||||
}
|
||||
|
||||
override fun processDirectOverriddenFunctionsWithBaseScope(
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
// SKIP_JDK6
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FULL_JDK
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ abstract class A : Map<Int, String>
|
||||
|
||||
fun foo(x: Map<Int, String>, a: A, b: java.util.HashMap<Int, String>) {
|
||||
x.getOrDefault(1, "")
|
||||
x.<!NONE_APPLICABLE!>getOrDefault<!>("", "")
|
||||
x.<!NONE_APPLICABLE!>getOrDefault<!>(1, 2)
|
||||
x.<!NONE_APPLICABLE!>getOrDefault<!>("", 2)
|
||||
x.<!INAPPLICABLE_CANDIDATE!>getOrDefault<!>("", "")
|
||||
x.<!INAPPLICABLE_CANDIDATE!>getOrDefault<!>(1, 2)
|
||||
x.<!INAPPLICABLE_CANDIDATE!>getOrDefault<!>("", 2)
|
||||
|
||||
a.getOrDefault(1, "")
|
||||
a.<!NONE_APPLICABLE!>getOrDefault<!>("", "")
|
||||
a.<!NONE_APPLICABLE!>getOrDefault<!>(1, 2)
|
||||
a.<!NONE_APPLICABLE!>getOrDefault<!>("", 2)
|
||||
a.<!INAPPLICABLE_CANDIDATE!>getOrDefault<!>("", "")
|
||||
a.<!INAPPLICABLE_CANDIDATE!>getOrDefault<!>(1, 2)
|
||||
a.<!INAPPLICABLE_CANDIDATE!>getOrDefault<!>("", 2)
|
||||
|
||||
b.getOrDefault(1, "")
|
||||
b.<!INAPPLICABLE_CANDIDATE!>getOrDefault<!>("", "")
|
||||
|
||||
Reference in New Issue
Block a user