Compare return types when structurally comparing callables
This commit is contained in:
+2
-2
@@ -85,8 +85,8 @@ object DescriptorEquivalenceForOverrides {
|
||||
areTypeParametersEquivalent(d1, d2, {x, y -> x == a && y == b})
|
||||
}
|
||||
|
||||
return overridingUtil.isOverridableBy(a, b).getResult() == OverrideCompatibilityInfo.Result.OVERRIDABLE
|
||||
&& overridingUtil.isOverridableBy(b, a).getResult() == OverrideCompatibilityInfo.Result.OVERRIDABLE
|
||||
return overridingUtil.isOverridableByIncludingReturnType(a, b).getResult() == OverrideCompatibilityInfo.Result.OVERRIDABLE
|
||||
&& overridingUtil.isOverridableByIncludingReturnType(b, a).getResult() == OverrideCompatibilityInfo.Result.OVERRIDABLE
|
||||
|
||||
}
|
||||
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
||||
|
||||
// MODULE: m1
|
||||
// FILE: a.kt
|
||||
package p
|
||||
|
||||
public trait B<T> {
|
||||
public fun foo(): T
|
||||
}
|
||||
|
||||
// MODULE: m2(m1)
|
||||
// FILE: b.kt
|
||||
package p
|
||||
|
||||
public trait C<X> : B<X> {
|
||||
override fun foo(): X
|
||||
|
||||
}
|
||||
|
||||
// MODULE: m3
|
||||
// FILE: b.kt
|
||||
package p
|
||||
|
||||
public trait B<T> {
|
||||
public fun foo(): T
|
||||
}
|
||||
|
||||
// MODULE: m4(m3, m2)
|
||||
// FILE: c.kt
|
||||
import p.*
|
||||
|
||||
fun test(b: B<String>?) {
|
||||
if (b is C) {
|
||||
<!DEBUG_INFO_AUTOCAST!>b<!>?.foo()
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
||||
|
||||
// MODULE: m1
|
||||
// FILE: a.kt
|
||||
package p
|
||||
|
||||
public trait B {
|
||||
public fun getParent(): B?
|
||||
}
|
||||
|
||||
// MODULE: m2(m1)
|
||||
// FILE: b.kt
|
||||
package p
|
||||
|
||||
public trait C : B {
|
||||
override fun getParent(): B?
|
||||
|
||||
}
|
||||
|
||||
// MODULE: m3
|
||||
// FILE: b.kt
|
||||
package p
|
||||
|
||||
public trait B {
|
||||
public fun getParent(): Any?
|
||||
}
|
||||
|
||||
// MODULE: m4(m3, m2)
|
||||
// FILE: c.kt
|
||||
import p.*
|
||||
|
||||
fun test(b: B?) {
|
||||
if (b is C) {
|
||||
b?.<!OVERLOAD_RESOLUTION_AMBIGUITY!>getParent<!>()
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -31,6 +31,6 @@ import p.*
|
||||
|
||||
fun test(b: B?) {
|
||||
if (b is C) {
|
||||
<!DEBUG_INFO_AUTOCAST!>b<!>?.getParent()
|
||||
b?.<!OVERLOAD_RESOLUTION_AMBIGUITY!>getParent<!>()
|
||||
}
|
||||
}
|
||||
@@ -4797,11 +4797,21 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsNameMismatch.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classGenericsInReturnType.kt")
|
||||
public void testClassGenericsInReturnType() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInReturnType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classVsFunctionGenericsInParamsMismatch.kt")
|
||||
public void testClassVsFunctionGenericsInParamsMismatch() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classVsFunctionGenericsInParamsMismatch.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("covariantReturnTypes.kt")
|
||||
public void testCovariantReturnTypes() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/multimodule/duplicateMethod/covariantReturnTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differenceInParamNames.kt")
|
||||
public void testDifferenceInParamNames() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/multimodule/duplicateMethod/differenceInParamNames.kt");
|
||||
|
||||
Reference in New Issue
Block a user