KT-11588 Type aliases
Additional tests for type alias constructor & companion object: - codegen - error diagnostics
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class C(val x: String)
|
||||
|
||||
typealias Alias = C
|
||||
|
||||
fun box(): String = Alias("OK").x
|
||||
@@ -0,0 +1,15 @@
|
||||
object OHolder {
|
||||
val O = "O"
|
||||
}
|
||||
|
||||
typealias OHolderAlias = OHolder
|
||||
|
||||
class KHolder {
|
||||
companion object {
|
||||
val K = "K"
|
||||
}
|
||||
}
|
||||
|
||||
typealias KHolderAlias = KHolder
|
||||
|
||||
fun box(): String = OHolderAlias.O + KHolderAlias.K
|
||||
@@ -8,3 +8,17 @@ val test1: C = TC("")
|
||||
val test2: TC = TC("")
|
||||
val test3: C = TC()
|
||||
val test4: TC = TC()
|
||||
|
||||
val test5 = <!NONE_APPLICABLE!>TC<!>("", "")
|
||||
|
||||
interface Interface
|
||||
typealias TI = Interface
|
||||
|
||||
object AnObject
|
||||
typealias TO = AnObject
|
||||
|
||||
val test6 = <!UNRESOLVED_REFERENCE!>TI<!>()
|
||||
val test6a = <!UNRESOLVED_REFERENCE!>Interface<!>()
|
||||
|
||||
val test7 = <!FUNCTION_EXPECTED!>TO<!>()
|
||||
val test7a = <!FUNCTION_EXPECTED!>AnObject<!>()
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
package
|
||||
|
||||
public typealias TC = C
|
||||
public typealias TI = Interface
|
||||
public typealias TO = AnObject
|
||||
public val test1: C
|
||||
public val test2: TC [= C]
|
||||
public val test3: C
|
||||
public val test4: TC [= C]
|
||||
public val test5: [ERROR : Type for TC("", "")]
|
||||
public val test6: [ERROR : Type for TI()]
|
||||
public val test6a: [ERROR : Type for Interface()]
|
||||
public val test7: [ERROR : Type for TO()]
|
||||
public val test7a: [ERROR : Type for AnObject()]
|
||||
|
||||
public object AnObject {
|
||||
private constructor AnObject()
|
||||
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 final class C {
|
||||
public constructor C()
|
||||
@@ -14,3 +28,9 @@ public final class C {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Interface {
|
||||
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,21 @@
|
||||
object ObjectWithInvoke {
|
||||
operator fun invoke() = this
|
||||
}
|
||||
|
||||
class ClassWithCompanionObjectWithInvoke {
|
||||
companion object {
|
||||
operator fun invoke(x: Any) = x
|
||||
}
|
||||
}
|
||||
|
||||
typealias WI = ObjectWithInvoke
|
||||
|
||||
typealias CWI = ClassWithCompanionObjectWithInvoke
|
||||
|
||||
val test1 = WI()
|
||||
val test2 = WI(<!TOO_MANY_ARGUMENTS!>null<!>)
|
||||
|
||||
val test3 = CWI()
|
||||
val test4 = CWI("")
|
||||
val test5 = CWI(<!TOO_MANY_ARGUMENTS!>null<!>)
|
||||
val test5a = ClassWithCompanionObjectWithInvoke(<!TOO_MANY_ARGUMENTS!>null<!>)
|
||||
@@ -0,0 +1,33 @@
|
||||
package
|
||||
|
||||
public typealias CWI = ClassWithCompanionObjectWithInvoke
|
||||
public typealias WI = ObjectWithInvoke
|
||||
public val test1: ObjectWithInvoke
|
||||
public val test2: ObjectWithInvoke
|
||||
public val test3: ClassWithCompanionObjectWithInvoke
|
||||
public val test4: kotlin.Any
|
||||
public val test5: ClassWithCompanionObjectWithInvoke
|
||||
public val test5a: ClassWithCompanionObjectWithInvoke
|
||||
|
||||
public final class ClassWithCompanionObjectWithInvoke {
|
||||
public constructor ClassWithCompanionObjectWithInvoke()
|
||||
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 companion object Companion {
|
||||
private constructor Companion()
|
||||
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 final operator fun invoke(/*0*/ x: kotlin.Any): kotlin.Any
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public object ObjectWithInvoke {
|
||||
private constructor ObjectWithInvoke()
|
||||
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 final operator fun invoke(): ObjectWithInvoke
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -19190,6 +19190,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasObjectWithInvoke.kt")
|
||||
public void testTypeAliasObjectWithInvoke() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasObjectWithInvoke.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/unit")
|
||||
|
||||
@@ -14370,6 +14370,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/simple.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasConstructor.kt")
|
||||
public void testTypeAliasConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasConstructor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasObject.kt")
|
||||
public void testTypeAliasObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/unaryOp")
|
||||
|
||||
Reference in New Issue
Block a user