fix check for ambiguous parameter names for overriding methods
This commit is contained in:
+3
-3
@@ -22,8 +22,7 @@ import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
@@ -164,7 +163,8 @@ public class ValueArgumentsToParametersMapper {
|
||||
));
|
||||
}
|
||||
|
||||
if (candidate.hasStableParameterNames() && nameReference != null && valueParameterDescriptor != null) {
|
||||
if (candidate.hasStableParameterNames() && nameReference != null && valueParameterDescriptor != null &&
|
||||
candidate instanceof CallableMemberDescriptor && ((CallableMemberDescriptor)candidate).getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
for (ValueParameterDescriptor parameterFromSuperclass : valueParameterDescriptor.getOverriddenDescriptors()) {
|
||||
if (OverrideResolver.shouldReportParameterNameOverrideWarning(valueParameterDescriptor, parameterFromSuperclass)) {
|
||||
report(NAME_FOR_AMBIGUOUS_PARAMETER.on(nameReference));
|
||||
|
||||
+6
-2
@@ -13,6 +13,10 @@ interface D : C {
|
||||
override fun foo(<!PARAMETER_NAME_CHANGED_ON_OVERRIDE!>d1<!>: Int, <!PARAMETER_NAME_CHANGED_ON_OVERRIDE!>d2<!>: Double)
|
||||
}
|
||||
|
||||
fun test(d: D) {
|
||||
d.foo(<!NAME_FOR_AMBIGUOUS_PARAMETER!>d1<!> = 1, <!NAME_FOR_AMBIGUOUS_PARAMETER!>d2<!> = 1.0)
|
||||
fun test1(d: D) {
|
||||
d.foo(d1 = 1, d2 = 1.0)
|
||||
}
|
||||
|
||||
fun test2(c: C) {
|
||||
c.foo(<!NAME_FOR_AMBIGUOUS_PARAMETER!>b1<!> = 1, <!NAME_FOR_AMBIGUOUS_PARAMETER!>b2<!> = 1.0)
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ d: D): kotlin.Unit
|
||||
public fun test1(/*0*/ d: D): kotlin.Unit
|
||||
public fun test2(/*0*/ c: C): kotlin.Unit
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
Reference in New Issue
Block a user