KAPT: Fix an ISE when processing unresolved generic types
Error types that are generic could sometimes throw an ISE when generating the stub. This fixes KT-43786
This commit is contained in:
committed by
Alexander Udalov
parent
21fe0e80ff
commit
115bc6ac89
@@ -19,6 +19,10 @@ package org.jetbrains.kotlin.types
|
|||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
||||||
|
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext.replaceArguments
|
||||||
|
import org.jetbrains.kotlin.types.error.ErrorType
|
||||||
|
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||||
|
import org.jetbrains.kotlin.types.model.typeConstructor
|
||||||
|
|
||||||
abstract class TypeSubstitution {
|
abstract class TypeSubstitution {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -171,6 +175,10 @@ fun SimpleType.replace(
|
|||||||
return replaceAttributes(newAttributes)
|
return replaceAttributes(newAttributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this is ErrorType) {
|
||||||
|
return replaceArguments(newArguments)
|
||||||
|
}
|
||||||
|
|
||||||
return KotlinTypeFactory.simpleType(
|
return KotlinTypeFactory.simpleType(
|
||||||
newAttributes,
|
newAttributes,
|
||||||
constructor,
|
constructor,
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ class ErrorType @JvmOverloads internal constructor(
|
|||||||
|
|
||||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType = this
|
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType = this
|
||||||
|
|
||||||
|
fun replaceArguments(newArguments: List<TypeProjection>): ErrorType =
|
||||||
|
ErrorType(constructor, memberScope, kind, newArguments, isMarkedNullable, *formatParams)
|
||||||
|
|
||||||
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType =
|
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType =
|
||||||
ErrorType(constructor, memberScope, kind, arguments, newNullability, *formatParams)
|
ErrorType(constructor, memberScope, kind, arguments, newNullability, *formatParams)
|
||||||
|
|
||||||
@TypeRefinement
|
@TypeRefinement
|
||||||
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) = this
|
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) = this
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// CORRECT_ERROR_TYPES
|
||||||
|
|
||||||
|
@Suppress("UNRESOLVED_REFERENCE")
|
||||||
|
class Application {
|
||||||
|
lateinit var _preferencesDataStore: DataStore<Preferences>
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun get(): Application = error()
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getPreferencesDataStore() = get()._preferencesDataStore
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
@kotlin.Metadata()
|
||||||
|
@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"})
|
||||||
|
public final class Application {
|
||||||
|
public DataStore<Preferences> _preferencesDataStore;
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public static final Application.Companion Companion = null;
|
||||||
|
|
||||||
|
public Application() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public final DataStore<Preferences> get_preferencesDataStore() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void set_preferencesDataStore(@org.jetbrains.annotations.NotNull()
|
||||||
|
DataStore<Preferences> p0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.jvm.JvmStatic()
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public static final Application get() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.jvm.JvmStatic()
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public static final java.lang.Object getPreferencesDataStore() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public static final class Companion {
|
||||||
|
|
||||||
|
private Companion() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.jvm.JvmStatic()
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public final Application get() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.jvm.JvmStatic()
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public final java.lang.Object getPreferencesDataStore() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -451,6 +451,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt34569.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt34569.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt43786.kt")
|
||||||
|
public void testKt43786() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt43786.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lazyProperty.kt")
|
@TestMetadata("lazyProperty.kt")
|
||||||
public void testLazyProperty() throws Exception {
|
public void testLazyProperty() throws Exception {
|
||||||
|
|||||||
+6
@@ -451,6 +451,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt34569.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt34569.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt43786.kt")
|
||||||
|
public void testKt43786() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt43786.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lazyProperty.kt")
|
@TestMetadata("lazyProperty.kt")
|
||||||
public void testLazyProperty() throws Exception {
|
public void testLazyProperty() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user