Fix true and false in when entry with subject broken before
This commit is contained in:
@@ -145,7 +145,7 @@ sealed class ArgumentPositionData(val function: FunctionDescriptor) : ExpectedIn
|
|||||||
|
|
||||||
class ReturnValueAdditionalData(val callable: CallableDescriptor) : ExpectedInfo.AdditionalData
|
class ReturnValueAdditionalData(val callable: CallableDescriptor) : ExpectedInfo.AdditionalData
|
||||||
|
|
||||||
object WhenEntryAdditionalData : ExpectedInfo.AdditionalData
|
class WhenEntryAdditionalData(val whenWithSubject: Boolean) : ExpectedInfo.AdditionalData
|
||||||
|
|
||||||
class ExpectedInfos(
|
class ExpectedInfos(
|
||||||
val bindingContext: BindingContext,
|
val bindingContext: BindingContext,
|
||||||
@@ -491,10 +491,10 @@ class ExpectedInfos(
|
|||||||
val subject = whenExpression.getSubjectExpression()
|
val subject = whenExpression.getSubjectExpression()
|
||||||
if (subject != null) {
|
if (subject != null) {
|
||||||
val subjectType = bindingContext.getType(subject) ?: return null
|
val subjectType = bindingContext.getType(subject) ?: return null
|
||||||
return listOf(ExpectedInfo(subjectType, null, null, additionalData = WhenEntryAdditionalData))
|
return listOf(ExpectedInfo(subjectType, null, null, additionalData = WhenEntryAdditionalData(whenWithSubject = true)))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return listOf(ExpectedInfo(resolutionFacade.moduleDescriptor.builtIns.booleanType, null, null, additionalData = WhenEntryAdditionalData))
|
return listOf(ExpectedInfo(resolutionFacade.moduleDescriptor.builtIns.booleanType, null, null, additionalData = WhenEntryAdditionalData(whenWithSubject = false)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,10 @@ object KeywordValues {
|
|||||||
) {
|
) {
|
||||||
if (callTypeAndReceiver is CallTypeAndReceiver.DEFAULT) {
|
if (callTypeAndReceiver is CallTypeAndReceiver.DEFAULT) {
|
||||||
val booleanInfoMatcher = matcher@ { info: ExpectedInfo ->
|
val booleanInfoMatcher = matcher@ { info: ExpectedInfo ->
|
||||||
// no sense in true or false as when entry
|
// no sense in true or false as when entry for when with no subject
|
||||||
if (info.additionalData is WhenEntryAdditionalData) return@matcher ExpectedInfoMatch.noMatch
|
if (info.additionalData is WhenEntryAdditionalData && !info.additionalData.whenWithSubject) {
|
||||||
|
return@matcher ExpectedInfoMatch.noMatch
|
||||||
|
}
|
||||||
|
|
||||||
if (info.fuzzyType?.type?.isBooleanOrNullableBoolean() ?: false)
|
if (info.fuzzyType?.type?.isBooleanOrNullableBoolean() ?: false)
|
||||||
ExpectedInfoMatch.match(TypeSubstitutor.EMPTY)
|
ExpectedInfoMatch.match(TypeSubstitutor.EMPTY)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun foo(b: Boolean?) {
|
||||||
|
when (b) {
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: true
|
||||||
|
// EXIST: false
|
||||||
|
// EXIST: null
|
||||||
+6
@@ -1602,5 +1602,11 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
|||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/whenEntry/WhenWithNoSubject2.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/whenEntry/WhenWithNoSubject2.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithSubjectTrueFalse.kt")
|
||||||
|
public void testWhenWithSubjectTrueFalse() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/whenEntry/WhenWithSubjectTrueFalse.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user