diff --git a/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.txt b/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.txt index 924882bc071..ea7a0ff901f 100644 --- a/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.txt +++ b/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.txt @@ -1,11 +1,11 @@ package public val x1: Num -public val x2: Num -public val x3: Num +public val x2: N /* = Num */ +public val x3: N2 /* = Num */ public val y1: TColl -public val y2: TColl -public val y3: TColl +public val y2: TC /* = TColl */ +public val y3: TC2 /* = TColl */ public final class Num { public constructor Num(/*0*/ x: T) diff --git a/compiler/testData/diagnostics/tests/typealias/boundsViolationInDeepTypeAliasExpansion.txt b/compiler/testData/diagnostics/tests/typealias/boundsViolationInDeepTypeAliasExpansion.txt index dc2b9db7d96..7f1fa33dd5e 100644 --- a/compiler/testData/diagnostics/tests/typealias/boundsViolationInDeepTypeAliasExpansion.txt +++ b/compiler/testData/diagnostics/tests/typealias/boundsViolationInDeepTypeAliasExpansion.txt @@ -1,9 +1,9 @@ package -public val test5: TColl> -public val test6: TColl> -public val test7: TColl> -public val test8: TColl> +public val test5: TC2> /* = TColl> */ +public val test6: TC2> /* = TColl> */ +public val test7: TC2> /* = TColl> */ +public val test8: TC2> /* = TColl> */ public fun test1(/*0*/ x: TC2> /* = TColl> */): kotlin.Unit public fun test2(/*0*/ x: TC2> /* = TColl> */): kotlin.Unit public fun test3(/*0*/ x: TC2> /* = TColl> */): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasExpansion.txt b/compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasExpansion.txt index 37d9bc08247..7d49b1217c2 100644 --- a/compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasExpansion.txt +++ b/compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasExpansion.txt @@ -1,13 +1,13 @@ package -public val test13: TColl> -public val test14: TColl> -public val test15: TColl> -public val test16: TColl> -public val test5: Num -public val test6: Num -public val test7: NumColl> -public val test8: NumColl> +public val test13: TC> /* = TColl> */ +public val test14: TC> /* = TColl> */ +public val test15: TC> /* = TColl> */ +public val test16: TC> /* = TColl> */ +public val test5: NA /* = Num */ +public val test6: NA /* = Num */ +public val test7: NL /* = NumColl> */ +public val test8: NL /* = NumColl> */ public fun test1(/*0*/ x: NA /* = Num */): kotlin.Unit public fun test10(/*0*/ x: TC> /* = TColl> */): kotlin.Unit public fun test11(/*0*/ x: TC> /* = TColl> */): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/typealias/genericTypeAliasConstructor.txt b/compiler/testData/diagnostics/tests/typealias/genericTypeAliasConstructor.txt index 0833ac32aaa..bec1b6a3fbd 100644 --- a/compiler/testData/diagnostics/tests/typealias/genericTypeAliasConstructor.txt +++ b/compiler/testData/diagnostics/tests/typealias/genericTypeAliasConstructor.txt @@ -1,9 +1,9 @@ package -public val test1: C -public val test2: C -public val test3: C -public val test4: C +public val test1: GTC /* = C */ +public val test2: GTC /* = C */ +public val test3: GTC /* = C */ +public val test4: GTC /* = C */ public final class C { public constructor C(/*0*/ x: T) diff --git a/compiler/testData/diagnostics/tests/typealias/inGenerics.txt b/compiler/testData/diagnostics/tests/typealias/inGenerics.txt index d4ea709cdd6..4f5546b9c65 100644 --- a/compiler/testData/diagnostics/tests/typealias/inGenerics.txt +++ b/compiler/testData/diagnostics/tests/typealias/inGenerics.txt @@ -2,7 +2,7 @@ package public val ms: MyString /* = kotlin.String */ = "MyString" public val msc: MyStringContainer /* = Container */ -public val msc1: Container +public val msc1: MyStringContainer /* = Container */ public val msn: MyString? /* = kotlin.String? */ = null public final class Container { diff --git a/compiler/testData/diagnostics/tests/typealias/innerClassTypeAliasConstructor.txt b/compiler/testData/diagnostics/tests/typealias/innerClassTypeAliasConstructor.txt index c0fcde5e43e..9d60d188a64 100644 --- a/compiler/testData/diagnostics/tests/typealias/innerClassTypeAliasConstructor.txt +++ b/compiler/testData/diagnostics/tests/typealias/innerClassTypeAliasConstructor.txt @@ -1,11 +1,11 @@ package public fun test1(/*0*/ x: Outer): Outer.Inner -public fun test2(/*0*/ x: Generic): Generic.Inner -public fun test3(/*0*/ x: Generic): Generic.Inner -public fun test4(/*0*/ x: Generic>): Generic>.Inner -public fun test5(/*0*/ x: Generic): Generic.Inner -public fun Generic.test6(): Generic.Inner +public fun test2(/*0*/ x: Generic): GI /* = Generic.Inner */ +public fun test3(/*0*/ x: Generic): GI /* = Generic.Inner */ +public fun test4(/*0*/ x: Generic>): GI> /* = Generic>.Inner */ +public fun test5(/*0*/ x: Generic): GIntI /* = Generic.Inner */ +public fun Generic.test6(): GIntI /* = Generic.Inner */ public final class Generic { public constructor Generic() diff --git a/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.txt b/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.txt index 01e86ef3e8e..b007fd8321a 100644 --- a/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.txt +++ b/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.txt @@ -5,9 +5,9 @@ public val test1: [ERROR : Type for C.P1("", 1)] public val test2: [ERROR : Type for C.P2(1, "")] public val test3: [ERROR : Type for C.P1("", 1)] public val test4: [ERROR : Type for C.P2(1, "")] -public val test5: Pair -public val test6: Pair -public val test7: Pair +public val test5: C.P /* = Pair */ +public val test6: C.P1 /* = Pair */ +public val test7: C.P2 /* = Pair */ public final class C { public constructor C() diff --git a/compiler/testData/diagnostics/tests/typealias/nested.txt b/compiler/testData/diagnostics/tests/typealias/nested.txt index eff054f6cab..c7d99bbd28d 100644 --- a/compiler/testData/diagnostics/tests/typealias/nested.txt +++ b/compiler/testData/diagnostics/tests/typealias/nested.txt @@ -11,7 +11,7 @@ public final class C { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun first(/*0*/ p: C.P2 /* = Pair */): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public final fun p(): Pair + public final fun p(): C.P2 /* = Pair */ public final fun second(/*0*/ p: C.P2 /* = Pair */): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public typealias P2 = Pair diff --git a/compiler/testData/diagnostics/tests/typealias/projectionsInTypeAliasConstructor.txt b/compiler/testData/diagnostics/tests/typealias/projectionsInTypeAliasConstructor.txt index 61114518597..7f86005af46 100644 --- a/compiler/testData/diagnostics/tests/typealias/projectionsInTypeAliasConstructor.txt +++ b/compiler/testData/diagnostics/tests/typealias/projectionsInTypeAliasConstructor.txt @@ -1,7 +1,7 @@ package public val test1: In -public val test2: In +public val test2: InAlias /* = In */ public final class In { public constructor In(/*0*/ x: kotlin.Any) diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorCrazyProjections.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorCrazyProjections.txt index d0cd0d3a9a6..a9e06910eaf 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorCrazyProjections.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorCrazyProjections.txt @@ -1,7 +1,7 @@ package public val test1: [ERROR : Type for BOutIn(listOf(), null!!)] -public val test2: Bound, in kotlin.Nothing> +public val test2: BInIn /* = Bound, in kotlin.Nothing> */ public fun listOf(): kotlin.collections.List public final class Bound { diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.txt index 1fcde7720eb..e65d538ffe6 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.txt @@ -1,10 +1,10 @@ package -public val test1: C<*> -public val test2: C -public val test3: C -public val test4: C<[ERROR : Star projection in a call]> -public val test5: C /* = C<*> */> +public val test1: CStar /* = C<*> */ +public val test2: CIn /* = C */ +public val test3: COut /* = C */ +public val test4: CT<[ERROR : Star projection in a call]> /* = C<[ERROR : Star projection in a call]> */ +public val test5: CT /* = C<*> */> /* = C /* = C<*> */> */ public final class C { public constructor C() diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt new file mode 100644 index 00000000000..e6a4d0eae5b --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt @@ -0,0 +1,18 @@ +class Cell(val x : T) +class Pair(val x1: T1, val x2: T2) + +typealias CIntA = Cell +typealias CA = Cell +typealias PIntIntA = Pair +typealias PA = Pair +typealias P2A = Pair + +val test1 = CIntA(10) +val test2 = CA(10) +val test3 = CA(10) +val test4 = PIntIntA(10, 20) +val test5 = PA(10, 20) +val test6 = PA(10, 20) +val test7 = P2A(10, 20) +val test8 = P2A(10, 20) + diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.txt new file mode 100644 index 00000000000..3169647e793 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.txt @@ -0,0 +1,32 @@ +package + +public val test1: CIntA /* = Cell */ +public val test2: CA /* = Cell */ +public val test3: CA /* = Cell */ +public val test4: PIntIntA /* = Pair */ +public val test5: PA /* = Pair */ +public val test6: PA /* = Pair */ +public val test7: P2A /* = Pair */ +public val test8: P2A /* = Pair */ + +public final class Cell { + public constructor Cell(/*0*/ x: T) + public final val x: 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 final class Pair { + public constructor Pair(/*0*/ x1: T1, /*1*/ x2: T2) + public final val x1: T1 + public final val x2: T2 + 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 CA = Cell +public typealias CIntA = Cell +public typealias P2A = Pair +public typealias PA = Pair +public typealias PIntIntA = Pair diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.kt index a2eccd30dd1..519efe38861 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.kt @@ -2,7 +2,7 @@ class Num(val x: Tn) typealias N = Num val test0 = N(1) -val test1 = \(x: T\): Num +val test1 = \(x: T\): N /* = Num */ is not satisfied: inferred type String is not a subtype of Number)!>N("1") diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.txt index f22d82148a8..7d86a477a50 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.txt @@ -1,11 +1,11 @@ package -public val test0: Num +public val test0: N /* = Num */ public val test1: [ERROR : Type for N("1")] -public val test2: Cons +public val test2: C /* = Cons */ public val test3: [ERROR : Type for CC(1, 2)] -public val test4: Cons> -public val test5: Pair> +public val test4: CC /* = Cons> */ +public val test5: PL /* = Pair> */ public fun testProjections1(/*0*/ x: Pair): [ERROR : Error function type] public fun testProjections2(/*0*/ x: Pair): [ERROR : Error function type] public fun testProjections3(/*0*/ x: Pair): [ERROR : Error function type] diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt index 80968c8e006..e34d3c6a445 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt @@ -1,7 +1,7 @@ package -public val test1: Cons -public val test2: Cons +public val test1: C /* = Cons */ +public val test2: C /* = Cons */ public final class Cons { public constructor Cons(/*0*/ head: T, /*1*/ tail: Cons?) diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls2.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls2.txt index 1dc9e78df8a..92486783d17 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls2.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls2.txt @@ -3,9 +3,9 @@ package public val r1: Ref public val r1a: Ref public val r2: LateInitNumRef -public val r2a: LateInitNumRef +public val r2a: LateNR /* = LateInitNumRef */ public val r3: LateInitNumRef -public val r3a: LateInitNumRef +public val r3a: LateNR /* = LateInitNumRef */ public fun test(): kotlin.Unit public fun > update(/*0*/ r: R, /*1*/ v: V): R diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.kt index e5428b12a35..7482a10667d 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.kt @@ -6,11 +6,11 @@ class Hr(val a: A, val b: B) typealias Test = Hr, Bar> val test1 = Test(1, "") -val test2 = \(a: A, b: B\): Hr, Bar> +val test2 = \(a: A, b: B\): Test /* = Hr, Bar> */ is not satisfied: inferred type Int is not a subtype of CharSequence)!>Test(1, 2) typealias Bas = Hr, Bar> -val test3 = \(a: T, b: T\): Hr, Bar> +val test3 = \(a: T, b: T\): Bas /* = Hr, Bar> */ is not satisfied: inferred type Int is not a subtype of CharSequence)!>Bas(1, 1) diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.txt index 2386061ebe4..9222d32b54d 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithPhantomTypes.txt @@ -1,6 +1,6 @@ package -public val test1: Hr, Bar> +public val test1: Test /* = Hr, Bar> */ public val test2: [ERROR : Type for Test(1, 2)] public val test3: [ERROR : Type for Bas(1, 1)] diff --git a/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.txt b/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.txt index 9b68e43e926..991cf163f01 100644 --- a/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.txt +++ b/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.txt @@ -1,23 +1,23 @@ package -public val test0: Pair -public val test0p2: Pair -public val test0p2a: Pair -public val test0pr: Pair -public val test1: Pair -public val test1p2: Pair -public val test1pr: Pair<[ERROR : Explicit type argument expected for T2], kotlin.Int> -public val test2: Pair -public val test2p2: Pair -public val test2pr: Pair -public val test2pra: Pair -public val test3: Pair -public val test3p2: Pair -public val test3pr: Pair +public val test0: P /* = Pair */ +public val test0p2: P2 /* = Pair */ +public val test0p2a: P2 /* = Pair */ +public val test0pr: PR /* = Pair */ +public val test1: P /* = Pair */ +public val test1p2: P2 /* = Pair */ +public val test1pr: PR /* = Pair<[ERROR : Explicit type argument expected for T2], kotlin.Int> */ +public val test2: P /* = Pair */ +public val test2p2: P2 /* = Pair */ +public val test2pr: PR /* = Pair */ +public val test2pra: PR /* = Pair */ +public val test3: P /* = Pair */ +public val test3p2: P2 /* = Pair */ +public val test3pr: P2 /* = Pair */ public val testN0: [ERROR : Type for N("")] -public val testN1: Num -public val testN1a: Num -public val testN2: Num +public val testN1: N /* = Num */ +public val testN1a: N /* = Num */ +public val testN2: N /* = Num */ public final class Num { public constructor Num(/*0*/ x: T) diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.txt b/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.txt index 27a51e14b91..38d683d0e74 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.txt @@ -1,7 +1,7 @@ package public var longWords: kotlin.Int -public val smallWords: java.util.HashSet +public val smallWords: kotlin.collections.HashSet /* = java.util.HashSet */ public fun test1(/*0*/ word: kotlin.String): kotlin.Any public fun test2(/*0*/ word: kotlin.String): kotlin.Any public fun test3(/*0*/ word: kotlin.String): kotlin.Any? diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/ea65206.txt b/compiler/testData/diagnostics/testsWithStdLib/regression/ea65206.txt index 64ce5612777..498748299fd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/regression/ea65206.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/ea65206.txt @@ -2,7 +2,7 @@ package public final class A { public constructor A() - public final val x: java.util.ArrayList<([ERROR : A]<[ERROR : No type element]>) -> kotlin.Unit> + public final val x: kotlin.collections.ArrayList<([ERROR : A]<[ERROR : No type element]>) -> kotlin.Unit> /* = java.util.ArrayList<([ERROR : A]<[ERROR : No type element]>) -> kotlin.Unit> */ public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.txt b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.txt index e68a8e2d396..fdd826a5570 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.txt @@ -1,4 +1,4 @@ package -public val barException: java.lang.Exception -public val fooException: java.lang.Exception +public val barException: kotlin.Exception /* = java.lang.Exception */ +public val fooException: kotlin.Exception /* = java.lang.Exception */ diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/hashMapTypeAlias.txt b/compiler/testData/diagnostics/testsWithStdLib/typealias/hashMapTypeAlias.txt index 9899f8b18a5..dd18182c972 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/typealias/hashMapTypeAlias.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/hashMapTypeAlias.txt @@ -1,6 +1,6 @@ package -public val mutableNamesByTeam1: java.util.HashMap> +public val mutableNamesByTeam1: HM> /* = java.util.HashMap> */ public val mutableNamesByTeam2: java.util.HashMap> public val nameToTeam: kotlin.collections.List> public val namesByTeam: kotlin.collections.Map> diff --git a/compiler/testData/ir/irText/declarations/classLevelProperties.txt b/compiler/testData/ir/irText/declarations/classLevelProperties.txt index b920d86edb0..466ac17716f 100644 --- a/compiler/testData/ir/irText/declarations/classLevelProperties.txt +++ b/compiler/testData/ir/irText/declarations/classLevelProperties.txt @@ -90,9 +90,9 @@ FILE /classLevelProperties.kt thisRef: GET_VAR '' type=C origin=null property: CALLABLE_REFERENCE 'test7: Int' type=kotlin.reflect.KProperty1 origin=PROPERTY_REFERENCE_FOR_DELEGATE PROPERTY public final var test8: kotlin.Int - FIELD DELEGATE val `test8$delegate`: java.util.HashMap + FIELD DELEGATE val `test8$delegate`: kotlin.collections.HashMap /* = java.util.HashMap */ EXPRESSION_BODY - CALL 'hashMapOf(): HashMap' type=java.util.HashMap origin=null + CALL 'hashMapOf(): HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null : String : Int FUN DELEGATED_PROPERTY_ACCESSOR public final fun (): kotlin.Int @@ -100,7 +100,7 @@ FILE /classLevelProperties.kt RETURN type=kotlin.Nothing from='(): Int' CALL 'getValue(Any?, KProperty<*>) on MutableMap: Int' type=kotlin.Int origin=null : Int - $receiver: GET_FIELD '`test8$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_FIELD '`test8$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null receiver: GET_VAR '' type=C origin=null thisRef: GET_VAR '' type=C origin=null property: CALLABLE_REFERENCE 'test8: Int' type=kotlin.reflect.KMutableProperty1 origin=PROPERTY_REFERENCE_FOR_DELEGATE @@ -109,7 +109,7 @@ FILE /classLevelProperties.kt RETURN type=kotlin.Nothing from='(Int): Unit' CALL 'setValue(Any?, KProperty<*>, Int) on MutableMap: Unit' type=kotlin.Unit origin=null : Int - $receiver: GET_FIELD '`test8$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_FIELD '`test8$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null receiver: GET_VAR '' type=C origin=null thisRef: GET_VAR '' type=C origin=null property: CALLABLE_REFERENCE 'test8: Int' type=kotlin.reflect.KMutableProperty1 origin=PROPERTY_REFERENCE_FOR_DELEGATE diff --git a/compiler/testData/ir/irText/declarations/delegatedProperties.txt b/compiler/testData/ir/irText/declarations/delegatedProperties.txt index efe95669232..75f4c0736dc 100644 --- a/compiler/testData/ir/irText/declarations/delegatedProperties.txt +++ b/compiler/testData/ir/irText/declarations/delegatedProperties.txt @@ -77,9 +77,9 @@ FILE /delegatedProperties.kt property: CALLABLE_REFERENCE 'test3: Any' type=kotlin.reflect.KMutableProperty1 origin=PROPERTY_REFERENCE_FOR_DELEGATE value: GET_VAR 'value-parameter : Any' type=kotlin.Any origin=null PROPERTY public var test4: kotlin.Any - FIELD DELEGATE val `test4$delegate`: java.util.HashMap + FIELD DELEGATE val `test4$delegate`: kotlin.collections.HashMap /* = java.util.HashMap */ EXPRESSION_BODY - CALL 'hashMapOf(): HashMap' type=java.util.HashMap origin=null + CALL 'hashMapOf(): HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null : String : Any FUN DELEGATED_PROPERTY_ACCESSOR public fun (): kotlin.Any @@ -87,7 +87,7 @@ FILE /delegatedProperties.kt RETURN type=kotlin.Nothing from='(): Any' CALL 'getValue(Any?, KProperty<*>) on MutableMap: Any' type=kotlin.Any origin=null : Any - $receiver: GET_FIELD '`test4$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_FIELD '`test4$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' property: CALLABLE_REFERENCE 'test4: Any' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN DELEGATED_PROPERTY_ACCESSOR public fun (: kotlin.Any): kotlin.Unit @@ -95,7 +95,7 @@ FILE /delegatedProperties.kt RETURN type=kotlin.Nothing from='(Any): Unit' CALL 'setValue(Any?, KProperty<*>, Any) on MutableMap: Unit' type=kotlin.Unit origin=null : Any - $receiver: GET_FIELD '`test4$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_FIELD '`test4$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' property: CALLABLE_REFERENCE 'test4: Any' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE value: GET_VAR 'value-parameter : Any' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt index 1d5b7e95d00..ecee620a087 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt @@ -24,8 +24,8 @@ FILE /localDelegatedProperties.kt FUN public fun test2(): kotlin.Unit BLOCK_BODY LOCAL_DELEGATED_PROPERTY var x: kotlin.Int - VAR DELEGATE val `x$delegate`: java.util.HashMap - CALL 'hashMapOf(): HashMap' type=java.util.HashMap origin=null + VAR DELEGATE val `x$delegate`: kotlin.collections.HashMap /* = java.util.HashMap */ + CALL 'hashMapOf(): HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null : String : Int FUN DELEGATED_PROPERTY_ACCESSOR local final fun (): kotlin.Int @@ -33,7 +33,7 @@ FILE /localDelegatedProperties.kt RETURN type=kotlin.Nothing from='(): Int' CALL 'getValue(Any?, KProperty<*>) on MutableMap: Int' type=kotlin.Int origin=null : Int - $receiver: GET_VAR '`x$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_VAR '`x$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' property: CALLABLE_REFERENCE 'x: Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN DELEGATED_PROPERTY_ACCESSOR local final fun (value: kotlin.Int): kotlin.Int @@ -42,7 +42,7 @@ FILE /localDelegatedProperties.kt TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Int CALL 'setValue(Any?, KProperty<*>, Int) on MutableMap: Unit' type=kotlin.Unit origin=null : Int - $receiver: GET_VAR '`x$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_VAR '`x$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' property: CALLABLE_REFERENCE 'x: Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/declarations/packageLevelProperties.txt b/compiler/testData/ir/irText/declarations/packageLevelProperties.txt index 11b26d29e64..5b8cc6d7080 100644 --- a/compiler/testData/ir/irText/declarations/packageLevelProperties.txt +++ b/compiler/testData/ir/irText/declarations/packageLevelProperties.txt @@ -76,9 +76,9 @@ FILE /packageLevelProperties.kt thisRef: CONST Null type=kotlin.Nothing? value='null' property: CALLABLE_REFERENCE 'test7: Int' type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE PROPERTY public var test8: kotlin.Int - FIELD DELEGATE val `test8$delegate`: java.util.HashMap + FIELD DELEGATE val `test8$delegate`: kotlin.collections.HashMap /* = java.util.HashMap */ EXPRESSION_BODY - CALL 'hashMapOf(): HashMap' type=java.util.HashMap origin=null + CALL 'hashMapOf(): HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null : String : Int FUN DELEGATED_PROPERTY_ACCESSOR public fun (): kotlin.Int @@ -86,7 +86,7 @@ FILE /packageLevelProperties.kt RETURN type=kotlin.Nothing from='(): Int' CALL 'getValue(Any?, KProperty<*>) on MutableMap: Int' type=kotlin.Int origin=null : Int - $receiver: GET_FIELD '`test8$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_FIELD '`test8$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' property: CALLABLE_REFERENCE 'test8: Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN DELEGATED_PROPERTY_ACCESSOR public fun (: kotlin.Int): kotlin.Unit @@ -94,7 +94,7 @@ FILE /packageLevelProperties.kt RETURN type=kotlin.Nothing from='(Int): Unit' CALL 'setValue(Any?, KProperty<*>, Int) on MutableMap: Unit' type=kotlin.Unit origin=null : Int - $receiver: GET_FIELD '`test8$delegate`: HashMap' type=java.util.HashMap origin=null + $receiver: GET_FIELD '`test8$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' property: CALLABLE_REFERENCE 'test8: Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE value: GET_VAR 'value-parameter : Int' type=kotlin.Int origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index c41c47b69ec..52dea448fc8 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -22510,6 +22510,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("typeAliasConstructorReturnType.kt") + public void testTypeAliasConstructorReturnType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt"); + doTest(fileName); + } + @TestMetadata("typeAliasConstructorTypeArgumentsInference.kt") public void testTypeAliasConstructorTypeArgumentsInference() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt index 5a057985589..32d14701c8c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt @@ -20,9 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.* interface TypeAliasConstructorDescriptor : ConstructorDescriptor { val underlyingConstructorDescriptor: ClassConstructorDescriptor @@ -122,15 +120,22 @@ class TypeAliasConstructorDescriptorImpl private constructor( val valueParameters = FunctionDescriptorImpl.getSubstitutedValueParameters(typeAliasConstructor, constructor.valueParameters, substitutor, false, false) ?: return null - val returnType = substitutor.substitute(constructor.returnType, Variance.INVARIANT) - ?: return null + val returnType = run { + val returnTypeNoAbbreviation = substitutor.substitute(constructor.returnType, Variance.INVARIANT) + ?: return null + val abbreviation = typeAliasDescriptor.defaultType + if (returnTypeNoAbbreviation is SimpleType && abbreviation is SimpleType) + returnTypeNoAbbreviation.withAbbreviation(abbreviation) + else + returnTypeNoAbbreviation + } val receiverParameterType = if (withDispatchReceiver) null else constructor.dispatchReceiverParameter?.let { substitutor.safeSubstitute(it.type, Variance.INVARIANT) } val dispatchReceiver = - if (withDispatchReceiver) constructor.dispatchReceiverParameter?.let { it.substitute(substitutor) } + if (withDispatchReceiver) constructor.dispatchReceiverParameter?.substitute(substitutor) else null typeAliasConstructor.initialize( diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt index 985ac9f452f..c68606130b7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt @@ -43,6 +43,7 @@ class AbbreviatedType(override val delegate: SimpleType, val abbreviation: Simpl } fun KotlinType.getAbbreviatedType(): AbbreviatedType? = unwrap() as? AbbreviatedType +fun KotlinType.getAbbreviation(): SimpleType? = getAbbreviatedType()?.abbreviation fun SimpleType.withAbbreviation(abbreviatedType: SimpleType): SimpleType { if (isError) return this diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java index 3238f31ba73..8a2c067f8fc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java @@ -229,11 +229,21 @@ public class TypeSubstitutor { return originalProjection; } + KotlinType substitutedAbbreviation = null; + SimpleType abbreviation = SpecialTypesKt.getAbbreviation(type); + if (abbreviation != null) { + substitutedAbbreviation = substitute(abbreviation, Variance.INVARIANT); + } + List substitutedArguments = substituteTypeArguments( type.getConstructor().getParameters(), type.getArguments(), recursionDepth); KotlinType substitutedType = TypeSubstitutionKt.replace(type, substitutedArguments, substitution.filterAnnotations(type.getAnnotations())); + if (substitutedType instanceof SimpleType && substitutedAbbreviation instanceof SimpleType) { + substitutedType = SpecialTypesKt.withAbbreviation((SimpleType) substitutedType, (SimpleType) substitutedAbbreviation); + } + return new TypeProjectionImpl(projectionKind, substitutedType); } diff --git a/idea/testData/diagnosticMessage/upperBoundViolatedInTypeAliasConstructorCall1.txt b/idea/testData/diagnosticMessage/upperBoundViolatedInTypeAliasConstructorCall1.txt index cfa0c19e631..a978a3074d1 100644 --- a/idea/testData/diagnosticMessage/upperBoundViolatedInTypeAliasConstructorCall1.txt +++ b/idea/testData/diagnosticMessage/upperBoundViolatedInTypeAliasConstructorCall1.txt @@ -1,3 +1,3 @@ -Type parameter bound for Tn in type inferred from type alias expansion for fun (x: T): Num +Type parameter bound for Tn in type inferred from type alias expansion for fun (x: T): N /* = Num */ is not satisfied: inferred type String is not a subtype of Number \ No newline at end of file