Humanize type mismatch diagnostic caused by type projections
#KT-10581 Fixed
This commit is contained in:
@@ -20,12 +20,14 @@ import com.intellij.icons.AllIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.diagnostics.TypeMismatchDueToTypeProjectionsData;
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages;
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap;
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer;
|
||||
import org.jetbrains.kotlin.js.resolve.diagnostics.ErrorsJs;
|
||||
import org.jetbrains.kotlin.js.resolve.diagnostics.JsCallDataHtmlRenderer;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.renderer.MultiRenderer;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@@ -66,6 +68,22 @@ public class IdeErrorMessages {
|
||||
MAP.put(TYPE_MISMATCH, "<html>Type mismatch.<table><tr><td>Required:</td><td>{0}</td></tr><tr><td>Found:</td><td>{1}</td></tr></table></html>",
|
||||
HTML_RENDER_TYPE, HTML_RENDER_TYPE);
|
||||
|
||||
MAP.put(TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS,
|
||||
"<html>Type mismatch.<table><tr><td>Required:</td><td>{0}</td></tr><tr><td>Found:</td><td>{1}</td></tr></table><br />\n" +
|
||||
"Projected type {2} restricts use of <br />\n{3}\n</html>",
|
||||
new MultiRenderer<TypeMismatchDueToTypeProjectionsData>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] render(@NotNull TypeMismatchDueToTypeProjectionsData object) {
|
||||
return new String[] {
|
||||
HTML_RENDER_TYPE.render(object.getExpectedType()),
|
||||
HTML_RENDER_TYPE.render(object.getExpressionType()),
|
||||
HTML_RENDER_TYPE.render(object.getReceiverType()),
|
||||
DescriptorRenderer.HTML.render(object.getCallableDescriptor())
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
MAP.put(ASSIGN_OPERATOR_AMBIGUITY, "<html>Assignment operators ambiguity. All these functions match.<ul>{0}</ul></table></html>",
|
||||
HTML_AMBIGUOUS_CALLS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user