Clarified error message for TYPE_MISMATCH_IN_BINDING_PATTERN.

This commit is contained in:
Evgeny Gerashchenko
2012-04-17 02:24:09 +04:00
parent 5a69231b92
commit 1123a4f438
2 changed files with 7 additions and 7 deletions
@@ -305,7 +305,7 @@ public class DefaultErrorMessages {
MAP.put(TYPE_MISMATCH_IN_CONDITION, "Condition must be of type jet.Boolean, but is of type {0}", RENDER_TYPE);
MAP.put(TYPE_MISMATCH_IN_TUPLE_PATTERN, "Type mismatch: subject is of type {0} but the pattern is of type Tuple{1}", RENDER_TYPE,
TO_STRING); // TODO: message
MAP.put(TYPE_MISMATCH_IN_BINDING_PATTERN, "{0} must be a supertype of {1}. Use 'is' to match against {0}", RENDER_TYPE, RENDER_TYPE);
MAP.put(TYPE_MISMATCH_IN_BINDING_PATTERN, "{0} is not a supertype of {1}. Use ''is'' to match against {0}", RENDER_TYPE, RENDER_TYPE);
MAP.put(INCOMPATIBLE_TYPES, "Incompatible types: {0} and {1}", RENDER_TYPE, RENDER_TYPE);
MAP.put(EXPECTED_CONDITION, "Expected condition of Boolean type");
+6 -6
View File
@@ -66,7 +66,7 @@ fun f12(a : A?) {
is A -> <info descr="Automatically cast to A">a</info>.foo()
is Any -> <info descr="Automatically cast to A">a</info>.foo();
is Any? -> a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B must be a supertype of A?. Use is to match against B">B</error> -> c.foo()
is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B is not a supertype of A?. Use 'is' to match against B">B</error> -> c.foo()
is val c is C -> <info descr="Automatically cast to C">c</info>.bar()
is val c is C -> <info descr="Automatically cast to C">a</info>.bar()
else -> a<info>?.</info>foo()
@@ -237,17 +237,17 @@ fun mergeAutocasts(a: Any?) {
fun f(): String {
var <info>a</info>: Any = 11
if (<info>a</info> is String) {
val <warning>i</warning>: String = <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to jet.String is impossible, because a could have changed since the is-check">a</error>
<error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to jet.String is impossible, because a could have changed since the is-check">a</error>.compareTo("f")
val <warning>f</warning>: Function0<String> = { <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to jet.String is impossible, because a could have changed since the is-check">a</error> }
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to jet.String is impossible, because a could have changed since the is-check">a</error>
val <warning>i</warning>: String = <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to 'jet.String' is impossible, because 'a' could have changed since the is-check">a</error>
<error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to 'jet.String' is impossible, because 'a' could have changed since the is-check">a</error>.compareTo("f")
val <warning>f</warning>: Function0<String> = { <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to 'jet.String' is impossible, because 'a' could have changed since the is-check">a</error> }
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to 'jet.String' is impossible, because 'a' could have changed since the is-check">a</error>
}
return ""
}
fun foo(var a: Any): Int {
if (a is Int) {
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to jet.Int is impossible, because a could have changed since the is-check">a</error>
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to 'jet.Int' is impossible, because 'a' could have changed since the is-check">a</error>
}
return 1
}