K2: use intersection scope override checker also in intersection scope
In more details, we use either platform override checker (if we came from platform) or the combined intersection scope override checker at this place. Also this commit fixes various places around JavaOverrideChecker, allowing to apply it in intersection override checker properly: - don't consider return types in this place - apply JavaOverrideChecker if at least one candidate is from Java - compare type primitivity closer to K1 logic #KT-62554 Fixed Partially fixes KT-63242
This commit is contained in:
committed by
Space Team
parent
54d978ba86
commit
e42c1be354
-20
@@ -1,20 +0,0 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: C:foo
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface B {
|
||||
fun foo(x: Int) {}
|
||||
}
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class C<!> : A(), B
|
||||
|
||||
fun main() {
|
||||
C().foo(42)
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
C:
|
||||
[IntersectionOverride]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/Unit| from Use site scope of /C [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/Unit| from Java enhancement scope for /A [id: 1]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/Unit| from Use site scope of /B [id: 2]
|
||||
Vendored
+1
-1
@@ -11,5 +11,5 @@ FILE: main.kt
|
||||
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
R|/C.C|().R|/A.foo|(Int(42))
|
||||
R|/C.C|().R|/B.foo|(Int(42))
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: C:foo
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
C:
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/Unit| from Use site scope of /C [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/Unit| from Java enhancement scope for /A [id: 0]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/Unit| from Use site scope of /C [id: 0]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/Unit| from Use site scope of /B [id: 0]
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: D:foo
|
||||
// FILE: A.java
|
||||
|
||||
public class A<T> {
|
||||
public T foo(Integer x) {
|
||||
return "A";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface B {
|
||||
fun foo(x: Int) = "B"
|
||||
}
|
||||
|
||||
open class C : A<String>()
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class D<!> : C(), B
|
||||
|
||||
fun main() {
|
||||
D().foo(42)
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
D:
|
||||
[IntersectionOverride]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /C [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /A] for type C [id: 1]
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|ft<T & Any, T?>| from Java enhancement scope for /A [id: 2]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /B [id: 3]
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: D:foo
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
D:
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /D [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /C [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /A] for type C [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|ft<T & Any, T?>| from Java enhancement scope for /A [id: 1]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 0]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /B [id: 0]
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: D:foo
|
||||
// FILE: A.java
|
||||
|
||||
public class A<T> {
|
||||
public String foo(T x) {
|
||||
return "A";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public class C extends A<Integer> {}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface B {
|
||||
fun foo(x: Int) = "B"
|
||||
}
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class D<!> : C(), B
|
||||
|
||||
fun main() {
|
||||
D().foo(42)
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
D:
|
||||
[IntersectionOverride]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Java enhancement scope for /C [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /A] for type C [id: 1]
|
||||
[Enhancement]: public open fun foo(x: R|ft<T & Any, T?>|): R|kotlin/String!| from Java enhancement scope for /A [id: 2]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /B [id: 3]
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: D:foo
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
D:
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /D [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Java enhancement scope for /C [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /A] for type C [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|ft<T & Any, T?>|): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 0]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /B [id: 0]
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: D:foo
|
||||
// FILE: A.java
|
||||
|
||||
public class A<T> {
|
||||
public String foo(T x) {
|
||||
return "A";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface B {
|
||||
fun foo(x: Int) = "B"
|
||||
}
|
||||
|
||||
open class C : A<Int>()
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class D<!> : C(), B
|
||||
|
||||
fun main() {
|
||||
D().foo(42)
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
D:
|
||||
[IntersectionOverride]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /C [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /A] for type C [id: 1]
|
||||
[Enhancement]: public open fun foo(x: R|ft<T & Any, T?>|): R|kotlin/String!| from Java enhancement scope for /A [id: 2]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /B [id: 3]
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: D:foo
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
D:
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /D [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /C [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /A] for type C [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|ft<T & Any, T?>|): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 0]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /B [id: 0]
|
||||
+2
@@ -1,6 +1,8 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: E:foo
|
||||
// IGNORE_REVERSED_RESOLVE
|
||||
// ^ resolves to C.foo instead of D.foo for some reason, does not seem important
|
||||
// FILE: A.java
|
||||
|
||||
public class A<T> {
|
||||
|
||||
+2
@@ -1,6 +1,8 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: E:foo
|
||||
// IGNORE_REVERSED_RESOLVE
|
||||
// ^ resolves to C.foo instead of D.foo for some reason, does not seem important
|
||||
// FILE: A.java
|
||||
|
||||
public class A<T> {
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: E:foo
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public String foo(Integer x) {
|
||||
return "A";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface B<T> {
|
||||
fun foo(x: T) = "B"
|
||||
}
|
||||
|
||||
interface D : B<Int>
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class E<!> : A(), D
|
||||
|
||||
fun main() {
|
||||
E().foo(42)
|
||||
}
|
||||
+1
-1
@@ -14,5 +14,5 @@ FILE: main.kt
|
||||
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
R|/E.E|().R|/D.foo|(Int(42))
|
||||
R|/E.E|().R|SubstitutionOverride</D.foo: R|kotlin/String|>|(Int(42))
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: E:foo
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
E:
|
||||
[IntersectionOverride]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /E [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 2]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Substitution scope for [Use site scope of /B] for type D [id: 2]
|
||||
[Source]: public open fun foo(x: R|T|): R|kotlin/String| from Use site scope of /B [id: 3]
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Use site scope of /E [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|kotlin/Int!|): R|kotlin/String!| from Java enhancement scope for /A [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /E [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Use site scope of /D [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun foo(x: R|kotlin/Int|): R|kotlin/String| from Substitution scope for [Use site scope of /B] for type D [id: 0]
|
||||
[Source]: public open fun foo(x: R|T|): R|kotlin/String| from Use site scope of /B [id: 1]
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: C:foo
|
||||
// FILE: A.java
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class A {
|
||||
public void foo(@NotNull Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface B {
|
||||
fun foo(x: Int) {}
|
||||
}
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class C<!> : A(), B
|
||||
|
||||
fun main() {
|
||||
C().foo(42)
|
||||
}
|
||||
compiler/testData/diagnostics/tests/j+k/primitiveOverrides/triangleWithNotNullType.fir.overrides.txt
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
C:
|
||||
[IntersectionOverride]: public open fun foo(x: R|@EnhancedNullability kotlin/Int|): R|kotlin/Unit| from Use site scope of /C [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|@EnhancedNullability kotlin/Int|): R|kotlin/Unit| from Java enhancement scope for /A [id: 1]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/Unit| from Use site scope of /B [id: 2]
|
||||
+1
-1
@@ -11,5 +11,5 @@ FILE: main.kt
|
||||
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
R|/C.C|().R|/A.foo|(Int(42))
|
||||
R|/C.C|().<Ambiguity: foo, [/A.foo, /B.foo]>#(Int(42))
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-62554
|
||||
// FIR_DUMP
|
||||
// SCOPE_DUMP: C:foo
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
C:
|
||||
[Enhancement]: public open fun foo(x: R|@EnhancedNullability kotlin/Int|): R|kotlin/Unit| from Use site scope of /C [id: 0]
|
||||
[Enhancement]: public open fun foo(x: R|@EnhancedNullability kotlin/Int|): R|kotlin/Unit| from Java enhancement scope for /A [id: 0]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/Unit| from Use site scope of /C [id: 0]
|
||||
[Source]: public open fun foo(x: R|kotlin/Int|): R|kotlin/Unit| from Use site scope of /B [id: 0]
|
||||
|
||||
Reference in New Issue
Block a user