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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/TypePropagationTest.java

Issue 300033008: Remember propagated types for PropertyInducingElement(s). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | « editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzer.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/TypePropagationTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/TypePropagationTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/TypePropagationTest.java
index a1a194898f9bd27d0d1364b25528f91ddd204080..3657f94072655138f22c6e86257a7a286c06f190 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/TypePropagationTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/TypePropagationTest.java
@@ -186,6 +186,137 @@ public class TypePropagationTest extends ResolverTestCase {
assertEquals("CanvasRenderingContext2D", identifier.getPropagatedType().getName());
}
+ public void test_finalPropertyInducingVariable_classMember_instance() throws Exception {
+ addNamedSource("/lib.dart", createSource(//
+ "class A {",
+ " final v = 0;",
+ "}"));
+ String code = createSource(//
+ "import 'lib.dart';",
+ "f(A a) {",
+ " return a.v; // marker",
+ "}");
+ Source source = addSource(code);
+ LibraryElement library = resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ {
+ SimpleIdentifier identifier = findNode(unit, code, "v; // marker", SimpleIdentifier.class);
+ assertSame(getTypeProvider().getDynamicType(), identifier.getStaticType());
+ assertSame(getTypeProvider().getIntType(), identifier.getPropagatedType());
+ }
+ }
+
+ public void test_finalPropertyInducingVariable_classMember_instance_inherited() throws Exception {
+ addNamedSource("/lib.dart", createSource(//
+ "class A {",
+ " final v = 0;",
+ "}"));
+ String code = createSource(//
+ "import 'lib.dart';",
+ "class B extends A {",
+ " m() {",
+ " return v; // marker",
+ " }",
+ "}");
+ Source source = addSource(code);
+ LibraryElement library = resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ {
+ SimpleIdentifier identifier = findNode(unit, code, "v; // marker", SimpleIdentifier.class);
+ assertSame(getTypeProvider().getDynamicType(), identifier.getStaticType());
+ assertSame(getTypeProvider().getIntType(), identifier.getPropagatedType());
+ }
+ }
+
+ public void test_finalPropertyInducingVariable_classMember_instance_propagatedTarget()
+ throws Exception {
+ addNamedSource("/lib.dart", createSource(//
+ "class A {",
+ " final v = 0;",
+ "}"));
+ String code = createSource(//
+ "import 'lib.dart';",
+ "f(p) {",
+ " if (p is A) {",
+ " return p.v; // marker",
+ " }",
+ "}");
+ Source source = addSource(code);
+ LibraryElement library = resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ {
+ SimpleIdentifier identifier = findNode(unit, code, "v; // marker", SimpleIdentifier.class);
+ assertSame(getTypeProvider().getDynamicType(), identifier.getStaticType());
+ assertSame(getTypeProvider().getIntType(), identifier.getPropagatedType());
+ }
+ }
+
+ public void test_finalPropertyInducingVariable_classMember_static() throws Exception {
+ addNamedSource("/lib.dart", createSource(//
+ "class A {",
+ " static final V = 0;",
+ "}"));
+ String code = createSource(//
+ "import 'lib.dart';",
+ "f() {",
+ " return A.V; // marker",
+ "}");
+ Source source = addSource(code);
+ LibraryElement library = resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ {
+ SimpleIdentifier identifier = findNode(unit, code, "V; // marker", SimpleIdentifier.class);
+ assertSame(getTypeProvider().getDynamicType(), identifier.getStaticType());
+ assertSame(getTypeProvider().getIntType(), identifier.getPropagatedType());
+ }
+ }
+
+ public void test_finalPropertyInducingVariable_topLevelVaraible_prefixed() throws Exception {
+ addNamedSource("/lib.dart", "final V = 0;");
+ String code = createSource(//
+ "import 'lib.dart' as p;",
+ "f() {",
+ " var v2 = p.V; // prefixed",
+ "}");
+ Source source = addSource(code);
+ LibraryElement library = resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ {
+ SimpleIdentifier identifier = findNode(unit, code, "V; // prefixed", SimpleIdentifier.class);
+ assertSame(getTypeProvider().getDynamicType(), identifier.getStaticType());
+ assertSame(getTypeProvider().getIntType(), identifier.getPropagatedType());
+ }
+ }
+
+ public void test_finalPropertyInducingVariable_topLevelVaraible_simple() throws Exception {
+ addNamedSource("/lib.dart", "final V = 0;");
+ String code = createSource(//
+ "import 'lib.dart';",
+ "f() {",
+ " return V; // simple",
+ "}");
+ Source source = addSource(code);
+ LibraryElement library = resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ {
+ SimpleIdentifier identifier = findNode(unit, code, "V; // simple", SimpleIdentifier.class);
+ assertSame(getTypeProvider().getDynamicType(), identifier.getStaticType());
+ assertSame(getTypeProvider().getIntType(), identifier.getPropagatedType());
+ }
+ }
+
public void test_forEach() throws Exception {
String code = createSource(//
"main() {",
« no previous file with comments | « editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698