Constructors for inner type aliases: add a failing test (no way to invoke such constructor at the moment).

This commit is contained in:
Dmitry Petrov
2016-11-14 13:13:24 +03:00
parent 718e8ebf9e
commit cd8b5dcb00
3 changed files with 56 additions and 0 deletions
@@ -0,0 +1,21 @@
class Pair<X, Y>(val x: X, val y: Y)
class C<T> {
typealias P = Pair<T, T>
typealias P1<X> = Pair<X, T>
typealias P2<Y> = Pair<T, Y>
}
// C<...>.P[<...>]() syntax doesn't work due to the way qualified expressions are resolved now.
// This restriction can be removed later.
val test0 = <!FUNCTION_CALL_EXPECTED!>C<Int><!>.<!UNRESOLVED_REFERENCE!>P<!>(1, 1)
val test1 = <!FUNCTION_CALL_EXPECTED!>C<Int><!>.<!UNRESOLVED_REFERENCE!>P1<!><String>("", 1)
val test2 = <!FUNCTION_CALL_EXPECTED!>C<Int><!>.<!UNRESOLVED_REFERENCE!>P2<!><String>(1, "")
val test3 = <!FUNCTION_CALL_EXPECTED!>C<Int><!>.<!UNRESOLVED_REFERENCE!>P1<!>("", 1)
val test4 = <!FUNCTION_CALL_EXPECTED!>C<Int><!>.<!UNRESOLVED_REFERENCE!>P2<!>(1, "")
// C.P() syntax could work if we add captured type parameters as type variables in a constraint system for corresponding call.
// However, this should be consistent with inner classes capturing type parameters.
val test5 = C.P(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
val test6 = C.<!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>P1<!>("", <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
val test7 = C.<!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>P2<!>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "")
@@ -0,0 +1,29 @@
package
public val test0: [ERROR : Type for C<Int>.P(1, 1)]
public val test1: [ERROR : Type for C<Int>.P1<String>("", 1)]
public val test2: [ERROR : Type for C<Int>.P2<String>(1, "")]
public val test3: [ERROR : Type for C<Int>.P1("", 1)]
public val test4: [ERROR : Type for C<Int>.P2(1, "")]
public val test5: Pair<T, T>
public val test6: Pair<kotlin.String, T>
public val test7: Pair<T, kotlin.String>
public final class C</*0*/ T> {
public constructor C</*0*/ 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
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public typealias P /*captured type parameters: /*0*/ T*/ = Pair<T, T>
public typealias P1</*0*/ X> /*captured type parameters: /*1*/ T*/ = Pair<X, T>
public typealias P2</*0*/ Y> /*captured type parameters: /*1*/ T*/ = Pair<T, Y>
}
public final class Pair</*0*/ X, /*1*/ Y> {
public constructor Pair</*0*/ X, /*1*/ Y>(/*0*/ x: X, /*1*/ y: Y)
public final val x: X
public final val y: Y
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -20938,6 +20938,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("innerTypeAliasConstructor.kt")
public void testInnerTypeAliasConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.kt");
doTest(fileName);
}
@TestMetadata("isAsWithTypeAlias.kt")
public void testIsAsWithTypeAlias() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/isAsWithTypeAlias.kt");