KT-6803 Subtyping breaks on star-projections for recursive generics
Star-projections have upper bounds of the form "parameter's bound where all parameter of the same class are substituted with their star-projections" #KT-6803 Fixed
This commit is contained in:
@@ -9,10 +9,10 @@ fun main(args : Array<String>) {
|
||||
val <!UNUSED_VARIABLE!>a<!> : C<Int> = C();
|
||||
val <!UNUSED_VARIABLE!>x<!> : C<in String> = C()
|
||||
val <!UNUSED_VARIABLE!>y<!> : C<out String> = C()
|
||||
val <!UNUSED_VARIABLE!>z<!> : C<*> = C()
|
||||
val <!UNUSED_VARIABLE!>z<!> : C<*> = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>C<!>()
|
||||
|
||||
val <!UNUSED_VARIABLE!>ba<!> : C<Int> = bar();
|
||||
val <!UNUSED_VARIABLE!>bx<!> : C<in String> = bar()
|
||||
val <!UNUSED_VARIABLE!>by<!> : C<out String> = bar()
|
||||
val <!UNUSED_VARIABLE!>bz<!> : C<*> = bar()
|
||||
}
|
||||
val <!UNUSED_VARIABLE!>bz<!> : C<*> = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!>()
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
trait A<R, T: A<R, T>> {
|
||||
fun r(): R
|
||||
fun t(): T
|
||||
}
|
||||
|
||||
fun testA(a: A<*, *>) {
|
||||
a.r().checkType { it : _<Any?> }
|
||||
a.t().checkType { it : _<A<*, *>> }
|
||||
}
|
||||
|
||||
trait B<R, T: B<List<R>, <!UPPER_BOUND_VIOLATED!>T<!>>> {
|
||||
fun r(): R
|
||||
fun t(): T
|
||||
}
|
||||
|
||||
fun testB(b: B<*, *>) {
|
||||
b.r().checkType { it : _<Any?> }
|
||||
b.t().checkType { it : _<B<List<*>, *>> }
|
||||
|
||||
b.t().r().size()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
internal fun testA(/*0*/ a: A<*, *>): kotlin.Unit
|
||||
internal fun testB(/*0*/ b: B<*, *>): kotlin.Unit
|
||||
|
||||
internal trait A</*0*/ R, /*1*/ T : A<R, T>> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
internal abstract fun r(): R
|
||||
internal abstract fun t(): T
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal trait B</*0*/ R, /*1*/ T : B<kotlin.List<R>, T>> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
internal abstract fun r(): R
|
||||
internal abstract fun t(): T
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -44,4 +44,8 @@ trait B: Parent
|
||||
|
||||
trait Rec<T>
|
||||
class ARec : Rec<ARec>
|
||||
class BRec : Rec<BRec>
|
||||
class BRec : Rec<BRec>
|
||||
trait SubRec<T>: Rec<T>
|
||||
|
||||
trait Star<T : Star<T>>
|
||||
trait SubStar<T : SubStar<T>> : Star<T>
|
||||
@@ -10901,6 +10901,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("starProjections.kt")
|
||||
public void testStarProjections() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/substitutions/starProjections.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("upperBoundsSubstitutionForOverloadResolutionWithAmbiguity.kt")
|
||||
public void testUpperBoundsSubstitutionForOverloadResolutionWithAmbiguity() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithAmbiguity.kt");
|
||||
|
||||
@@ -328,6 +328,23 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
assertSubtype("Nothing?", "Derived_T<*>?");
|
||||
}
|
||||
|
||||
public void testStars() throws Exception {
|
||||
assertSubtype("SubStar<*>", "Star<*>");
|
||||
assertSubtype("SubStar<SubStar<*>>", "Star<*>");
|
||||
assertSubtype("SubStar<SubStar<*>>", "Star<SubStar<*>>");
|
||||
assertNotSubtype("SubStar<SubStar<*>>", "Star<Star<*>>");
|
||||
|
||||
assertSubtype("Star<Star<*>>", "Star<*>");
|
||||
assertSubtype("Star<*>", "Star<out Star<*>>");
|
||||
|
||||
assertNotSubtype("Star<*>", "Star<Star<*>>");
|
||||
|
||||
assertSubtype("SubRec<*>", "Rec<*>");
|
||||
assertSubtype("SubRec<*>", "Rec<out Any?>");
|
||||
assertSubtype("Rec<*>", "Rec<out Any?>");
|
||||
assertNotSubtype("Rec<*>", "Rec<out Any>");
|
||||
}
|
||||
|
||||
public void testThis() throws Exception {
|
||||
assertType("Derived_T<Int>", "this", "Derived_T<Int>");
|
||||
// assertType("Derived_T<Int>", "super<Base_T>", "Base_T<Int>");
|
||||
|
||||
Reference in New Issue
Block a user