Fix type parameter bound check in expect-actual checker

Also make TypeParameterUpperBounds a "strong" incompatibility, meaning
that non-actual members from platform module are _not_ going to be
matched to the expected members if this incompatibility exists between
them, and therefore NO_ACTUAL_FOR_EXPECT will be reported on the
expected declaration, instead of ACTUAL_MISSING on the platform member.
This is needed because the difference in type parameter upper bounds can
have effect on the function signature on the platform (e.g. on JVM,
Array<T> -> T[], but Array<T> -> Comparable[] if T : Comparable<T>), and
it would be incorrect to report ACTUAL_MISSING on the member that has
nothing to do with the expected declaration that happens to coincide
with it in everything except type parameter bounds

 #KT-21864 Fixed
This commit is contained in:
Alexander Udalov
2018-01-08 15:35:59 +01:00
parent 8c6b140865
commit f198a28276
11 changed files with 224 additions and 3 deletions
@@ -11,6 +11,18 @@ The following declaration is incompatible because number of type parameters is d
expect class C1<A>
^
compiler/testData/multiplatform/incompatibleClasses/common.kt:16:16: error: expected class 'C3' has no actual declaration in module
The following declaration is incompatible because upper bounds of type parameters are different:
public final actual class C3<D, E : D?>
expect class C3<D, E : D>
^
compiler/testData/multiplatform/incompatibleClasses/common.kt:18:16: error: expected class 'C4' has no actual declaration in module
The following declaration is incompatible because upper bounds of type parameters are different:
public typealias C4<F> = C4Impl<F>
expect class C4<F>
^
compiler/testData/multiplatform/incompatibleClasses/jvm.kt:1:8: error: actual interface 'PClass' has no corresponding expected declaration
The following declaration is incompatible because class kinds are different (class, interface, object, enum, annotation):
public final expect class PClass
@@ -83,6 +95,18 @@ The following declaration is incompatible because declaration-site variances of
actual class C2<out B>
^
compiler/testData/multiplatform/incompatibleClasses/jvm.kt:16:16: error: actual class 'C3' has no corresponding expected declaration
The following declaration is incompatible because upper bounds of type parameters are different:
public final expect class C3<D, E : D>
actual class C3<D, E : D?>
^
compiler/testData/multiplatform/incompatibleClasses/jvm.kt:18:20: error: actual typealias 'C4' has no corresponding expected declaration
The following declaration is incompatible because upper bounds of type parameters are different:
public final expect class C4<F>
actual typealias C4<F> = C4Impl<F>
^
compiler/testData/multiplatform/incompatibleClasses/jvm.kt:21:39: error: actual class 'ExtendsNumber' has no corresponding expected declaration
The following declaration is incompatible because some supertypes are missing in the actual declaration:
public abstract expect class ExtendsNumber : Number