Retain nullability information for type alias arguments which are in turn type aliases #KT-13835 Fixed
This commit is contained in:
@@ -153,7 +153,11 @@ class TypeAliasExpander(
|
|||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val substitutedArguments = type.arguments.mapIndexed { i, originalArgument ->
|
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)
|
val substitutedType = type.replace(newArguments = substitutedArguments)
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
typealias MyString = String
|
||||||
|
|
||||||
|
class Container<T>(val x: T)
|
||||||
|
|
||||||
|
typealias MyStringContainer = Container<MyString?>
|
||||||
|
|
||||||
|
val ms: MyString = "MyString"
|
||||||
|
|
||||||
|
val msn: MyString? = null
|
||||||
|
|
||||||
|
val msc: MyStringContainer = Container(ms)
|
||||||
|
val msc1 = MyStringContainer(null)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public val ms: MyString /* = kotlin.String */ = "MyString"
|
||||||
|
public val msc: MyStringContainer /* = Container<MyString? /* = kotlin.String? */> */
|
||||||
|
public val msc1: Container<MyString? /* = kotlin.String? */>
|
||||||
|
public val msn: MyString? /* = kotlin.String? */ = null
|
||||||
|
|
||||||
|
public final class Container</*0*/ T> {
|
||||||
|
public constructor Container</*0*/ T>(/*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<MyString?>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
typealias Processor = (number: Int) -> Unit
|
||||||
|
typealias Handler = (String) -> Processor?
|
||||||
|
|
||||||
|
fun x(handler: Handler) {
|
||||||
|
return handler("a")!!(1)
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -20229,6 +20229,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("inSupertypesList.kt")
|
||||||
public void testInSupertypesList() throws Exception {
|
public void testInSupertypesList() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/inSupertypesList.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/inSupertypesList.kt");
|
||||||
@@ -20391,6 +20397,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("typeAliasObject.kt")
|
||||||
public void testTypeAliasObject() throws Exception {
|
public void testTypeAliasObject() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasObject.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasObject.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user