diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt index 74bb482094e..4b5a1561434 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt @@ -153,7 +153,11 @@ class TypeAliasExpander( } else -> { val substitutedArguments = type.arguments.mapIndexed { i, originalArgument -> - expandTypeProjection(originalArgument, typeAliasExpansion, typeConstructor.parameters[i], recursionDepth + 1) + val projection = expandTypeProjection( + originalArgument, typeAliasExpansion, typeConstructor.parameters[i], recursionDepth + 1) + if (projection.isStarProjection) projection + else TypeProjectionImpl(projection.projectionKind, + TypeUtils.makeNullableIfNeeded(projection.type, originalArgument.type.isMarkedNullable)) } val substitutedType = type.replace(newArguments = substitutedArguments) diff --git a/compiler/testData/diagnostics/tests/typealias/inGenerics.kt b/compiler/testData/diagnostics/tests/typealias/inGenerics.kt new file mode 100644 index 00000000000..f13914ae8b8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/inGenerics.kt @@ -0,0 +1,12 @@ +typealias MyString = String + +class Container(val x: T) + +typealias MyStringContainer = Container + +val ms: MyString = "MyString" + +val msn: MyString? = null + +val msc: MyStringContainer = Container(ms) +val msc1 = MyStringContainer(null) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/typealias/inGenerics.txt b/compiler/testData/diagnostics/tests/typealias/inGenerics.txt new file mode 100644 index 00000000000..d4ea709cdd6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/inGenerics.txt @@ -0,0 +1,16 @@ +package + +public val ms: MyString /* = kotlin.String */ = "MyString" +public val msc: MyStringContainer /* = Container */ +public val msc1: Container +public val msn: MyString? /* = kotlin.String? */ = null + +public final class Container { + public constructor Container(/*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 typealias MyString = kotlin.String +public typealias MyStringContainer = Container diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.kt new file mode 100644 index 00000000000..285064d139a --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.kt @@ -0,0 +1,6 @@ +typealias Processor = (number: Int) -> Unit +typealias Handler = (String) -> Processor? + +fun x(handler: Handler) { + return handler("a")!!(1) +} diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.txt new file mode 100644 index 00000000000..825cc83f9bb --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.txt @@ -0,0 +1,5 @@ +package + +public fun x(/*0*/ handler: Handler /* = (kotlin.String) -> Processor? /* = ((kotlin.Int) -> kotlin.Unit)? */ */): kotlin.Unit +public typealias Handler = (kotlin.String) -> Processor? +public typealias Processor = (kotlin.Int) -> kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index c912a77a73e..eeb363ccae6 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -20229,6 +20229,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("inGenerics.kt") + public void testInGenerics() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/inGenerics.kt"); + doTest(fileName); + } + @TestMetadata("inSupertypesList.kt") public void testInSupertypesList() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/inSupertypesList.kt"); @@ -20391,6 +20397,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("typeAliasNotNull.kt") + public void testTypeAliasNotNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.kt"); + doTest(fileName); + } + @TestMetadata("typeAliasObject.kt") public void testTypeAliasObject() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasObject.kt");