[FE] Type-safety refactoring: Make areCompatibleClassScopes to return Incompatible.WeakIncompatible

Review: https://jetbrains.team/p/kt/reviews/11039/timeline

For StrongIncompatible `actual` declaration is considered as overload
and error reports on expected declaration. For WeakIncompatible the
error is reported straight away

Before the refactoring `areCompatibleClassScopes` returned just
`Incompatible`. It is bad because StrongIncompatible isn't possible for
classes (classes can't be overloaded). Now all class incompatibilities
are weak.

The commit has a minor impact on observable behavior (cases where we
reported the compilation problems are still reported but on another
elements):
- We no longer report type parameter class incompatibilities on expect
  declaration, we report them only on actuals (it happened because all
  WeakIncompatible are reported only on actuals)
- In a sense, Java implicit actualization was the only way to "overload"
  classes (it would be a redeclaration compilation problem, so it
  doesn't count as a valid "overload"). And since type parameters
  incompatibility was StrongIncompatible for classes, we counted them as
  "overloads" and didn't report incompatibility problems on Kotlin
  class. Now we do report. (see
  implicitJavaActualization_multipleActuals)
This commit is contained in:
Nikita Bobko
2023-08-08 12:55:43 +02:00
committed by teamcity
parent 98ec13b51a
commit d4758014ec
6 changed files with 52 additions and 60 deletions
@@ -1,7 +1,7 @@
// MODULE: m1-common
// FILE: common.kt
expect class <!IMPLICIT_JVM_ACTUALIZATION{JVM}!>Foo<!>(i: Int) {
expect class <!AMBIGUOUS_ACTUALS{JVM}, IMPLICIT_JVM_ACTUALIZATION{JVM}!>Foo<!>(i: Int) {
fun <!AMBIGUOUS_ACTUALS{JVM}!>foo<!>()
}
@@ -15,6 +15,6 @@ public class Foo {
// FILE: jvm.kt
class Foo<T>(t: T) {
class <!ACTUAL_MISSING!>Foo<!><T>(t: T) {
fun foo() {}
}
@@ -1,6 +1,6 @@
// MODULE: m1-common
// FILE: common.kt
expect class SomeClass<!NO_ACTUAL_FOR_EXPECT{JVM}!><T><!> {
expect class SomeClass<T> {
fun foo()
}