No true/false for if-condition too
This commit is contained in:
@@ -147,6 +147,8 @@ class ReturnValueAdditionalData(val callable: CallableDescriptor) : ExpectedInfo
|
|||||||
|
|
||||||
class WhenEntryAdditionalData(val whenWithSubject: Boolean) : ExpectedInfo.AdditionalData
|
class WhenEntryAdditionalData(val whenWithSubject: Boolean) : ExpectedInfo.AdditionalData
|
||||||
|
|
||||||
|
object IfConditionAdditionalData : ExpectedInfo.AdditionalData
|
||||||
|
|
||||||
class ExpectedInfos(
|
class ExpectedInfos(
|
||||||
val bindingContext: BindingContext,
|
val bindingContext: BindingContext,
|
||||||
val resolutionFacade: ResolutionFacade,
|
val resolutionFacade: ResolutionFacade,
|
||||||
@@ -423,7 +425,7 @@ class ExpectedInfos(
|
|||||||
private fun calculateForIf(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
private fun calculateForIf(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
||||||
val ifExpression = (expressionWithType.getParent() as? JetContainerNode)?.getParent() as? JetIfExpression ?: return null
|
val ifExpression = (expressionWithType.getParent() as? JetContainerNode)?.getParent() as? JetIfExpression ?: return null
|
||||||
return when (expressionWithType) {
|
return when (expressionWithType) {
|
||||||
ifExpression.getCondition() -> listOf(ExpectedInfo(resolutionFacade.moduleDescriptor.builtIns.booleanType, null, Tail.RPARENTH))
|
ifExpression.getCondition() -> listOf(ExpectedInfo(resolutionFacade.moduleDescriptor.builtIns.booleanType, null, Tail.RPARENTH, additionalData = IfConditionAdditionalData))
|
||||||
|
|
||||||
ifExpression.getThen() -> calculate(ifExpression).map { ExpectedInfo(it.filter, it.expectedName, Tail.ELSE) }
|
ifExpression.getThen() -> calculate(ifExpression).map { ExpectedInfo(it.filter, it.expectedName, Tail.ELSE) }
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,13 @@ 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 for when with no subject
|
// no sense in true or false as if-condition or when entry for when with no subject
|
||||||
if (info.additionalData is WhenEntryAdditionalData && !info.additionalData.whenWithSubject) {
|
val skipTrueFalse = when (info.additionalData) {
|
||||||
|
is IfConditionAdditionalData -> true
|
||||||
|
is WhenEntryAdditionalData -> !info.additionalData.whenWithSubject
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
if (skipTrueFalse) {
|
||||||
return@matcher ExpectedInfoMatch.noMatch
|
return@matcher ExpectedInfoMatch.noMatch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ fun bar(b: Boolean, c: Char){
|
|||||||
|
|
||||||
// EXIST: b
|
// EXIST: b
|
||||||
// ABSENT: c
|
// ABSENT: c
|
||||||
|
// ABSENT: true
|
||||||
|
// ABSENT: false
|
||||||
|
|||||||
Reference in New Issue
Block a user