[FE 1.0] Fix mistakes in error messages for resolution ambiguity with stub types
^KT-51022 Fixed
This commit is contained in:
+6
-5
@@ -926,11 +926,12 @@ public class DefaultErrorMessages {
|
||||
ELEMENT_TEXT, STRING, ELEMENT_TEXT);
|
||||
|
||||
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY, "Overload resolution ambiguity: {0}", AMBIGUOUS_CALLS);
|
||||
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY_BECAUSE_OF_STUB_TYPES, "The builder `{0}` you are using has a type argument for type parameter(s) `{1}` that was not explicitly specified. " +
|
||||
"Without knowing the type of `{1}` compiler cannot choose which overloaded function `{2}` to call here. " +
|
||||
"Please, either specify the type `{1}` explicitly in `{0}` builder or use explicit cast to a specific type for parameter or receiver (see specific errors on them).", STRING, STRING, STRING);
|
||||
MAP.put(STUB_TYPE_IN_ARGUMENT_CAUSES_AMBIGUITY, "Type of an argument hasn't inferred yet. To disambiguate this call, please use explicit cast for the parameter to {1} if you rely a type argument for type parameter(s) {2} to be inferred to {3}", RENDER_TYPE, STRING, STRING);
|
||||
MAP.put(STUB_TYPE_IN_RECEIVER_CAUSES_AMBIGUITY, "Type of a receiver hasn't inferred yet. To disambiguate this call, please use explicit cast for the receiver to {1} if you rely a type argument for type parameter(s) {2} to be inferred to {3}", RENDER_TYPE, STRING, STRING, null);
|
||||
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY_BECAUSE_OF_STUB_TYPES, "No type argument for type parameter(s) `{1}` of the `{0}` builder specified. " +
|
||||
"Cannot choose which overloaded function `{2}` to call. " +
|
||||
"To disambiguate this call, either use an explicit type cast for a parameter or a receiver (see specific errors on them) or specify the type `{1}` explicitly.",
|
||||
STRING, STRING, STRING);
|
||||
MAP.put(STUB_TYPE_IN_ARGUMENT_CAUSES_AMBIGUITY, "The type of an argument hasn''t been inferred yet. To disambiguate this call, explicitly cast it to `{0}` if you want the builder''s type parameter(s) `{1}` to be inferred to `{2}`.", RENDER_TYPE, STRING, STRING);
|
||||
MAP.put(STUB_TYPE_IN_RECEIVER_CAUSES_AMBIGUITY, "The type of a receiver hasn''t been inferred yet. To disambiguate this call, explicitly cast it to `{0}` if you want the builder''s type parameter(s) `{1}` to be inferred to `{2}`.", RENDER_TYPE, STRING, STRING, null);
|
||||
MAP.put(NONE_APPLICABLE, "None of the following functions can be called with the arguments supplied: {0}", AMBIGUOUS_CALLS);
|
||||
MAP.put(CANNOT_COMPLETE_RESOLVE, "Cannot choose among the following candidates without completing type inference: {0}", AMBIGUOUS_CALLS);
|
||||
MAP.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: {0}", AMBIGUOUS_CALLS);
|
||||
|
||||
+7
-7
@@ -112,9 +112,9 @@ class ResolutionWithStubTypesChecker(private val kotlinCallResolver: KotlinCallR
|
||||
context.trace.report(
|
||||
OVERLOAD_RESOLUTION_AMBIGUITY_BECAUSE_OF_STUB_TYPES.on(
|
||||
calleeExpression,
|
||||
builderCalleeExpression.toString(),
|
||||
typeVariablesCausedAmbiguity.toString(),
|
||||
calleeExpression.toString()
|
||||
builderCalleeExpression.text,
|
||||
typeVariablesCausedAmbiguity.joinToString { it.originalTypeParameter.toString() },
|
||||
calleeExpression.text
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -140,14 +140,14 @@ class ResolutionWithStubTypesChecker(private val kotlinCallResolver: KotlinCallR
|
||||
if (receiverType != newReceiverType) {
|
||||
val typeVariables = substitutionMap.map { it.key as NewTypeVariableConstructor }
|
||||
val typeParameters = typeVariables.joinToString { (it.originalTypeParameter?.name ?: it).toString() }
|
||||
val inferredTypes = substitutionMap.values.joinToString()
|
||||
val inferredTypes = substitutionMap.values
|
||||
|
||||
addAll(typeVariables)
|
||||
|
||||
context.trace.report(
|
||||
STUB_TYPE_IN_RECEIVER_CAUSES_AMBIGUITY.on(
|
||||
kotlinCall.explicitReceiver?.psiExpression ?: kotlinCall.psiCall.callElement,
|
||||
newReceiverType, typeParameters, inferredTypes,
|
||||
newReceiverType, typeParameters, inferredTypes.joinToString(),
|
||||
if (relatedLambdaToLabel != null) BuilderLambdaLabelingInfo(relatedLambdaToLabel) else BuilderLambdaLabelingInfo.EMPTY
|
||||
)
|
||||
)
|
||||
@@ -171,12 +171,12 @@ class ResolutionWithStubTypesChecker(private val kotlinCallResolver: KotlinCallR
|
||||
val psiExpression = valueArgument.psiExpression ?: continue
|
||||
val typeVariables = substitutionMap.map { it.key as NewTypeVariableConstructor }
|
||||
val typeParameters = typeVariables.joinToString { (it.originalTypeParameter?.name ?: it).toString() }
|
||||
val inferredTypes = substitutionMap.values.joinToString()
|
||||
val inferredTypes = substitutionMap.values
|
||||
|
||||
addAll(typeVariables)
|
||||
|
||||
context.trace.report(
|
||||
STUB_TYPE_IN_ARGUMENT_CAUSES_AMBIGUITY.on(psiExpression, substitutedType, typeParameters, inferredTypes)
|
||||
STUB_TYPE_IN_ARGUMENT_CAUSES_AMBIGUITY.on(psiExpression, substitutedType, typeParameters, inferredTypes.joinToString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user