Better smart completion after "by" for override property with no explicit type specified
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
abstract class Base {
|
||||||
|
abstract val property: Number
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived : Base() {
|
||||||
|
override val property by <caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
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<Any?, Number>", attributes:"" }
|
||||||
|
// EXIST: { itemText: "Delegates.observable", tailText:"(initialValue: Number, crossinline onChange: (KProperty<*>, Number, Number) -> Unit) (kotlin.properties)", typeText: "ReadWriteProperty<Any?, Number>", attributes:"" }
|
||||||
|
// EXIST: { itemText: "Delegates.vetoable", tailText:"(initialValue: Number, crossinline onChange: (KProperty<*>, Number, Number) -> Boolean) (kotlin.properties)", typeText: "ReadWriteProperty<Any?, Number>", attributes:"" }
|
||||||
|
|
||||||
|
// EXIST: X1
|
||||||
|
// ABSENT: X2
|
||||||
|
// EXIST: X3
|
||||||
+6
@@ -1540,6 +1540,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("TopLevelVal.kt")
|
||||||
public void testTopLevelVal() throws Exception {
|
public void testTopLevelVal() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/propertyDelegate/TopLevelVal.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/propertyDelegate/TopLevelVal.kt");
|
||||||
|
|||||||
@@ -615,6 +615,7 @@ class ExpectedInfos(
|
|||||||
?: property.builtIns.nullableNothingType.toFuzzyType(emptyList())
|
?: property.builtIns.nullableNothingType.toFuzzyType(emptyList())
|
||||||
|
|
||||||
val explicitPropertyType = property.fuzzyReturnType()?.check { propertyDeclaration.typeReference != null }
|
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 typesWithGetDetector = TypesWithGetValueDetector(scope, indicesHelper, propertyOwnerType, explicitPropertyType)
|
||||||
val typesWithSetDetector = if (property.isVar) TypesWithSetValueDetector(scope, indicesHelper, propertyOwnerType) else null
|
val typesWithSetDetector = if (property.isVar) TypesWithSetValueDetector(scope, indicesHelper, propertyOwnerType) else null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user