Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10535027: Issue 3221. Use upper bound type of then/else expressions for conditional (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/Types.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index 8e348952d2cce0218991f9bdccd10642ca2b5e47..1c8e52b38a866de0398e186ef7c0d39213cec04f 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -1307,6 +1307,26 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(result.getErrors(), errEx(TypeErrorCode.SETTER_TYPE_MUST_BE_ASSIGNABLE, 8, 18, 5));
}
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3221
+ */
+ public void test_conditionalExpressionType() throws Exception {
+ AnalyzeLibraryResult result =
+ analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " bool x = (true ? 1 : 2.0);",
+ "}", "");
+ List<DartCompilationError> errors = result.getErrors();
+ assertErrors(errors, errEx(TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, 3, 12, 16));
+ {
+ String message = errors.get(0).getMessage();
+ assertTrue(message.contains("'num'"));
+ assertTrue(message.contains("'bool'"));
+ }
+ }
+
public void test_typeVariableBoundsMismatch() throws Exception {
AnalyzeLibraryResult result =
analyzeLibrary(
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/Types.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698