Kapt: Generic arguments in anonymous type should always be mapped to boxed types (KT-19750)
This commit is contained in:
committed by
Yan Zhulanow
parent
4d9a612a64
commit
84e59601c1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.kapt3.mapJList
|
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.builtIns
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
@@ -93,7 +94,8 @@ class AnonymousTypeHandler(private val converter: ClassFileToSourceStubConverter
|
|||||||
val typeMapper = converter.kaptContext.generationState.typeMapper
|
val typeMapper = converter.kaptContext.generationState.typeMapper
|
||||||
|
|
||||||
val treeMaker = converter.treeMaker
|
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
|
if (type.arguments.isEmpty()) return selfType
|
||||||
|
|
||||||
return treeMaker.TypeApply(selfType, mapJList(type.arguments) { projection ->
|
return treeMaker.TypeApply(selfType, mapJList(type.arguments) { projection ->
|
||||||
|
|||||||
+6
@@ -198,6 +198,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("mapEntry.kt")
|
||||||
public void testMapEntry() throws Exception {
|
public void testMapEntry() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/mapEntry.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/mapEntry.kt");
|
||||||
|
|||||||
+11
@@ -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
@@ -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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user