From 8bf87a9a4ff36f07b202cb361273cbe659f05d62 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 18 May 2016 17:19:16 +0300 Subject: [PATCH] KT-11588 Type aliases Proper abbreviated type for '?' --- .../jetbrains/kotlin/resolve/PossiblyBareType.java | 11 ++++++++++- .../diagnostics/tests/typealias/simpleTypeAlias.txt | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java index 3cee33c3b44..b3eeee21984 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java @@ -91,7 +91,16 @@ public class PossiblyBareType { if (isBare()) { return isBareTypeNullable() ? this : bare(getBareTypeConstructor(), true); } - return type(TypeUtils.makeNullable(getActualType())); + + KotlinType nullableActualType = TypeUtils.makeNullable(getActualType()); + + KotlinType abbreviatedType = TypeCapabilitiesKt.getAbbreviatedType(getActualType()); + if (abbreviatedType == null) { + return type(nullableActualType); + } + else { + return type(TypeCapabilitiesKt.withAbbreviatedType(nullableActualType, TypeUtils.makeNullable(abbreviatedType))); + } } @NotNull diff --git a/compiler/testData/diagnostics/tests/typealias/simpleTypeAlias.txt b/compiler/testData/diagnostics/tests/typealias/simpleTypeAlias.txt index cd3162bf06d..3b95d62ed74 100644 --- a/compiler/testData/diagnostics/tests/typealias/simpleTypeAlias.txt +++ b/compiler/testData/diagnostics/tests/typealias/simpleTypeAlias.txt @@ -4,6 +4,6 @@ public typealias S = kotlin.String public typealias SS = S public typealias SSS = SS public val s1: SSS [= kotlin.String] = "" -public val s2: SSS [= kotlin.String?] = null +public val s2: SSS? [= kotlin.String?] = null public val s3: kotlin.collections.List? = null public val s4: kotlin.collections.List?>? = null