KT-11588 Type aliases

Type alias constructor
This commit is contained in:
Dmitry Petrov
2016-05-23 15:31:01 +03:00
parent 4a9507b3ab
commit 1329a43d89
6 changed files with 69 additions and 1 deletions
@@ -256,7 +256,10 @@ private fun getFakeDescriptorForObject(classifier: ClassifierDescriptor?): FakeC
}
private fun getClassWithConstructors(classifier: ClassifierDescriptor?): ClassDescriptor? {
if (classifier !is ClassDescriptor || ErrorUtils.isError(classifier)
if (classifier is TypeAliasDescriptor) {
return getClassWithConstructors(classifier.classDescriptor)
}
else if (classifier !is ClassDescriptor || ErrorUtils.isError(classifier)
// Constructors of singletons shouldn't be callable from the code
|| classifier.kind.isSingleton) {
return null
@@ -0,0 +1,10 @@
class C<T>(val x: T, val y: String) {
constructor(x: T): this(x, "")
}
typealias GTC<T> = C<T>
val test1 = GTC<String>("", "")
val test2 = GTC<String>("", "")
val test3 = GTC<String>("")
val test4 = GTC<String>("")
@@ -0,0 +1,17 @@
package
public typealias GTC</*0*/ T> = C<T>
public val test1: C<kotlin.String>
public val test2: C<kotlin.String>
public val test3: C<kotlin.String>
public val test4: C<kotlin.String>
public final class C</*0*/ T> {
public constructor C</*0*/ T>(/*0*/ x: T)
public constructor C</*0*/ T>(/*0*/ x: T, /*1*/ y: kotlin.String)
public final val x: T
public final val y: kotlin.String
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
}
@@ -0,0 +1,10 @@
class C(val x: String) {
constructor(): this("")
}
typealias TC = C
val test1: C = TC("")
val test2: TC = TC("")
val test3: C = TC()
val test4: TC = TC()
@@ -0,0 +1,16 @@
package
public typealias TC = C
public val test1: C
public val test2: TC [= C]
public val test3: C
public val test4: TC [= C]
public final class C {
public constructor C()
public constructor C(/*0*/ x: kotlin.String)
public final val x: kotlin.String
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
}
@@ -19131,6 +19131,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("genericTypeAliasConstructor.kt")
public void testGenericTypeAliasConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/genericTypeAliasConstructor.kt");
doTest(fileName);
}
@TestMetadata("genericTypeAliasObject.kt")
public void testGenericTypeAliasObject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/genericTypeAliasObject.kt");
@@ -19173,6 +19179,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("typeAliasConstructor.kt")
public void testTypeAliasConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasConstructor.kt");
doTest(fileName);
}
@TestMetadata("typeAliasObject.kt")
public void testTypeAliasObject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasObject.kt");