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

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

Issue 10592016: Dart Editor overlooks assignment to final fields scoped by "this" (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/resolver/Resolver.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 150b4b83f271310ef43d43fa28e813363d85bea7..577f534632898bbbc23238530775ac3c1e799838 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -3,9 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
package com.google.dart.compiler.type;
-import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
-import static com.google.dart.compiler.common.ErrorExpectation.errEx;
-
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -46,6 +43,9 @@ import com.google.dart.compiler.resolver.NodeElement;
import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.TypeErrorCode;
+import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
+import static com.google.dart.compiler.common.ErrorExpectation.errEx;
+
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
@@ -58,7 +58,7 @@ import java.util.concurrent.atomic.AtomicReference;
* slower, not actually unit test, but easier to use if you need access to DartNode's.
*/
public class TypeAnalyzerCompilerTest extends CompilerTestCase {
-
+
/**
* Top-level "main" function should not have parameters.
* <p>
@@ -106,7 +106,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
libraryResult.source.indexOf("call() => 42"),
element.getNameLocation().getOffset());
}
-
+
/**
* It is a compile-time error if a typedef refers to itself via a chain of references that does
* not include a class or interface type.
@@ -1177,7 +1177,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"}"));
assertErrors(libraryResult.getTypeErrors());
}
-
+
public void test_constField() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
getName(),
@@ -1186,6 +1186,10 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"const f = 1;",
"class A {",
" const f = 1;",
+ " method() {",
+ " f = 2;",
+ " this.f = 2;",
+ " }",
"}",
"main() {",
" f = 2;",
@@ -1195,8 +1199,10 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
""));
assertErrors(
libraryResult.getErrors(),
- errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 7, 3, 1),
- errEx(TypeErrorCode.FIELD_IS_FINAL, 9, 5, 1));
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 6, 5, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 7, 5, 6),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 11, 3, 1),
+ errEx(TypeErrorCode.FIELD_IS_FINAL, 13, 5, 1));
}
/**
@@ -1689,7 +1695,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(result.getErrors());
}
}
-
+
public void test_typesPropagation_assignAtDeclaration() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
"f() {",
@@ -1769,7 +1775,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertInferredElementTypeString(libraryResult, "v1", "String");
assertInferredElementTypeString(libraryResult, "v2", "<dynamic>");
}
-
+
/**
* Even if there is negation, we still apply "as" cast, so visit "then" statement only if cast was
* successful.
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698