diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 05674255b31..ef7bd6f145f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -13758,6 +13758,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt2872.kt"); } + @Test + @TestMetadata("kt46727.kt") + public void testKt46727() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.kt"); + } + @Test @TestMetadata("memberScopeOfCaptured.kt") public void testMemberScopeOfCaptured() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index c90102b5616..1cc117bfef7 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -13758,6 +13758,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt2872.kt"); } + @Test + @TestMetadata("kt46727.kt") + public void testKt46727() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.kt"); + } + @Test @TestMetadata("memberScopeOfCaptured.kt") public void testMemberScopeOfCaptured() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java index cb097a18770..c3515bfa702 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java @@ -684,6 +684,12 @@ public class FirOldFrontendForeignAnnotationsCompiledJavaTestGenerated extends A runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt47437.kt"); } + @Test + @TestMetadata("kt48261.kt") + public void testKt48261() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt48261.kt"); + } + @Test @TestMetadata("NonPlatformTypeParameter.kt") public void testNonPlatformTypeParameter() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java index b576a256a30..3e29e5162aa 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java @@ -684,6 +684,12 @@ public class FirOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTest runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt47437.kt"); } + @Test + @TestMetadata("kt48261.kt") + public void testKt48261() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt48261.kt"); + } + @Test @TestMetadata("NonPlatformTypeParameter.kt") public void testNonPlatformTypeParameter() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsSourceJavaTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsSourceJavaTestGenerated.java index b15f02e0757..02b12d83adf 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsSourceJavaTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendForeignAnnotationsSourceJavaTestGenerated.java @@ -684,6 +684,12 @@ public class FirOldFrontendForeignAnnotationsSourceJavaTestGenerated extends Abs runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt47437.kt"); } + @Test + @TestMetadata("kt48261.kt") + public void testKt48261() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt48261.kt"); + } + @Test @TestMetadata("NonPlatformTypeParameter.kt") public void testNonPlatformTypeParameter() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java index d3c5f3f89b0..015f15a4bc6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java @@ -371,8 +371,8 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito VariableDescriptor descriptor = BindingContextUtils.extractVariableFromResolvedCall(bindingContext, leftOperand); if (descriptor instanceof PropertyDescriptor) { - PropertySetterDescriptor setter = ((PropertyDescriptor) descriptor).getSetter(); - if (setter != null) return setter.getValueParameters().get(0).getType(); + KotlinType inType = ((PropertyDescriptor) descriptor).getInType(); + if (inType != null) return inType; } return leftOperandType; diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt index 0db03861746..4798c843eb0 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt @@ -884,6 +884,8 @@ open class IrBasedPropertyDescriptor(owner: IrProperty) : TODO("not implemented") } + override fun getInType(): KotlinType? = setter?.valueParameters?.get(0)?.type + override fun getUserData(key: CallableDescriptor.UserDataKey?): V? = null } @@ -1062,6 +1064,8 @@ open class IrBasedFieldDescriptor(owner: IrField) : PropertyDescriptor, IrBasedD override fun getBackingField(): FieldDescriptor? = null // TODO override fun getDelegateField(): FieldDescriptor? = null // TODO + override fun getInType(): KotlinType? = setter?.valueParameters?.get(0)?.type + override fun getUserData(key: CallableDescriptor.UserDataKey?): V? = null } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.fir.kt new file mode 100644 index 00000000000..d56997beed0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.fir.kt @@ -0,0 +1,111 @@ +// WITH_RUNTIME + +// FILE: Foo.java +public class Foo { + public T value; +} + +// FILE: Foo2.java +import org.jetbrains.annotations.Nullable; + +public class Foo2 { + public @Nullable T value; +} + +// FILE: Foo3.java +import org.jetbrains.annotations.NotNull; + +public class Foo3 { + public @NotNull T value; +} + +// FILE: main.kt + +// --- from Java --- // + +fun takeStarFoo(x: Foo<*>) { + x.value = "test" +} + +fun main1() { + val foo = Foo() + foo.value = 1 + takeStarFoo(foo) + println(foo.value) // CCE: String cannot be cast to Number +} + +// --- from Kotlin --- // + +public class Bar { + var value: T = null as T +} + +fun takeStarBar(x: Bar<*>) { + x.value = "test" +} + +fun main2() { + val bar = Bar() + bar.value = 1 + takeStarBar(bar) + println(bar.value) // CCE: String cannot be cast to Number +} + +// --- from Java (nullable) --- // + +fun takeStarFoo2(x: Foo2<*>) { + x.value = "test" +} + +fun main3() { + val foo = Foo2() + foo.value = 1 + takeStarFoo2(foo) + println(foo.value) // CCE: String cannot be cast to Number +} + +// --- from Kotlin (nullable) --- // +public class Bar2 { + var value: T? = null +} + +fun takeStarBar2(x: Bar2<*>) { + x.value = "test" +} + +fun main4() { + val bar = Bar2() + bar.value = 1 + takeStarBar2(bar) + println(bar.value) // CCE: String cannot be cast to Number +} + +// --- from Java (not-null) --- // + +fun takeStarFoo3(x: Foo3<*>) { + x.value = "test" +} + +fun main5() { + val foo = Foo3() + foo.value = 1 + takeStarFoo3(foo) + println(foo.value) // CCE: String cannot be cast to Number +} + +// --- from Kotlin (field) --- // +class Bar3 { + @JvmField + var value: T? = null +} + +fun takeStarBar3(x: Bar3<*>) { + x.value = "test" +} + +fun main6() { + val bar = Bar3() + bar.value = 1 + takeStarBar3(bar) + println(bar.value) // CCE: String cannot be cast to Number +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.kt new file mode 100644 index 00000000000..757c449183c --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.kt @@ -0,0 +1,111 @@ +// WITH_RUNTIME + +// FILE: Foo.java +public class Foo { + public T value; +} + +// FILE: Foo2.java +import org.jetbrains.annotations.Nullable; + +public class Foo2 { + public @Nullable T value; +} + +// FILE: Foo3.java +import org.jetbrains.annotations.NotNull; + +public class Foo3 { + public @NotNull T value; +} + +// FILE: main.kt + +// --- from Java --- // + +fun takeStarFoo(x: Foo<*>) { + x.value = "test" +} + +fun main1() { + val foo = Foo() + foo.value = 1 + takeStarFoo(foo) + println(foo.value) // CCE: String cannot be cast to Number +} + +// --- from Kotlin --- // + +public class Bar { + var value: T = null as T +} + +fun takeStarBar(x: Bar<*>) { + x.value = "test" +} + +fun main2() { + val bar = Bar() + bar.value = 1 + takeStarBar(bar) + println(bar.value) // CCE: String cannot be cast to Number +} + +// --- from Java (nullable) --- // + +fun takeStarFoo2(x: Foo2<*>) { + x.value = "test" +} + +fun main3() { + val foo = Foo2() + foo.value = 1 + takeStarFoo2(foo) + println(foo.value) // CCE: String cannot be cast to Number +} + +// --- from Kotlin (nullable) --- // +public class Bar2 { + var value: T? = null +} + +fun takeStarBar2(x: Bar2<*>) { + x.value = ; public final var value: T? defined in Bar2")!>"test" +} + +fun main4() { + val bar = Bar2() + bar.value = 1 + takeStarBar2(bar) + println(bar.value) // CCE: String cannot be cast to Number +} + +// --- from Java (not-null) --- // + +fun takeStarFoo3(x: Foo3<*>) { + x.value = "test" +} + +fun main5() { + val foo = Foo3() + foo.value = 1 + takeStarFoo3(foo) + println(foo.value) // CCE: String cannot be cast to Number +} + +// --- from Kotlin (field) --- // +class Bar3 { + @JvmField + var value: T? = null +} + +fun takeStarBar3(x: Bar3<*>) { + x.value = ; public final var value: T? defined in Bar3")!>"test" +} + +fun main6() { + val bar = Bar3() + bar.value = 1 + takeStarBar3(bar) + println(bar.value) // CCE: String cannot be cast to Number +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.txt b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.txt new file mode 100644 index 00000000000..7b8ac704e39 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.txt @@ -0,0 +1,53 @@ +package + +public fun main1(): kotlin.Unit +public fun main2(): kotlin.Unit +public fun main3(): kotlin.Unit +public fun main4(): kotlin.Unit +public fun main5(): kotlin.Unit +public fun takeStarBar(/*0*/ x: Bar<*>): kotlin.Unit +public fun takeStarBar2(/*0*/ x: Bar2<*>): kotlin.Unit +public fun takeStarFoo(/*0*/ x: Foo<*>): kotlin.Unit +public fun takeStarFoo2(/*0*/ x: Foo2<*>): kotlin.Unit +public fun takeStarFoo3(/*0*/ x: Foo3<*>): kotlin.Unit + +public final class Bar { + public constructor Bar() + public final var value: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Bar2 { + public constructor Bar2() + public final var value: T? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class Foo { + public constructor Foo() + public final var value: T! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class Foo2 { + public constructor Foo2() + @org.jetbrains.annotations.Nullable public final var value: T? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class Foo3 { + public constructor Foo3() + @org.jetbrains.annotations.Nullable public final var value: T? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 53cf2e186a5..8073dd7f5e5 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -13764,6 +13764,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt2872.kt"); } + @Test + @TestMetadata("kt46727.kt") + public void testKt46727() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727.kt"); + } + @Test @TestMetadata("memberScopeOfCaptured.kt") public void testMemberScopeOfCaptured() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java index 685fa024920..f47c439d389 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java @@ -684,6 +684,12 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt47437.kt"); } + @Test + @TestMetadata("kt48261.kt") + public void testKt48261() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt48261.kt"); + } + @Test @TestMetadata("NonPlatformTypeParameter.kt") public void testNonPlatformTypeParameter() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java index 232a42da463..70efc6e89a7 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java @@ -684,6 +684,12 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt47437.kt"); } + @Test + @TestMetadata("kt48261.kt") + public void testKt48261() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt48261.kt"); + } + @Test @TestMetadata("NonPlatformTypeParameter.kt") public void testNonPlatformTypeParameter() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java index 8f007f7291a..60c78371bdb 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java @@ -684,6 +684,12 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt47437.kt"); } + @Test + @TestMetadata("kt48261.kt") + public void testKt48261() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/kt48261.kt"); + } + @Test @TestMetadata("NonPlatformTypeParameter.kt") public void testNonPlatformTypeParameter() throws Exception { diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java index f1e4c46105d..7caf31ea1b2 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java @@ -37,6 +37,8 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja @Nullable private final Pair, ?> singleUserData; + private KotlinType inType = null; + protected JavaPropertyDescriptor( @NotNull DeclarationDescriptor containingDeclaration, @NotNull Annotations annotations, @@ -172,6 +174,18 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja (!TypeEnhancementKt.hasEnhancedNullability(type) || KotlinBuiltIns.isString(type)); } + @Override + public void setInType(@NotNull KotlinType inType) { + this.inType = inType; + } + + @Override + public @Nullable KotlinType getInType() { + PropertySetterDescriptor setter = getSetter(); + KotlinType setterType = setter != null ? setter.getValueParameters().get(0).getType() : null; + return setterType != null ? setterType : inType; + } + @Nullable @Override @SuppressWarnings("unchecked") diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PropertyDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PropertyDescriptor.java index f1b02ea8a4e..cb5ca7ccae4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PropertyDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PropertyDescriptor.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import java.util.Collection; @@ -65,4 +66,7 @@ public interface PropertyDescriptor extends VariableDescriptorWithAccessors, Cal @NotNull @Override CopyBuilder newCopyBuilder(); + + @Nullable + KotlinType getInType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java index d97b5a938c2..35a65b1cd5d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java @@ -108,6 +108,15 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp isExpect, isActual, isExternal, isDelegated); } + public void setInType(@NotNull KotlinType inType) { + /* Do nothing as the corresponding setter is generated by default */ + } + + @Override + public KotlinType getInType() { + return setter != null ? setter.getValueParameters().get(0).getType() : null; + } + public void setType( @NotNull KotlinType outType, @ReadOnly @NotNull List typeParameters, @@ -400,6 +409,12 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp return null; // TODO : tell the user that the property was projected out } + KotlinType inType = substitutor.substitute(originalOutType, Variance.IN_VARIANCE); + + if (inType != null) { + substitutedDescriptor.setInType(inType); + } + ReceiverParameterDescriptor substitutedDispatchReceiver; ReceiverParameterDescriptor dispatchReceiver = copyConfiguration.dispatchReceiverParameter; if (dispatchReceiver != null) {