diff --git a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/AnonymousTypeHandler.kt b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/AnonymousTypeHandler.kt index db567431e45..2833116bfa7 100644 --- a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/AnonymousTypeHandler.kt +++ b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/AnonymousTypeHandler.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.kapt3.mapJList +import org.jetbrains.kotlin.load.kotlin.TypeMappingMode import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny import org.jetbrains.kotlin.types.KotlinType @@ -93,7 +94,8 @@ class AnonymousTypeHandler(private val converter: ClassFileToSourceStubConverter val typeMapper = converter.kaptContext.generationState.typeMapper val treeMaker = converter.treeMaker - val selfType = treeMaker.Type(typeMapper.mapType(type)) + // Primitive types can't be anonymous, so if we get here, we want to map a class type or its generic argument + val selfType = treeMaker.Type(typeMapper.mapType(type, null, TypeMappingMode.GENERIC_ARGUMENT)) if (type.arguments.isEmpty()) return selfType return treeMaker.TypeApply(selfType, mapJList(type.arguments) { projection -> diff --git a/plugins/kapt3/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java index b93ca2785b3..15d4465fc5a 100644 --- a/plugins/kapt3/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java @@ -198,6 +198,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi doTest(fileName); } + @TestMetadata("kt19750.kt") + public void testKt19750() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/kt19750.kt"); + doTest(fileName); + } + @TestMetadata("mapEntry.kt") public void testMapEntry() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/mapEntry.kt"); diff --git a/plugins/kapt3/testData/converter/kt19750.kt b/plugins/kapt3/testData/converter/kt19750.kt new file mode 100644 index 00000000000..6e98b934c2f --- /dev/null +++ b/plugins/kapt3/testData/converter/kt19750.kt @@ -0,0 +1,11 @@ +package test + +class Test { + private val x = object : TypedListUpdateCallback { + override fun onInserted(position: Long, count: Long, item: String) {} + } +} + +interface TypedListUpdateCallback { + fun onInserted(position: C, count: C, item: T) +} \ No newline at end of file diff --git a/plugins/kapt3/testData/converter/kt19750.txt b/plugins/kapt3/testData/converter/kt19750.txt new file mode 100644 index 00000000000..9a062a45135 --- /dev/null +++ b/plugins/kapt3/testData/converter/kt19750.txt @@ -0,0 +1,23 @@ +package test; + +@kotlin.Metadata() +public final class Test { + private final test.TypedListUpdateCallback x = null; + + public Test() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public abstract interface TypedListUpdateCallback { + + public abstract void onInserted(@org.jetbrains.annotations.NotNull() + C position, @org.jetbrains.annotations.NotNull() + C count, @org.jetbrains.annotations.NotNull() + T item); +}