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

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

Issue 11411236: Don't warn if inferred type is too generic - such as Object or Collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/TypeAnalyzer.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 fd5391c207c3dbce31a5b6058ff6558d98247791..ddd46a32e070723c595b9305cf31fadc13a8d9f0 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -3052,6 +3052,37 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * Sometimes inferred type is too generic - such as "Object" or "Collection", so there are no
+ * reason to reports problems.
+ */
+ public void test_typesPropagation_dontWant_ifTooGeneric() throws Exception {
+ compilerConfiguration = new DefaultCompilerConfiguration(new CompilerOptions() {
+ @Override
+ public boolean typeChecksForInferredTypes() {
+ return true;
+ }
+ });
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "typedef void HandlerObject(Object o);",
+ "typedef void HandlerCollection(Collection o);",
+ "fObject(HandlerObject h) {}",
+ "fCollection(HandlerCollection h) {}",
+ "main() {",
+ " fObject((x) {",
+ " x.myNoSuchField;",
+ " x.myNoSuchMethod();",
+ " });",
+ " fCollection((x) {",
+ " x.myNoSuchField;",
+ " x.myNoSuchMethod();",
+ " });",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ }
+
+ /**
* Helpful (but not perfectly satisfying Specification) type of "conditional" is intersection of
* then/else types, not just their "least upper bounds". And this corresponds runtime behavior.
*/
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698