[FIR] Report WRONG_NUMBER_OF_TYPE_ARGUMENTS on typealias in super types
#KT-59893 Fixed
This commit is contained in:
committed by
Space Team
parent
bb8a46c3a0
commit
85bb7faf10
+1
-1
@@ -228,7 +228,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol is FirRegularClassSymbol) {
|
||||
if (symbol is FirClassLikeSymbol<*>) {
|
||||
val isPossibleBareType = areBareTypesAllowed && allTypeArguments.isEmpty()
|
||||
if (!isPossibleBareType) {
|
||||
val actualSubstitutor = substitutor ?: ConeSubstitutor.Empty
|
||||
|
||||
@@ -13,7 +13,7 @@ object O1 : One<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() // compi
|
||||
object O2 : Both<<!UPPER_BOUND_VIOLATED!>Any<!>, <!UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
|
||||
class A1<T : One<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>>
|
||||
class A2<T : One<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>, Any>>
|
||||
class A2<T : One<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Any, Any><!>>
|
||||
|
||||
interface IO1 : OneList<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>> {}
|
||||
interface IO2 : BothList<<!UPPER_BOUND_VIOLATED!>Any<!>, <!UPPER_BOUND_VIOLATED!>Any<!>> {}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ object O1 : One<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() // compi
|
||||
object O2 : Both<<!UPPER_BOUND_VIOLATED!>Any<!>, <!UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
|
||||
class A1<T : One<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>>
|
||||
class A2<T : One<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>, Any>>
|
||||
class A2<T : One<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Any, Any><!>>
|
||||
|
||||
interface IO1 : OneList<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>> {}
|
||||
interface IO2 : BothList<<!UPPER_BOUND_VIOLATED!>Any<!>, <!UPPER_BOUND_VIOLATED!>Any<!>> {}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
typealias R<T: <!BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED!>List<R><!>> = List<T>
|
||||
typealias R<T: <!BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED!>List<<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>R<!>><!>> = List<T>
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ class Derived : Base<Int>() {
|
||||
val x2: Base<Int>.InnerCell = InnerCell(42)
|
||||
|
||||
val test1: <!UNRESOLVED_REFERENCE!>CT<!> = Cell(42)
|
||||
val test2: Base<Int>.CT = <!TYPE_MISMATCH, TYPE_MISMATCH!>Cell(42)<!>
|
||||
val test2: Base<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.CT = Cell(42)
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ class Outer<T> {
|
||||
fun test5(x: GenericInnerAlias<Int>) = x
|
||||
fun <T> test6(x: GenericInnerAlias<T>) = x
|
||||
}
|
||||
fun test1(x: Outer<Int>.NestedAlias) = x
|
||||
fun <T> test2(x: Outer<T>.NestedAlias) = x
|
||||
fun test1(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.NestedAlias) = x
|
||||
fun <T> test2(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T><!>.NestedAlias) = x
|
||||
fun test3(x: Outer.NestedAlias) = x
|
||||
fun test4(x: Outer<Int>.GenericNestedAlias<Int>) = x
|
||||
fun <T> test5(x: Outer<T>.GenericNestedAlias<Int>) = x
|
||||
fun <T> test6(x: Outer<Int>.GenericNestedAlias<T>) = x
|
||||
fun test4(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.GenericNestedAlias<Int>) = x
|
||||
fun <T> test5(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T><!>.GenericNestedAlias<Int>) = x
|
||||
fun <T> test6(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.GenericNestedAlias<T>) = x
|
||||
fun test7(x: Outer.GenericNestedAlias<Int>) = x
|
||||
fun <T> test8(x: Outer.GenericNestedAlias<T>) = x
|
||||
fun test9(x: Outer.InnerAlias) = x
|
||||
fun test10(x: Outer<Int>.InnerAlias) = x
|
||||
fun <T> test11(x: Outer<T>.InnerAlias) = x
|
||||
fun test10(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.InnerAlias) = x
|
||||
fun <T> test11(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T><!>.InnerAlias) = x
|
||||
fun test12(x: Outer.GenericInnerAlias<Int>) = x
|
||||
fun test13(x: Outer<Int>.GenericInnerAlias<Int>) = x
|
||||
fun <T> test14(x: Outer<T>.GenericInnerAlias<Int>) = x
|
||||
fun test13(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.GenericInnerAlias<Int>) = x
|
||||
fun <T> test14(x: Outer<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T><!>.GenericInnerAlias<Int>) = x
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY
|
||||
|
||||
class C<T> {
|
||||
inner class D
|
||||
|
||||
typealias DA = D
|
||||
typealias SDA = C<Int>.D
|
||||
typealias TSDA = C<T>.D
|
||||
typealias TC = C<T>
|
||||
typealias SSDA = C<*>.D
|
||||
typealias SSC = C<*>
|
||||
}
|
||||
|
||||
fun test1(x: C<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.DA) = x
|
||||
fun test2(x: C.SDA) = x
|
||||
fun test3(x: C<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.TSDA) = x
|
||||
fun test4(x: C<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>.TC) = x
|
||||
|
||||
fun test5(x: C<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><*><!>.DA) = x
|
||||
fun test6(x: C<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><*><!>.TSDA) = x
|
||||
fun test7(x: C<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><*><!>.TC) = x
|
||||
|
||||
fun test8(x: C.SSDA) = x
|
||||
fun test9(x: C.SSC) = x
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY
|
||||
|
||||
class C<T> {
|
||||
@@ -22,4 +21,4 @@ fun test6(x: C<*>.TSDA) = x
|
||||
fun test7(x: C<*>.TC) = x
|
||||
|
||||
fun test8(x: C.SSDA) = x
|
||||
fun test9(x: C.SSC) = x
|
||||
fun test9(x: C.SSC) = x
|
||||
|
||||
@@ -6,5 +6,5 @@ class OuterClass<T1> {
|
||||
}
|
||||
|
||||
typealias ON1<T1, T2> = OuterClass<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T1><!>.NestedClass<T2>
|
||||
typealias ON2<T1, T2> = OuterClass<T1>.NestedType<T2>
|
||||
typealias ON2<T1, T2> = OuterClass<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T1><!>.NestedType<T2>
|
||||
typealias ON3<T2> = OuterClass.NestedType<T2>
|
||||
|
||||
@@ -6,4 +6,4 @@ class C<T> {
|
||||
typealias P2 = Pair<T, Int>
|
||||
}
|
||||
|
||||
val p1: C<String>.P2 = <!TYPE_MISMATCH, TYPE_MISMATCH!>Pair("", 1)<!>
|
||||
val p1: C<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><String><!>.P2 = Pair("", 1)
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
open class Ref<T>(var x: T)
|
||||
|
||||
typealias R<T> = Ref<T>
|
||||
|
||||
// Type inference SHOULD NOT work for type alias constructor in supertypes list
|
||||
class Test1 : R(0)
|
||||
class Test2 : R<Int>(0)
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
open class Ref<T>(var x: T)
|
||||
|
||||
typealias R<T> = Ref<T>
|
||||
|
||||
Reference in New Issue
Block a user