From f7dc59e2d691b93c4e5eeb641761933c238cf278 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 27 May 2015 16:02:09 +0300 Subject: [PATCH] Added 'UNKNOWN' argument mapping for cases with no argument expression --- .../kotlin/resolve/calls/model/ArgumentMapping.kt | 11 ++++++++--- .../jetbrains/kotlin/resolve/calls/util/callUtil.kt | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt index 876de88efc3..39caf37c688 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.model import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -public trait ArgumentMapping { +public interface ArgumentMapping { public fun isError(): Boolean } @@ -33,7 +33,9 @@ public enum class ArgumentMatchStatus(val isError: Boolean = true) { // The case when there is no type mismatch, but parameter has uninferred types: // fun foo(l: List) {}; val l = foo(emptyList()) - MATCH_MODULO_UNINFERRED_TYPES() + MATCH_MODULO_UNINFERRED_TYPES(), + + UNKNOWN() } public trait ArgumentMatch : ArgumentMapping { @@ -45,11 +47,14 @@ public trait ArgumentMatch : ArgumentMapping { class ArgumentMatchImpl(override val valueParameter: ValueParameterDescriptor): ArgumentMatch { private var _status: ArgumentMatchStatus? = null + override val status: ArgumentMatchStatus - get() = _status!! + get() = _status ?: ArgumentMatchStatus.UNKNOWN + fun recordMatchStatus(status: ArgumentMatchStatus) { _status = status } + fun replaceValueParameter(newValueParameter: ValueParameterDescriptor): ArgumentMatchImpl { val newArgumentMatch = ArgumentMatchImpl(newValueParameter) newArgumentMatch._status = _status diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index fc9d4f6b9a8..fc2352154f1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.utils.sure // resolved call public fun ResolvedCall.noErrorsInValueArguments(): Boolean { - return getCall().getValueArguments().all { argument -> argument.getArgumentExpression() != null/* isError() crashes otherwise!*/ && !getArgumentMapping(argument!!).isError() } + return getCall().getValueArguments().all { argument -> !getArgumentMapping(argument!!).isError() } } public fun ResolvedCall.hasUnmappedArguments(): Boolean {