Kapt: Generic arguments in anonymous type should always be mapped to boxed types (KT-19750)

This commit is contained in:
Yan Zhulanow
2017-08-17 18:51:52 +03:00
committed by Yan Zhulanow
parent 4d9a612a64
commit 84e59601c1
4 changed files with 43 additions and 1 deletions
@@ -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 ->
@@ -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");
+11
View File
@@ -0,0 +1,11 @@
package test
class Test<T : CharSequence, N : Number> {
private val x = object : TypedListUpdateCallback<String, Long> {
override fun onInserted(position: Long, count: Long, item: String) {}
}
}
interface TypedListUpdateCallback<T : Any, C : Number> {
fun onInserted(position: C, count: C, item: T)
}
+23
View File
@@ -0,0 +1,23 @@
package test;
@kotlin.Metadata()
public final class Test<T extends java.lang.CharSequence, N extends java.lang.Number> {
private final test.TypedListUpdateCallback<java.lang.String, java.lang.Long> x = null;
public Test() {
super();
}
}
////////////////////
package test;
@kotlin.Metadata()
public abstract interface TypedListUpdateCallback<T extends java.lang.Object, C extends java.lang.Number> {
public abstract void onInserted(@org.jetbrains.annotations.NotNull()
C position, @org.jetbrains.annotations.NotNull()
C count, @org.jetbrains.annotations.NotNull()
T item);
}