diff --git a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/util.kt b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/util.kt index 2455e19ba7..f18d357b24 100644 --- a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/util.kt +++ b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/util.kt @@ -608,7 +608,11 @@ internal fun KaValueParameterSymbol.getDefaultValue(): KaAnnotationValue? { internal fun fillInDeepSubstitutor(context: KaType, substitutorBuilder: KaSubstitutorBuilder) { val unwrappedType = when (context) { is KaClassType -> context - is KaFlexibleType -> context.lowerBound as? KaClassType ?: return + is KaFlexibleType -> { + fillInDeepSubstitutor(context.upperBound, substitutorBuilder) + fillInDeepSubstitutor(context.lowerBound, substitutorBuilder) + return + } else -> return } val parameters = unwrappedType.symbol.typeParameters diff --git a/kotlin-analysis-api/testData/asMemberOf.kt b/kotlin-analysis-api/testData/asMemberOf.kt index 80b5e92702..d334058d2f 100644 --- a/kotlin-analysis-api/testData/asMemberOf.kt +++ b/kotlin-analysis-api/testData/asMemberOf.kt @@ -18,6 +18,18 @@ // WITH_RUNTIME // TEST PROCESSOR: AsMemberOfProcessor // EXPECTED: +// main.Test: MutableIterator<(String..String?)> +// main.Test: Iterator<(String..String?)> +// main.Test: MutableIterator<(String..String?)> +// lib.Test: MutableIterator<(String..String?)> +// lib.Test: Iterator<(String..String?)> +// lib.Test: MutableIterator<(String..String?)> +// main.TestKt: MutableIterator +// main.TestKt: Iterator +// main.TestKt: MutableIterator +// lib.TestKt: MutableIterator +// lib.TestKt: Iterator +// lib.TestKt: MutableIterator // Child1!! // intType: kotlin.Int!! // baseTypeArg1: kotlin.Int!! diff --git a/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/AsMemberOfProcessor.kt b/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/AsMemberOfProcessor.kt index 5fe8c08316..655cb5cf51 100644 --- a/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/AsMemberOfProcessor.kt +++ b/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/AsMemberOfProcessor.kt @@ -19,14 +19,17 @@ class AsMemberOfProcessor : AbstractTestProcessor() { listOf("main.Test", "lib.Test", "main.TestKt", "lib.TestKt").forEach { clsName -> resolver.getClassDeclarationByName(clsName)!!.let { cls -> - val listType = cls.getAllFunctions().single {it.simpleName.asString() == "f"}.returnType!!.resolve() + val listType = cls.getAllFunctions().single { it.simpleName.asString() == "f" }.returnType!!.resolve() val listDecl = listType.declaration as KSClassDeclaration val iterator = listDecl.getAllFunctions().single { it.simpleName.asString() == "iterator" } - println("$clsName: ${iterator.asMemberOf(listType).returnType}") - val listIterator = resolver.getClassDeclarationByName("kotlin.collections.List")!!.getDeclaredFunctions().single { it.simpleName.asString() == "iterator" } - println("$clsName: ${listIterator.asMemberOf(listType).returnType}") - val mutableListIterator = resolver.getClassDeclarationByName("kotlin.collections.MutableCollection")!!.getDeclaredFunctions().single { it.simpleName.asString() == "iterator" } - println("$clsName: ${mutableListIterator.asMemberOf(listType).returnType}") + results.add("$clsName: ${iterator.asMemberOf(listType).returnType}") + val listIterator = resolver.getClassDeclarationByName("kotlin.collections.List")!! + .getDeclaredFunctions().single { it.simpleName.asString() == "iterator" } + results.add("$clsName: ${listIterator.asMemberOf(listType).returnType}") + val mutableListIterator = + resolver.getClassDeclarationByName("kotlin.collections.MutableCollection")!! + .getDeclaredFunctions().single { it.simpleName.asString() == "iterator" } + results.add("$clsName: ${mutableListIterator.asMemberOf(listType).returnType}") } } diff --git a/test-utils/testData/api/asMemberOf.kt b/test-utils/testData/api/asMemberOf.kt index 0c4e5fa74d..cd2ade6b8b 100644 --- a/test-utils/testData/api/asMemberOf.kt +++ b/test-utils/testData/api/asMemberOf.kt @@ -18,6 +18,18 @@ // WITH_RUNTIME // TEST PROCESSOR: AsMemberOfProcessor // EXPECTED: +// main.Test: MutableIterator<(String..String?)> +// main.Test: Iterator<(String..String?)> +// main.Test: MutableIterator<(String..String?)> +// lib.Test: MutableIterator<(String..String?)> +// lib.Test: Iterator<(String..String?)> +// lib.Test: MutableIterator<(String..String?)> +// main.TestKt: MutableIterator +// main.TestKt: Iterator +// main.TestKt: MutableIterator +// lib.TestKt: MutableIterator +// lib.TestKt: Iterator +// lib.TestKt: MutableIterator // Child1!! // intType: kotlin.Int!! // baseTypeArg1: kotlin.Int!!