[KAPT] Don't fail on illegal delegate

Kapt ignores error diagnostics, but backend can't
 compile such code at all
This is workaround so backend won't fail.
#KT-46176 Fixed
This commit is contained in:
Andrey Zinovyev
2021-04-21 13:28:30 +03:00
committed by TeamCityServer
parent 0c0710bb79
commit 0c6066db74
5 changed files with 90 additions and 1 deletions
@@ -188,6 +188,12 @@ class JvmRuntimeTypes(
else -> if (isMutable) mutablePropertyReferences else propertyReferences
}
return classes[arity].defaultType
return if (arity >= 0) {
classes[arity].defaultType
} else {
//in case of ErrorUtils.ERROR_PROPERTY there would be no dispatchReceiverParameter and arity becomes negative
//so we just take zero argument reference class (because it is incorrect anyway)
classes[0].defaultType
}
}
}
@@ -209,6 +209,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
runTest("plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt");
}
@TestMetadata("incorrectDelegate.kt")
public void testIncorrectDelegate() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt");
}
@TestMetadata("inheritanceSimple.kt")
public void testInheritanceSimple() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/inheritanceSimple.kt");
@@ -210,6 +210,11 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
runTest("plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt");
}
@TestMetadata("incorrectDelegate.kt")
public void testIncorrectDelegate() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt");
}
@TestMetadata("inheritanceSimple.kt")
public void testInheritanceSimple() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/inheritanceSimple.kt");
@@ -0,0 +1,19 @@
class HomeFragment {
@Suppress("TOO_MANY_ARGUMENTS", "DELEGATE_SPECIAL_FUNCTION_MISSING")
private val categoryNewsListPresenter by moxyPresenter {
}
private val groupedNewsListAdapter: GroupedNewsListDelegateAdapter by lazy {
GroupedNewsListDelegateAdapter(
categoryNewsListPresenter::onWiFiClick
)
}
}
class GroupedNewsListDelegateAdapter(onWiFiClickListener: () -> Unit)
fun moxyPresenter() {
}
@@ -0,0 +1,54 @@
import java.lang.System;
@kotlin.Metadata()
public final class GroupedNewsListDelegateAdapter {
public GroupedNewsListDelegateAdapter(@org.jetbrains.annotations.NotNull()
kotlin.jvm.functions.Function0<kotlin.Unit> onWiFiClickListener) {
super();
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public final class HomeFragment {
private final kotlin.Unit categoryNewsListPresenter$delegate = null;
private final kotlin.Lazy groupedNewsListAdapter$delegate = null;
public HomeFragment() {
super();
}
private final error.NonExistentClass getCategoryNewsListPresenter() {
return null;
}
@kotlin.Suppress(names = {"TOO_MANY_ARGUMENTS", "DELEGATE_SPECIAL_FUNCTION_MISSING"})
@java.lang.Deprecated()
private static void getCategoryNewsListPresenter$annotations() {
}
private final GroupedNewsListDelegateAdapter getGroupedNewsListAdapter() {
return null;
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public final class IncorrectDelegateKt {
public IncorrectDelegateKt() {
super();
}
public static final void moxyPresenter() {
}
}