[FIR] Fix creating overrides for functions with name same as renamed in JVM builtins

This commit is contained in:
Dmitriy Novozhilov
2021-02-26 18:09:11 +03:00
committed by TeamCityServer
parent 523d37b0f5
commit af79265f42
5 changed files with 11 additions and 17 deletions
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.load.java.SpecialGenericSignatures import org.jetbrains.kotlin.load.java.SpecialGenericSignatures
import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.ERASED_COLLECTION_PARAMETER_NAMES import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.ERASED_COLLECTION_PARAMETER_NAMES
import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.sameAsBuiltinMethodWithErasedValueParameters import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.sameAsBuiltinMethodWithErasedValueParameters
import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.sameAsRenamedInJvmBuiltin
import org.jetbrains.kotlin.load.java.getPropertyNamesCandidatesByAccessorName import org.jetbrains.kotlin.load.java.getPropertyNamesCandidatesByAccessorName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.AbstractTypeChecker
@@ -191,7 +192,7 @@ class JavaClassUseSiteMemberScope(
val renamedSpecialBuiltInNames = SpecialGenericSignatures.getBuiltinFunctionNamesByJvmName(name) val renamedSpecialBuiltInNames = SpecialGenericSignatures.getBuiltinFunctionNamesByJvmName(name)
if (potentialPropertyNames.isEmpty() && renamedSpecialBuiltInNames.isEmpty() && if (potentialPropertyNames.isEmpty() && renamedSpecialBuiltInNames.isEmpty() &&
!name.sameAsBuiltinMethodWithErasedValueParameters !name.sameAsBuiltinMethodWithErasedValueParameters && !name.sameAsRenamedInJvmBuiltin
) { ) {
return super.processFunctionsByName(name, processor) return super.processFunctionsByName(name, processor)
} }
@@ -387,10 +388,7 @@ class JavaClassUseSiteMemberScope(
superTypesScope.processOverriddenFunctions(this) { superTypesScope.processOverriddenFunctions(this) {
if (!it.isFromBuiltInClass(session)) return@processOverriddenFunctions ProcessorAction.NEXT if (!it.isFromBuiltInClass(session)) return@processOverriddenFunctions ProcessorAction.NEXT
if (SpecialGenericSignatures.SIGNATURE_TO_JVM_REPRESENTATION_NAME.containsKey( if (SpecialGenericSignatures.SIGNATURE_TO_JVM_REPRESENTATION_NAME.containsKey(it.fir.computeJvmSignature())) {
it.fir.computeJvmSignature()
)
) {
result = it result = it
return@processOverriddenFunctions ProcessorAction.STOP return@processOverriddenFunctions ProcessorAction.STOP
} }
@@ -1,6 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM // DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: STDLIB_COLLECTIONS // WASM_MUTE_REASON: STDLIB_COLLECTIONS
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME // KJS_WITH_FULL_RUNTIME
// KT-6042 java.lang.UnsupportedOperationException with ArrayList // KT-6042 java.lang.UnsupportedOperationException with ArrayList
// IGNORE_BACKEND: NATIVE // IGNORE_BACKEND: NATIVE
@@ -1,5 +1,4 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME // WITH_RUNTIME
// FILE: removeAtBridgeClashWithJava.kt // FILE: removeAtBridgeClashWithJava.kt
@@ -1,5 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
abstract class A1<T> : MutableList<T> { abstract class A1<T> : MutableList<T> {
override fun remove(x: T): Boolean = true override fun remove(x: T): Boolean = true
override fun removeAt(index: Int): T = null!! override fun removeAt(index: Int): T = null!!
+8 -8
View File
@@ -392,11 +392,11 @@ FILE fqName:<root> fileName:/MultiList.kt
public open fun sort (p0: java.util.Comparator<in E of java.util.ArrayList?>?): kotlin.Unit declared in java.util.ArrayList public open fun sort (p0: java.util.Comparator<in E of java.util.ArrayList?>?): kotlin.Unit declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
VALUE_PARAMETER name:p0 index:0 type:java.util.Comparator<in <root>.Some<T of <root>.SomeList>?>? VALUE_PARAMETER name:p0 index:0 type:java.util.Comparator<in <root>.Some<T of <root>.SomeList>?>?
FUN FAKE_OVERRIDE name:removeAt visibility:public modality:ABSTRACT <> ($this:kotlin.collections.MutableList<E of kotlin.collections.MutableList>, index:kotlin.Int) returnType:<root>.Some<T of <root>.SomeList>? [fake_override] FUN FAKE_OVERRIDE name:removeAt visibility:public modality:OPEN <> ($this:java.util.ArrayList<E of java.util.ArrayList>, p0:kotlin.Int) returnType:<root>.Some<T of <root>.SomeList>? [fake_override]
overridden: overridden:
public abstract fun removeAt (index: kotlin.Int): @[FlexibleNullability] E of java.util.ArrayList? [fake_override] declared in java.util.ArrayList public open fun removeAt (p0: kotlin.Int): E of java.util.ArrayList? declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:kotlin.collections.MutableList<E of kotlin.collections.MutableList> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
VALUE_PARAMETER name:index index:0 type:kotlin.Int VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
CLASS CLASS name:FinalList modality:FINAL visibility:public superTypes:[<root>.SomeList<kotlin.String>] CLASS CLASS name:FinalList modality:FINAL visibility:public superTypes:[<root>.SomeList<kotlin.String>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.FinalList $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.FinalList
CONSTRUCTOR visibility:public <> () returnType:<root>.FinalList [primary] CONSTRUCTOR visibility:public <> () returnType:<root>.FinalList [primary]
@@ -584,8 +584,8 @@ FILE fqName:<root> fileName:/MultiList.kt
public open fun sort (p0: java.util.Comparator<in <root>.Some<T of <root>.SomeList>?>?): kotlin.Unit [fake_override] declared in <root>.SomeList public open fun sort (p0: java.util.Comparator<in <root>.Some<T of <root>.SomeList>?>?): kotlin.Unit [fake_override] declared in <root>.SomeList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
VALUE_PARAMETER name:p0 index:0 type:java.util.Comparator<in <root>.Some<kotlin.String>?>? VALUE_PARAMETER name:p0 index:0 type:java.util.Comparator<in <root>.Some<kotlin.String>?>?
FUN FAKE_OVERRIDE name:removeAt visibility:public modality:ABSTRACT <> ($this:kotlin.collections.MutableList<E of kotlin.collections.MutableList>, index:kotlin.Int) returnType:<root>.Some<kotlin.String>? [fake_override] FUN FAKE_OVERRIDE name:removeAt visibility:public modality:OPEN <> ($this:java.util.ArrayList<E of java.util.ArrayList>, p0:kotlin.Int) returnType:<root>.Some<kotlin.String>? [fake_override]
overridden: overridden:
public abstract fun removeAt (index: kotlin.Int): <root>.Some<T of <root>.SomeList>? [fake_override] declared in <root>.SomeList public open fun removeAt (p0: kotlin.Int): <root>.Some<T of <root>.SomeList>? [fake_override] declared in <root>.SomeList
$this: VALUE_PARAMETER name:<this> type:kotlin.collections.MutableList<E of kotlin.collections.MutableList> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
VALUE_PARAMETER name:index index:0 type:kotlin.Int VALUE_PARAMETER name:p0 index:0 type:kotlin.Int