Kapt: Fix error type correction for super class constructor calls

This commit is contained in:
Yan Zhulanow
2018-09-28 20:49:12 +03:00
parent ba53ba37b0
commit f6bf35c1f5
3 changed files with 37 additions and 1 deletions
@@ -94,6 +94,11 @@ class ErrorTypeCorrector(
val typeAlias = target.source.getPsi() as? KtTypeAlias
val actualType = typeAlias?.getTypeReference() ?: return convert(target.expandedType)
return convert(actualType, typeAlias.getSubstitutions(type))
} else if (target is ClassConstructorDescriptor) {
val asmType = converter.kaptContext.generationState.typeMapper
.mapType(target.constructedClass.defaultType, null, TypeMappingMode.GENERIC_ARGUMENT)
baseExpression = converter.treeMaker.Type(asmType)
} else if (target is ClassDescriptor) {
// We only get here if some type were an error type. In other words, 'type' is either an error type or its argument,
// so it's impossible it to be unboxed primitive.
@@ -1,5 +1,6 @@
// CORRECT_ERROR_TYPES
// NO_VALIDATION
// WITH_RUNTIME
@file:Suppress("UNRESOLVED_REFERENCE", "DELEGATION_NOT_TO_INTERFACE", "SUPERTYPE_NOT_INITIALIZED")
package test
@@ -42,4 +43,9 @@ class Generics1 : Foo<String>()
class Generics2 : Foo<String>
class Generics3 : Foo<Bar, Baz, Boo<Baz, List<*>>, String>
class Generics3 : Foo<Bar, Baz, Boo<Baz, List<*>>, String>
class MappedList<R>() : AbstractList<R>(), List<R> {
override fun get(index: Int) = throw RuntimeException()
override val size get() = 0
}
@@ -68,6 +68,31 @@ package test;
import java.lang.System;
@kotlin.Metadata()
public final class MappedList<R extends java.lang.Object> extends kotlin.collections.AbstractList<R> implements java.util.List<? extends R> {
@org.jetbrains.annotations.NotNull()
@java.lang.Override()
public java.lang.Void get(int index) {
return null;
}
@java.lang.Override()
public int getSize() {
return 0;
}
public MappedList() {
super();
}
}
////////////////////
package test;
import java.lang.System;
@kotlin.Metadata()
public final class TBarBazCl extends test.Cl implements Bar, Baz {