diff --git a/compiler/frontend/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java b/compiler/frontend/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java index f57b04b6953..d69d839dbbd 100644 --- a/compiler/frontend/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java @@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotated; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies; import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe; import org.jetbrains.jet.lang.resolve.name.Name; @@ -195,16 +196,16 @@ public class DescriptorRendererImpl implements DescriptorRenderer { } private String renderTypeWithoutEscape(@NotNull JetType type) { - if (type == ExpressionTypingUtils.CANNOT_BE_INFERRED) { + if (type == ExpressionTypingUtils.CANNOT_BE_INFERRED || type == CallResolverUtil.CANT_INFER) { return "???"; } - else if (ErrorUtils.isErrorType(type)) { + if (ErrorUtils.isErrorType(type)) { return type.toString(); } - else if (KotlinBuiltIns.getInstance().isUnit(type)) { + if (KotlinBuiltIns.getInstance().isUnit(type)) { return KotlinBuiltIns.UNIT_ALIAS + (type.isNullable() ? "?" : ""); } - else if (KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type)) { + if (KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type)) { return renderFunctionType(type); } return renderDefaultType(type); diff --git a/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt b/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt index 15a67ec6473..8eee69ddae7 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt @@ -5,7 +5,7 @@ trait A fun infer(a: A) : T {} fun test(nothing: Nothing?) { - val i = infer(nothing) + val i = infer(nothing) } fun sum(a : IntArray) : Int { diff --git a/idea/testData/diagnosticMessage/typeMismatchWithNothing.kt b/idea/testData/diagnosticMessage/typeMismatchWithNothing.kt new file mode 100644 index 00000000000..edd1a2b198c --- /dev/null +++ b/idea/testData/diagnosticMessage/typeMismatchWithNothing.kt @@ -0,0 +1,9 @@ +package b + +trait A + +fun infer(a: A) : T {} + +fun foo(nothing: Nothing?) { + val i = infer(nothing) +} diff --git a/idea/testData/diagnosticMessage/typeMismatchWithNothing1.html b/idea/testData/diagnosticMessage/typeMismatchWithNothing1.html new file mode 100644 index 00000000000..d878c8f28bc --- /dev/null +++ b/idea/testData/diagnosticMessage/typeMismatchWithNothing1.html @@ -0,0 +1,17 @@ + + +Type mismatch. + + + + + + + + +
+Required: +b.A<???>
+Found: +jet.Nothing?
+ \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/highlighter/DiagnosticMessageTest.java b/idea/tests/org/jetbrains/jet/plugin/highlighter/DiagnosticMessageTest.java index 8fcdfe2683a..982af03f815 100644 --- a/idea/tests/org/jetbrains/jet/plugin/highlighter/DiagnosticMessageTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/highlighter/DiagnosticMessageTest.java @@ -106,4 +106,8 @@ public class DiagnosticMessageTest extends JetLiteFixture { public void testUpperBoundViolated() throws Exception { doTest("upperBoundViolated", 1, Errors.TYPE_INFERENCE_UPPER_BOUND_VIOLATED); } + + public void testTypeMismatchWithNothing() throws Exception { + doTest("typeMismatchWithNothing", 1, Errors.TYPE_MISMATCH); + } }