Kapt: Fix supertype conversion for DefaultImpls (KT-28306)

This commit is contained in:
Yan Zhulanow
2019-02-01 21:30:37 +03:00
parent 3a768060ca
commit 1c824655d4
4 changed files with 61 additions and 0 deletions
@@ -425,6 +425,11 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
}
val declaration = kaptContext.origins[clazz]?.element as? KtClassOrObject ?: return defaultSuperTypes
val declarationDescriptor = kaptContext.bindingContext[BindingContext.CLASS, declaration] ?: return defaultSuperTypes
if (typeMapper.mapType(declarationDescriptor) != Type.getObjectType(clazz.name)) {
return defaultSuperTypes
}
val (superClass, superInterfaces) = partitionSuperTypes(declaration) ?: return defaultSuperTypes
@@ -269,6 +269,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt27126.kt");
}
@TestMetadata("kt28306.kt")
public void testKt28306() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt28306.kt");
}
@TestMetadata("lazyProperty.kt")
public void testLazyProperty() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.kt");
@@ -0,0 +1,9 @@
// CORRECT_ERROR_TYPES
package foo
interface InterfaceWithDefaults<T> {
fun foo() {}
}
interface SubInterface<T> : InterfaceWithDefaults<T>
@@ -0,0 +1,42 @@
package foo;
import java.lang.System;
@kotlin.Metadata()
public abstract interface InterfaceWithDefaults<T extends java.lang.Object> {
public abstract void foo();
@kotlin.Metadata()
public static final class DefaultImpls {
public DefaultImpls() {
super();
}
public static <T extends java.lang.Object>void foo(foo.InterfaceWithDefaults<T> $this) {
}
}
}
////////////////////
package foo;
import java.lang.System;
@kotlin.Metadata()
public abstract interface SubInterface<T extends java.lang.Object> extends foo.InterfaceWithDefaults<T> {
@kotlin.Metadata()
public static final class DefaultImpls {
public DefaultImpls() {
super();
}
@java.lang.Override()
public static <T extends java.lang.Object>void foo(foo.SubInterface<T> $this) {
}
}
}