From 8b7585af66a9d8eedfe89156bceaf8de6f438d2d Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 22 Jul 2013 13:18:25 +0400 Subject: [PATCH] added diagnostic message tests to ensure that number value types don't appear in error messages --- .../diagnosticMessage/numberValueTypes.kt | 19 +++ .../diagnosticMessage/numberValueTypes1.html | 23 ++++ .../diagnosticMessage/numberValueTypes2.html | 23 ++++ .../diagnosticMessage/numberValueTypes3.html | 48 ++++++++ .../diagnosticMessage/numberValueTypes4.html | 116 ++++++++++++++++++ .../highlighter/DiagnosticMessageTest.java | 5 + 6 files changed, 234 insertions(+) create mode 100644 idea/testData/diagnosticMessage/numberValueTypes.kt create mode 100644 idea/testData/diagnosticMessage/numberValueTypes1.html create mode 100644 idea/testData/diagnosticMessage/numberValueTypes2.html create mode 100644 idea/testData/diagnosticMessage/numberValueTypes3.html create mode 100644 idea/testData/diagnosticMessage/numberValueTypes4.html diff --git a/idea/testData/diagnosticMessage/numberValueTypes.kt b/idea/testData/diagnosticMessage/numberValueTypes.kt new file mode 100644 index 00000000000..cb67a188e8f --- /dev/null +++ b/idea/testData/diagnosticMessage/numberValueTypes.kt @@ -0,0 +1,19 @@ +package a + +fun id(t: T): T = t + +fun either(t1: T, t2: T): T = t1 + +fun foo(l: List) {} + +fun bar(t: T, l: MutableList) {} + +fun test(l: MutableList) { + val c: Int = id(9223372036854775807) + + val g: Byte = either(1, 300) + + foo(1) + + bar(1, l) +} \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes1.html b/idea/testData/diagnosticMessage/numberValueTypes1.html new file mode 100644 index 00000000000..ac6dc6274a2 --- /dev/null +++ b/idea/testData/diagnosticMessage/numberValueTypes1.html @@ -0,0 +1,23 @@ + + +Type inference failed. Expected type mismatch: + + + + + + + + +
+found: + + +jet.Long + +
+required: + +jet.Int +
+ \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes2.html b/idea/testData/diagnosticMessage/numberValueTypes2.html new file mode 100644 index 00000000000..4600bc9146e --- /dev/null +++ b/idea/testData/diagnosticMessage/numberValueTypes2.html @@ -0,0 +1,23 @@ + + +Type inference failed. Expected type mismatch: + + + + + + + + +
+found: + + +jet.Int + +
+required: + +jet.Byte +
+ \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes3.html b/idea/testData/diagnosticMessage/numberValueTypes3.html new file mode 100644 index 00000000000..80a81ffe555 --- /dev/null +++ b/idea/testData/diagnosticMessage/numberValueTypes3.html @@ -0,0 +1,48 @@ + + +Type inference failed: + + + + + + + + + + + + + + + + + + + +
+ + +fun + <T> + foo +( +l: jet.List<T> +) +: jet.Unit
+cannot be applied to
+ + + + +( + + + +jet.Int + + + +) +
+ \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes4.html b/idea/testData/diagnosticMessage/numberValueTypes4.html new file mode 100644 index 00000000000..be392711eb4 --- /dev/null +++ b/idea/testData/diagnosticMessage/numberValueTypes4.html @@ -0,0 +1,116 @@ + + +Type inference failed: Cannot infer type parameter +T + in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +fun + <T> + bar +( +t: T, +l: jet.MutableList<T> +) +: jet.Unit
+None of the following substitutions
+ + + + +( + + + +jet.String + + +, + + +jet.MutableList<jet.String> + + +) +
+ + + + +( + + +jet.Int + +, + + + +jet.MutableList<jet.Int> + + + +) +
+can be applied to
+ + + + +( + + +jet.Int + +, + + +jet.MutableList<jet.String> + + +) +
+ \ 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 c9ea336c646..e46008d80ac 100644 --- a/idea/tests/org/jetbrains/jet/plugin/highlighter/DiagnosticMessageTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/highlighter/DiagnosticMessageTest.java @@ -113,4 +113,9 @@ public class DiagnosticMessageTest extends JetLiteFixture { public void testInvisibleMember() throws Exception { doTest("invisibleMember", 3, Errors.INVISIBLE_MEMBER, Errors.INVISIBLE_MEMBER, Errors.INVISIBLE_MEMBER); } + + public void testNumberValueTypes() throws Exception { + doTest("numberValueTypes", 4, Errors.TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, Errors.TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH, + Errors.TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS); + } }