@@ -224,32 +224,29 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
224
224
}
225
225
}
226
226
227
- private fun checkExpressionList (expressionList : List <RsExpression >, parameterTypes : Array <RsType >) {
227
+ private fun checkExpressionList (context : PsiElement , expressionList : List <RsExpression >, parameterTypes : Array <RsType >) {
228
228
var index = 0
229
- expressionList.forEach {
229
+ val actualTypes = expressionList.map {
230
230
if (index < parameterTypes.size) {
231
231
it.typeHint = parameterTypes[index]
232
232
}
233
233
if (it.type == null ) {
234
234
it.accept(this )
235
235
}
236
- // TODO(Walied): Better error reporting here
237
236
val actualType = it.type
238
237
if (actualType != null ) {
239
- val expectedTuple = (0 until actualType.size).map { tupleIndex ->
240
- val expectedIndex = index + tupleIndex
241
- if (expectedIndex < parameterTypes.size) parameterTypes[expectedIndex] else RsErrorType
242
- }.joined()
243
- checkTypeMismatch(it, actualType, expectedTuple)
244
- index + = expectedTuple.size
238
+ index + = actualType.size
239
+ actualType
245
240
} else {
246
241
index++
242
+ RsErrorType
247
243
}
248
- }
244
+ }.joined()
245
+ checkTypeMismatch(context, actualTypes, parameterTypes.toList().joined())
249
246
}
250
247
251
248
fun checkArgumentList (argumentList : RsArgumentList , parameterTypes : Array <RsType >) {
252
- checkExpressionList(argumentList.expressionList, parameterTypes)
249
+ checkExpressionList(argumentList, argumentList .expressionList, parameterTypes)
253
250
}
254
251
255
252
override fun visitConditionExpression (o : RsConditionExpression ) {
@@ -594,7 +591,7 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
594
591
?.typeNameList
595
592
?.map { RsPrimitiveType .lookupReferencable(it.text) }
596
593
?.toTypedArray<RsType >()
597
- checkExpressionList(o.expressionList, expectedReturnList ? : emptyArray<RsType >())
594
+ checkExpressionList(o, o .expressionList, expectedReturnList ? : emptyArray<RsType >())
598
595
}
599
596
}
600
597
0 commit comments