diff --git a/idea/idea-completion/testData/smart/propertyDelegate/OverrideVal.kt b/idea/idea-completion/testData/smart/propertyDelegate/OverrideVal.kt new file mode 100644 index 00000000000..1d208ae14c9 --- /dev/null +++ b/idea/idea-completion/testData/smart/propertyDelegate/OverrideVal.kt @@ -0,0 +1,30 @@ +import kotlin.reflect.KProperty + +abstract class Base { + abstract val property: Number +} + +class Derived : Base() { + override val property by +} + +class X1 { + operator fun getValue(thisRef: Any, property: KProperty<*>): Number = 1 +} + +class X2 { + operator fun getValue(thisRef: Any, property: KProperty<*>): String = "" +} + +class X3 { + operator fun getValue(thisRef: Any, property: KProperty<*>): Int = "" +} + +// EXIST: lazy +// EXIST: { itemText: "Delegates.notNull", tailText:"() (kotlin.properties)", typeText: "ReadWriteProperty", attributes:"" } +// EXIST: { itemText: "Delegates.observable", tailText:"(initialValue: Number, crossinline onChange: (KProperty<*>, Number, Number) -> Unit) (kotlin.properties)", typeText: "ReadWriteProperty", attributes:"" } +// EXIST: { itemText: "Delegates.vetoable", tailText:"(initialValue: Number, crossinline onChange: (KProperty<*>, Number, Number) -> Boolean) (kotlin.properties)", typeText: "ReadWriteProperty", attributes:"" } + +// EXIST: X1 +// ABSENT: X2 +// EXIST: X3 diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java index f8130b8c253..4b6a35ebe1b 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java @@ -1540,6 +1540,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT doTest(fileName); } + @TestMetadata("OverrideVal.kt") + public void testOverrideVal() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/propertyDelegate/OverrideVal.kt"); + doTest(fileName); + } + @TestMetadata("TopLevelVal.kt") public void testTopLevelVal() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/propertyDelegate/TopLevelVal.kt"); diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt index 950a2ef79bc..3a5c933087a 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt @@ -615,6 +615,7 @@ class ExpectedInfos( ?: property.builtIns.nullableNothingType.toFuzzyType(emptyList()) val explicitPropertyType = property.fuzzyReturnType()?.check { propertyDeclaration.typeReference != null } + ?: property.overriddenDescriptors.singleOrNull()?.fuzzyReturnType() // for override properties use super property type as explicit (if not specified) val typesWithGetDetector = TypesWithGetValueDetector(scope, indicesHelper, propertyOwnerType, explicitPropertyType) val typesWithSetDetector = if (property.isVar) TypesWithSetValueDetector(scope, indicesHelper, propertyOwnerType) else null