[UAST] Fix mapping types containing type aliases

#KT-27935 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-04-03 20:08:23 +03:00
parent 73e1ddc505
commit 86fd4da567
15 changed files with 106 additions and 13 deletions
@@ -285,7 +285,7 @@ internal fun KotlinType.toPsiType(lightDeclaration: PsiModifierListOwner?, conte
.getLanguageVersionSettings(context)
val signatureWriter = BothSignatureWriter(BothSignatureWriter.Mode.TYPE)
val typeMappingMode = if (boxed) TypeMappingMode.GENERIC_ARGUMENT else TypeMappingMode.DEFAULT
val typeMappingMode = if (boxed) TypeMappingMode.GENERIC_ARGUMENT_UAST else TypeMappingMode.DEFAULT_UAST
val approximatedType = TypeApproximator(this.builtIns).approximateDeclarationType(this, true, languageVersionSettings)
typeMapper.mapType(approximatedType, signatureWriter, typeMappingMode)
@@ -0,0 +1,5 @@
typealias A = String
typealias My = (Map<A, Int>) -> Unit
fun My.foo(x: My): My? = null
fun Map<A, Int>.bar(x: Map<A, Int>): Map<A, Int>? = null
@@ -0,0 +1,18 @@
UFile (package = )
UClass (name = TypeAliasExpansionWithOtherAliasInArgumentKt)
UMethod (name = foo)
UParameter (name = $this$foo)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = x)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
ULiteralExpression (value = null)
UMethod (name = bar)
UParameter (name = $this$bar)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = x)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
ULiteralExpression (value = null)
@@ -0,0 +1,8 @@
public final class TypeAliasExpansionWithOtherAliasInArgumentKt {
public static final fun foo(@org.jetbrains.annotations.NotNull $this$foo: kotlin.jvm.functions.Function1<? super java.util.Map<java.lang.String,java.lang.Integer>,kotlin.Unit>, @org.jetbrains.annotations.NotNull x: kotlin.jvm.functions.Function1<? super java.util.Map<java.lang.String,java.lang.Integer>,kotlin.Unit>) : kotlin.jvm.functions.Function1<java.util.Map<java.lang.String,java.lang.Integer>,kotlin.Unit> {
return null
}
public static final fun bar(@org.jetbrains.annotations.NotNull $this$bar: java.util.Map<java.lang.String,java.lang.Integer>, @org.jetbrains.annotations.NotNull x: java.util.Map<java.lang.String,java.lang.Integer>) : java.util.Map<java.lang.String,java.lang.Integer> {
return null
}
}
@@ -150,6 +150,9 @@ class SimpleKotlinRenderLogTest : AbstractKotlinUastTest(), AbstractKotlinRender
@Test
fun testNonTrivialIdentifiers() = doTest("NonTrivialIdentifiers")
@Test
fun testTypeAliasExpansionWithOtherAliasInArgument() = doTest("TypeAliasExpansionWithOtherAliasInArgument")
}
fun withForceUInjectionHostValue(call: () -> Unit) {