Do not check argumentMapping.isError()
Argument matching status can be considered an "error" in resolve, even though it is not a compilation error and doesn't prevent code from being generated. Actually, we should only check if the argument matching status is ArgumentMatch. #KT-18294 Fixed
This commit is contained in:
@@ -48,10 +48,8 @@ fun KtElement.deparenthesize(): KtElement =
|
||||
fun ResolvedCall<*>.isValueArgumentReorderingRequired(): Boolean {
|
||||
var lastValueParameterIndex = -1
|
||||
for (valueArgument in call.valueArguments) {
|
||||
val argumentMapping = getArgumentMapping(valueArgument)
|
||||
if (argumentMapping !is ArgumentMatch || argumentMapping.isError()) {
|
||||
throw Exception("Value argument in function call is mapped with error")
|
||||
}
|
||||
val argumentMapping = getArgumentMapping(valueArgument) as? ArgumentMatch ?:
|
||||
throw Exception("Value argument in function call is mapped with error")
|
||||
val argumentIndex = argumentMapping.valueParameter.index
|
||||
if (argumentIndex < lastValueParameterIndex) {
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fun <R : Number> Number.convert(): R = TODO()
|
||||
|
||||
fun foo(arg: Number) {
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val x: Int = 0
|
||||
foo(x.convert())
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
FILE /argumentMappedWithError.kt
|
||||
FUN public fun <R : kotlin.Number> kotlin.Number.convert(): R
|
||||
TYPE_PARAMETER <R : kotlin.Number>
|
||||
$receiver: VALUE_PARAMETER this@convert: Number
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='convert() on Number: R'
|
||||
CALL 'TODO(): Nothing' type=kotlin.Nothing origin=null
|
||||
FUN public fun foo(arg: kotlin.Number): kotlin.Unit
|
||||
VALUE_PARAMETER value-parameter arg: kotlin.Number
|
||||
BLOCK_BODY
|
||||
FUN public fun main(args: kotlin.Array<kotlin.String>): kotlin.Unit
|
||||
VALUE_PARAMETER value-parameter args: kotlin.Array<kotlin.String>
|
||||
BLOCK_BODY
|
||||
VAR val x: kotlin.Int = 0
|
||||
CONST Int type=kotlin.Int value='0'
|
||||
CALL 'foo(Number): Unit' type=kotlin.Unit origin=null
|
||||
arg: CALL 'convert() on Number: Number' type=kotlin.Number origin=null
|
||||
<R : Number>: Number
|
||||
$receiver: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
@@ -467,6 +467,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/expressions"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("argumentMappedWithError.kt")
|
||||
public void testArgumentMappedWithError() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/argumentMappedWithError.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayAccess.kt")
|
||||
public void testArrayAccess() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/arrayAccess.kt");
|
||||
|
||||
Reference in New Issue
Block a user