Skip to content

Commit f7203da

Browse files
committed
Type inference SHOULD NOT work for type alias constructor in supertypes list
(same as for classes: type arguments should be provided explicitly).
1 parent cd8b5dc commit f7203da

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
open class Ref<T>(var x: T)
2+
3+
typealias R<T> = Ref<T>
4+
5+
// Type inference SHOULD NOT work for type alias constructor in supertypes list
6+
class Test1 : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>R<!>(0)
7+
class Test2 : R<Int>(0)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package
2+
3+
public open class Ref</*0*/ T> {
4+
public constructor Ref</*0*/ T>(/*0*/ x: T)
5+
public final var x: T
6+
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
7+
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
8+
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
9+
}
10+
11+
public final class Test1 {
12+
public constructor Test1()
13+
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
14+
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
15+
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
16+
}
17+
18+
public final class Test2 : R<kotlin.Int> /* = Ref<kotlin.Int> */ {
19+
public constructor Test2()
20+
public final override /*1*/ /*fake_override*/ var x: kotlin.Int
21+
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
22+
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
23+
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
24+
}
25+
public typealias R</*0*/ T> = Ref<T>

compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21154,6 +21154,12 @@ public void testTypeAliasConstructorInSuperCall() throws Exception {
2115421154
doTest(fileName);
2115521155
}
2115621156

21157+
@TestMetadata("typeAliasConstructorInferenceInSupertypesList.kt")
21158+
public void testTypeAliasConstructorInferenceInSupertypesList() throws Exception {
21159+
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.kt");
21160+
doTest(fileName);
21161+
}
21162+
2115721163
@TestMetadata("typeAliasConstructorTypeArgumentsInference.kt")
2115821164
public void testTypeAliasConstructorTypeArgumentsInference() throws Exception {
2115921165
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.kt");

0 commit comments

Comments
 (0)