diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt index 69da4e34ae4..991decb85b4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt @@ -19,6 +19,10 @@ package org.jetbrains.kotlin.types import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations 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 { companion object { @@ -171,6 +175,10 @@ fun SimpleType.replace( return replaceAttributes(newAttributes) } + if (this is ErrorType) { + return replaceArguments(newArguments) + } + return KotlinTypeFactory.simpleType( newAttributes, constructor, diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorType.kt index 85e5f7fcda8..f66e03b3c3d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorType.kt @@ -24,8 +24,11 @@ class ErrorType @JvmOverloads internal constructor( override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType = this + fun replaceArguments(newArguments: List): ErrorType = + ErrorType(constructor, memberScope, kind, newArguments, isMarkedNullable, *formatParams) + override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType = - ErrorType(constructor, memberScope, kind, arguments, newNullability, *formatParams) + ErrorType(constructor, memberScope, kind, arguments, newNullability, *formatParams) @TypeRefinement override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) = this diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.kt b/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.kt new file mode 100644 index 00000000000..06f4b0f18ea --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.kt @@ -0,0 +1,14 @@ +// CORRECT_ERROR_TYPES + +@Suppress("UNRESOLVED_REFERENCE") +class Application { + lateinit var _preferencesDataStore: DataStore + + companion object { + @JvmStatic + fun get(): Application = error() + + @JvmStatic + fun getPreferencesDataStore() = get()._preferencesDataStore + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.txt new file mode 100644 index 00000000000..1e5ac37ba49 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.txt @@ -0,0 +1,52 @@ +@kotlin.Metadata() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) +public final class Application { + public DataStore _preferencesDataStore; + @org.jetbrains.annotations.NotNull() + public static final Application.Companion Companion = null; + + public Application() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final DataStore get_preferencesDataStore() { + return null; + } + + public final void set_preferencesDataStore(@org.jetbrains.annotations.NotNull() + DataStore 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; + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java index 40b7283dc49..d8a63471848 100644 --- a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java @@ -451,6 +451,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi 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 @TestMetadata("lazyProperty.kt") public void testLazyProperty() throws Exception { diff --git a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java index dd077fead83..1b90464f7e0 100644 --- a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java @@ -451,6 +451,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla 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 @TestMetadata("lazyProperty.kt") public void testLazyProperty() throws Exception {