KT-15878 Extension shadowed by member shouldn't be reported for infix/operator extensions when member is non-infix/operator
This commit is contained in:
@@ -91,6 +91,7 @@ class ShadowedExtensionChecker(val typeSpecificityComparator: TypeSpecificityCom
|
||||
if (extension.valueParameters.size != member.valueParameters.size) return false
|
||||
if (extension.varargParameterPosition() != member.varargParameterPosition()) return false
|
||||
if (extension.isOperator && !member.isOperator) return false
|
||||
if (extension.isInfix && !member.isInfix) return false
|
||||
|
||||
val extensionSignature = FlatSignature.createForPossiblyShadowedExtension(extension)
|
||||
val memberSignature = FlatSignature.createFromCallableDescriptor(member)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
infix fun Int.<!EXTENSION_SHADOWED_BY_MEMBER!>compareTo<!>(<!UNUSED_PARAMETER!>o<!>: Int) = 0
|
||||
infix fun Int.compareTo(<!UNUSED_PARAMETER!>o<!>: Int) = 0
|
||||
|
||||
fun foo(a: Number): Int {
|
||||
val result = (a as Int) compareTo <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
interface IFoo {
|
||||
fun foo(i: Int): Int
|
||||
infix fun bar(i: Int): Int
|
||||
}
|
||||
|
||||
infix fun IFoo.foo(i: Int) = i
|
||||
infix fun IFoo.<!EXTENSION_SHADOWED_BY_MEMBER!>bar<!>(i: Int) = i
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public infix fun IFoo.bar(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public infix fun IFoo.foo(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
|
||||
public interface IFoo {
|
||||
public abstract infix fun bar(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun foo(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
interface Test {
|
||||
fun invoke()
|
||||
operator fun invoke(i: Int): Int
|
||||
}
|
||||
|
||||
operator fun Test.invoke() {}
|
||||
operator fun Test.invoke() {}
|
||||
operator fun Test.<!EXTENSION_SHADOWED_BY_MEMBER!>invoke<!>(i: Int) = i
|
||||
+2
@@ -1,10 +1,12 @@
|
||||
package
|
||||
|
||||
public operator fun Test.invoke(): kotlin.Unit
|
||||
public operator fun Test.invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
|
||||
public interface Test {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun invoke(): kotlin.Unit
|
||||
public abstract operator fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@@ -16035,6 +16035,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("infixExtensionVsNonInfixMember.kt")
|
||||
public void testInfixExtensionVsNonInfixMember() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/infixExtensionVsNonInfixMember.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localExtensionShadowedByMember.kt")
|
||||
public void testLocalExtensionShadowedByMember() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.kt");
|
||||
|
||||
Reference in New Issue
Block a user