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

Side by Side Diff: pkg/analyzer_experimental/test/generated/resolver_test.dart

Issue 14161021: Generate unique names less aggressively. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.resolver_test; 4 library engine.resolver_test;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'package:analyzer_experimental/src/generated/java_core.dart'; 7 import 'package:analyzer_experimental/src/generated/java_core.dart';
8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 8 import 'package:analyzer_experimental/src/generated/java_engine.dart';
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 9 import 'package:analyzer_experimental/src/generated/java_junit.dart';
10 import 'package:analyzer_experimental/src/generated/source_io.dart'; 10 import 'package:analyzer_experimental/src/generated/source_io.dart';
(...skipping 15 matching lines...) Expand all
26 class TypePropagationTest extends ResolverTestCase { 26 class TypePropagationTest extends ResolverTestCase {
27 void test_as() { 27 void test_as() {
28 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"])); 28 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"]));
29 LibraryElement library = resolve(source, []); 29 LibraryElement library = resolve(source, []);
30 assertNoErrors(); 30 assertNoErrors();
31 verify([source]); 31 verify([source]);
32 CompilationUnit unit = resolveCompilationUnit(source, library); 32 CompilationUnit unit = resolveCompilationUnit(source, library);
33 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 33 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
34 InterfaceType typeA = classA.element.type; 34 InterfaceType typeA = classA.element.type;
35 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 35 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
36 BlockFunctionBody body6 = function.functionExpression.body as BlockFunctionB ody; 36 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
37 IfStatement ifStatement = body6.block.statements[0] as IfStatement; 37 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
38 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 38 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
39 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 39 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
40 JUnitTestCase.assertSame(typeA, variableName.staticType); 40 JUnitTestCase.assertSame(typeA, variableName.staticType);
41 } 41 }
42 void test_assert() { 42 void test_assert() {
43 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " assert (p is A);", " return p;", "}"])); 43 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " assert (p is A);", " return p;", "}"]));
44 LibraryElement library = resolve(source, []); 44 LibraryElement library = resolve(source, []);
45 assertNoErrors(); 45 assertNoErrors();
46 verify([source]); 46 verify([source]);
47 CompilationUnit unit = resolveCompilationUnit(source, library); 47 CompilationUnit unit = resolveCompilationUnit(source, library);
48 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 48 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
49 InterfaceType typeA = classA.element.type; 49 InterfaceType typeA = classA.element.type;
50 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 50 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
51 BlockFunctionBody body7 = function.functionExpression.body as BlockFunctionB ody; 51 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
52 ReturnStatement statement = body7.block.statements[1] as ReturnStatement; 52 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
53 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 53 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
54 JUnitTestCase.assertSame(typeA, variableName.staticType); 54 JUnitTestCase.assertSame(typeA, variableName.staticType);
55 } 55 }
56 void test_assignment() { 56 void test_assignment() {
57 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var v;", " v = 0;", " return v;", "}"])); 57 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var v;", " v = 0;", " return v;", "}"]));
58 LibraryElement library = resolve(source, []); 58 LibraryElement library = resolve(source, []);
59 assertNoErrors(); 59 assertNoErrors();
60 verify([source]); 60 verify([source]);
61 CompilationUnit unit = resolveCompilationUnit(source, library); 61 CompilationUnit unit = resolveCompilationUnit(source, library);
62 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 62 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
63 BlockFunctionBody body8 = function.functionExpression.body as BlockFunctionB ody; 63 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
64 ReturnStatement statement = body8.block.statements[2] as ReturnStatement; 64 ReturnStatement statement = body2.block.statements[2] as ReturnStatement;
65 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 65 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
66 JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType); 66 JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType);
67 } 67 }
68 void test_assignment_afterInitializer() { 68 void test_assignment_afterInitializer() {
69 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var v = 0;", " v = 1.0;", " return v;", "}"])); 69 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var v = 0;", " v = 1.0;", " return v;", "}"]));
70 LibraryElement library = resolve(source, []); 70 LibraryElement library = resolve(source, []);
71 assertNoErrors(); 71 assertNoErrors();
72 verify([source]); 72 verify([source]);
73 CompilationUnit unit = resolveCompilationUnit(source, library); 73 CompilationUnit unit = resolveCompilationUnit(source, library);
74 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 74 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
75 BlockFunctionBody body9 = function.functionExpression.body as BlockFunctionB ody; 75 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
76 ReturnStatement statement = body9.block.statements[2] as ReturnStatement; 76 ReturnStatement statement = body2.block.statements[2] as ReturnStatement;
77 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 77 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
78 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.staticType); 78 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.staticType);
79 } 79 }
80 void test_initializer() { 80 void test_initializer() {
81 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var v = 0;", " return v;", "}"])); 81 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var v = 0;", " return v;", "}"]));
82 LibraryElement library = resolve(source, []); 82 LibraryElement library = resolve(source, []);
83 assertNoErrors(); 83 assertNoErrors();
84 verify([source]); 84 verify([source]);
85 CompilationUnit unit = resolveCompilationUnit(source, library); 85 CompilationUnit unit = resolveCompilationUnit(source, library);
86 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 86 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
87 BlockFunctionBody body10 = function.functionExpression.body as BlockFunction Body; 87 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
88 ReturnStatement statement = body10.block.statements[1] as ReturnStatement; 88 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
89 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 89 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
90 JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType); 90 JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType);
91 } 91 }
92 void test_is_conditional() { 92 void test_is_conditional() {
93 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is A) ? p : null;", "}"])); 93 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is A) ? p : null;", "}"]));
94 LibraryElement library = resolve(source, []); 94 LibraryElement library = resolve(source, []);
95 assertNoErrors(); 95 assertNoErrors();
96 verify([source]); 96 verify([source]);
97 CompilationUnit unit = resolveCompilationUnit(source, library); 97 CompilationUnit unit = resolveCompilationUnit(source, library);
98 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 98 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
99 InterfaceType typeA = classA.element.type; 99 InterfaceType typeA = classA.element.type;
100 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 100 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
101 BlockFunctionBody body11 = function.functionExpression.body as BlockFunction Body; 101 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
102 ReturnStatement statement = body11.block.statements[0] as ReturnStatement; 102 ReturnStatement statement = body2.block.statements[0] as ReturnStatement;
103 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion; 103 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion;
104 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi er; 104 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi er;
105 JUnitTestCase.assertSame(typeA, variableName.staticType); 105 JUnitTestCase.assertSame(typeA, variableName.staticType);
106 } 106 }
107 void test_is_if() { 107 void test_is_if() {
108 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " return p;", " } else {", " re turn null;", " }", "}"])); 108 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " return p;", " } else {", " re turn null;", " }", "}"]));
109 LibraryElement library = resolve(source, []); 109 LibraryElement library = resolve(source, []);
110 assertNoErrors(); 110 assertNoErrors();
111 verify([source]); 111 verify([source]);
112 CompilationUnit unit = resolveCompilationUnit(source, library); 112 CompilationUnit unit = resolveCompilationUnit(source, library);
113 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 113 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
114 InterfaceType typeA = classA.element.type; 114 InterfaceType typeA = classA.element.type;
115 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 115 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
116 BlockFunctionBody body12 = function.functionExpression.body as BlockFunction Body; 116 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
117 IfStatement ifStatement = body12.block.statements[0] as IfStatement; 117 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
118 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 118 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
119 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 119 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
120 JUnitTestCase.assertSame(typeA, variableName.staticType); 120 JUnitTestCase.assertSame(typeA, variableName.staticType);
121 } 121 }
122 void test_is_if_logicalAnd() { 122 void test_is_if_logicalAnd() {
123 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A && p != null) {", " return p;", " } els e {", " return null;", " }", "}"])); 123 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A && p != null) {", " return p;", " } els e {", " return null;", " }", "}"]));
124 LibraryElement library = resolve(source, []); 124 LibraryElement library = resolve(source, []);
125 assertNoErrors(); 125 assertNoErrors();
126 verify([source]); 126 verify([source]);
127 CompilationUnit unit = resolveCompilationUnit(source, library); 127 CompilationUnit unit = resolveCompilationUnit(source, library);
128 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 128 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
129 InterfaceType typeA = classA.element.type; 129 InterfaceType typeA = classA.element.type;
130 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 130 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
131 BlockFunctionBody body13 = function.functionExpression.body as BlockFunction Body; 131 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
132 IfStatement ifStatement = body13.block.statements[0] as IfStatement; 132 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
133 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 133 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
134 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 134 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
135 JUnitTestCase.assertSame(typeA, variableName.staticType); 135 JUnitTestCase.assertSame(typeA, variableName.staticType);
136 } 136 }
137 void test_is_postConditional() { 137 void test_is_postConditional() {
138 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"] )); 138 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"] ));
139 LibraryElement library = resolve(source, []); 139 LibraryElement library = resolve(source, []);
140 assertNoErrors(); 140 assertNoErrors();
141 verify([source]); 141 verify([source]);
142 CompilationUnit unit = resolveCompilationUnit(source, library); 142 CompilationUnit unit = resolveCompilationUnit(source, library);
143 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 143 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
144 InterfaceType typeA = classA.element.type; 144 InterfaceType typeA = classA.element.type;
145 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 145 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
146 BlockFunctionBody body14 = function.functionExpression.body as BlockFunction Body; 146 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
147 ReturnStatement statement = body14.block.statements[1] as ReturnStatement; 147 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
148 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 148 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
149 JUnitTestCase.assertSame(typeA, variableName.staticType); 149 JUnitTestCase.assertSame(typeA, variableName.staticType);
150 } 150 }
151 void test_is_postIf() { 151 void test_is_postIf() {
152 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " A a = p;", " } else {", " ret urn null;", " }", " return p;", "}"])); 152 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " A a = p;", " } else {", " ret urn null;", " }", " return p;", "}"]));
153 LibraryElement library = resolve(source, []); 153 LibraryElement library = resolve(source, []);
154 assertNoErrors(); 154 assertNoErrors();
155 verify([source]); 155 verify([source]);
156 CompilationUnit unit = resolveCompilationUnit(source, library); 156 CompilationUnit unit = resolveCompilationUnit(source, library);
157 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 157 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
158 InterfaceType typeA = classA.element.type; 158 InterfaceType typeA = classA.element.type;
159 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 159 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
160 BlockFunctionBody body15 = function.functionExpression.body as BlockFunction Body; 160 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
161 ReturnStatement statement = body15.block.statements[1] as ReturnStatement; 161 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
162 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 162 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
163 JUnitTestCase.assertSame(typeA, variableName.staticType); 163 JUnitTestCase.assertSame(typeA, variableName.staticType);
164 } 164 }
165 void test_is_subclass() { 165 void test_is_subclass() {
166 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " return p.m();", " }", "}"])); 166 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " return p.m();", " }", "}"]));
167 LibraryElement library = resolve(source, []); 167 LibraryElement library = resolve(source, []);
168 assertNoErrors(); 168 assertNoErrors();
169 verify([source]); 169 verify([source]);
170 CompilationUnit unit = resolveCompilationUnit(source, library); 170 CompilationUnit unit = resolveCompilationUnit(source, library);
171 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; 171 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration;
172 BlockFunctionBody body16 = function.functionExpression.body as BlockFunction Body; 172 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
173 IfStatement ifStatement = body16.block.statements[0] as IfStatement; 173 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
174 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 174 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
175 MethodInvocation invocation = statement.expression as MethodInvocation; 175 MethodInvocation invocation = statement.expression as MethodInvocation;
176 JUnitTestCase.assertNotNull(invocation.methodName.element); 176 JUnitTestCase.assertNotNull(invocation.methodName.element);
177 } 177 }
178 void test_isNot_conditional() { 178 void test_isNot_conditional() {
179 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is! A) ? null : p;", "}"])); 179 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is! A) ? null : p;", "}"]));
180 LibraryElement library = resolve(source, []); 180 LibraryElement library = resolve(source, []);
181 assertNoErrors(); 181 assertNoErrors();
182 verify([source]); 182 verify([source]);
183 CompilationUnit unit = resolveCompilationUnit(source, library); 183 CompilationUnit unit = resolveCompilationUnit(source, library);
184 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 184 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
185 InterfaceType typeA = classA.element.type; 185 InterfaceType typeA = classA.element.type;
186 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 186 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
187 BlockFunctionBody body17 = function.functionExpression.body as BlockFunction Body; 187 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
188 ReturnStatement statement = body17.block.statements[0] as ReturnStatement; 188 ReturnStatement statement = body2.block.statements[0] as ReturnStatement;
189 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion; 189 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion;
190 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi er; 190 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi er;
191 JUnitTestCase.assertSame(typeA, variableName.staticType); 191 JUnitTestCase.assertSame(typeA, variableName.staticType);
192 } 192 }
193 void test_isNot_if() { 193 void test_isNot_if() {
194 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " } else {", " return p;", " }", "}"])); 194 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " } else {", " return p;", " }", "}"]));
195 LibraryElement library = resolve(source, []); 195 LibraryElement library = resolve(source, []);
196 assertNoErrors(); 196 assertNoErrors();
197 verify([source]); 197 verify([source]);
198 CompilationUnit unit = resolveCompilationUnit(source, library); 198 CompilationUnit unit = resolveCompilationUnit(source, library);
199 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 199 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
200 InterfaceType typeA = classA.element.type; 200 InterfaceType typeA = classA.element.type;
201 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 201 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
202 BlockFunctionBody body18 = function.functionExpression.body as BlockFunction Body; 202 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
203 IfStatement ifStatement = body18.block.statements[0] as IfStatement; 203 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
204 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement; 204 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement;
205 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 205 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
206 JUnitTestCase.assertSame(typeA, variableName.staticType); 206 JUnitTestCase.assertSame(typeA, variableName.staticType);
207 } 207 }
208 void test_isNot_if_logicalOr() { 208 void test_isNot_if_logicalOr() {
209 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A || null == p) {", " return null;", " } else {", " return p;", " }", "}"])); 209 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A || null == p) {", " return null;", " } else {", " return p;", " }", "}"]));
210 LibraryElement library = resolve(source, []); 210 LibraryElement library = resolve(source, []);
211 assertNoErrors(); 211 assertNoErrors();
212 verify([source]); 212 verify([source]);
213 CompilationUnit unit = resolveCompilationUnit(source, library); 213 CompilationUnit unit = resolveCompilationUnit(source, library);
214 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 214 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
215 InterfaceType typeA = classA.element.type; 215 InterfaceType typeA = classA.element.type;
216 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 216 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
217 BlockFunctionBody body19 = function.functionExpression.body as BlockFunction Body; 217 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
218 IfStatement ifStatement = body19.block.statements[0] as IfStatement; 218 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
219 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement; 219 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement;
220 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 220 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
221 JUnitTestCase.assertSame(typeA, variableName.staticType); 221 JUnitTestCase.assertSame(typeA, variableName.staticType);
222 } 222 }
223 void test_isNot_postConditional() { 223 void test_isNot_postConditional() {
224 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}" ])); 224 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}" ]));
225 LibraryElement library = resolve(source, []); 225 LibraryElement library = resolve(source, []);
226 assertNoErrors(); 226 assertNoErrors();
227 verify([source]); 227 verify([source]);
228 CompilationUnit unit = resolveCompilationUnit(source, library); 228 CompilationUnit unit = resolveCompilationUnit(source, library);
229 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 229 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
230 InterfaceType typeA = classA.element.type; 230 InterfaceType typeA = classA.element.type;
231 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 231 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
232 BlockFunctionBody body20 = function.functionExpression.body as BlockFunction Body; 232 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
233 ReturnStatement statement = body20.block.statements[1] as ReturnStatement; 233 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
234 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 234 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
235 JUnitTestCase.assertSame(typeA, variableName.staticType); 235 JUnitTestCase.assertSame(typeA, variableName.staticType);
236 } 236 }
237 void test_isNot_postIf() { 237 void test_isNot_postIf() {
238 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"])); 238 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"]));
239 LibraryElement library = resolve(source, []); 239 LibraryElement library = resolve(source, []);
240 assertNoErrors(); 240 assertNoErrors();
241 verify([source]); 241 verify([source]);
242 CompilationUnit unit = resolveCompilationUnit(source, library); 242 CompilationUnit unit = resolveCompilationUnit(source, library);
243 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 243 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
244 InterfaceType typeA = classA.element.type; 244 InterfaceType typeA = classA.element.type;
245 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 245 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
246 BlockFunctionBody body21 = function.functionExpression.body as BlockFunction Body; 246 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
247 ReturnStatement statement = body21.block.statements[1] as ReturnStatement; 247 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
248 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 248 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
249 JUnitTestCase.assertSame(typeA, variableName.staticType); 249 JUnitTestCase.assertSame(typeA, variableName.staticType);
250 } 250 }
251 void test_query() { 251 void test_query() {
252 Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'dart:html';", "", "main() {", " var v1 = query('a');", " var v2 = query('A') ;", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]') ;", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('select#id');", " // invocation of method", " var m1 = document.query ('div');", " // unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " r eturn [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"])); 252 Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'dart:html';", "", "main() {", " var v1 = query('a');", " var v2 = query('A') ;", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]') ;", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('select#id');", " // invocation of method", " var m1 = document.query ('div');", " // unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " r eturn [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"]));
253 LibraryElement library = resolve(source, []); 253 LibraryElement library = resolve(source, []);
254 assertNoErrors(); 254 assertNoErrors();
255 verify([source]); 255 verify([source]);
256 CompilationUnit unit = resolveCompilationUnit(source, library); 256 CompilationUnit unit = resolveCompilationUnit(source, library);
257 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; 257 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration;
258 BlockFunctionBody body22 = main.functionExpression.body as BlockFunctionBody ; 258 BlockFunctionBody body2 = main.functionExpression.body as BlockFunctionBody;
259 ReturnStatement statement = body22.block.statements[11] as ReturnStatement; 259 ReturnStatement statement = body2.block.statements[11] as ReturnStatement;
260 NodeList<Expression> elements3 = ((statement.expression as ListLiteral)).ele ments; 260 NodeList<Expression> elements2 = ((statement.expression as ListLiteral)).ele ments;
261 JUnitTestCase.assertEquals("AnchorElement", elements3[0].staticType.name); 261 JUnitTestCase.assertEquals("AnchorElement", elements2[0].staticType.name);
262 JUnitTestCase.assertEquals("AnchorElement", elements3[1].staticType.name); 262 JUnitTestCase.assertEquals("AnchorElement", elements2[1].staticType.name);
263 JUnitTestCase.assertEquals("BodyElement", elements3[2].staticType.name); 263 JUnitTestCase.assertEquals("BodyElement", elements2[2].staticType.name);
264 JUnitTestCase.assertEquals("ButtonElement", elements3[3].staticType.name); 264 JUnitTestCase.assertEquals("ButtonElement", elements2[3].staticType.name);
265 JUnitTestCase.assertEquals("DivElement", elements3[4].staticType.name); 265 JUnitTestCase.assertEquals("DivElement", elements2[4].staticType.name);
266 JUnitTestCase.assertEquals("InputElement", elements3[5].staticType.name); 266 JUnitTestCase.assertEquals("InputElement", elements2[5].staticType.name);
267 JUnitTestCase.assertEquals("SelectElement", elements3[6].staticType.name); 267 JUnitTestCase.assertEquals("SelectElement", elements2[6].staticType.name);
268 JUnitTestCase.assertEquals("DivElement", elements3[7].staticType.name); 268 JUnitTestCase.assertEquals("DivElement", elements2[7].staticType.name);
269 JUnitTestCase.assertEquals("Element", elements3[8].staticType.name); 269 JUnitTestCase.assertEquals("Element", elements2[8].staticType.name);
270 JUnitTestCase.assertEquals("Element", elements3[9].staticType.name); 270 JUnitTestCase.assertEquals("Element", elements2[9].staticType.name);
271 JUnitTestCase.assertEquals("Element", elements3[10].staticType.name); 271 JUnitTestCase.assertEquals("Element", elements2[10].staticType.name);
272 } 272 }
273 static dartSuite() { 273 static dartSuite() {
274 _ut.group('TypePropagationTest', () { 274 _ut.group('TypePropagationTest', () {
275 _ut.test('test_as', () { 275 _ut.test('test_as', () {
276 final __test = new TypePropagationTest(); 276 final __test = new TypePropagationTest();
277 runJUnitTest(__test, __test.test_as); 277 runJUnitTest(__test, __test.test_as);
278 }); 278 });
279 _ut.test('test_assert', () { 279 _ut.test('test_assert', () {
280 final __test = new TypePropagationTest(); 280 final __test = new TypePropagationTest();
281 runJUnitTest(__test, __test.test_assert); 281 runJUnitTest(__test, __test.test_assert);
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 void setUp() { 865 void setUp() {
866 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); 866 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
867 _analysisContext = new AnalysisContextImpl(); 867 _analysisContext = new AnalysisContextImpl();
868 _analysisContext.sourceFactory = _sourceFactory; 868 _analysisContext.sourceFactory = _sourceFactory;
869 _errorListener = new GatheringErrorListener(); 869 _errorListener = new GatheringErrorListener();
870 _library5 = library("/lib.dart"); 870 _library5 = library("/lib.dart");
871 } 871 }
872 void test_addExport() { 872 void test_addExport() {
873 Library exportLibrary = library("/exported.dart"); 873 Library exportLibrary = library("/exported.dart");
874 _library5.addExport(ASTFactory.exportDirective2("exported.dart", []), export Library); 874 _library5.addExport(ASTFactory.exportDirective2("exported.dart", []), export Library);
875 List<Library> exports3 = _library5.exports; 875 List<Library> exports2 = _library5.exports;
876 EngineTestCase.assertLength(1, exports3); 876 EngineTestCase.assertLength(1, exports2);
877 JUnitTestCase.assertSame(exportLibrary, exports3[0]); 877 JUnitTestCase.assertSame(exportLibrary, exports2[0]);
878 _errorListener.assertNoErrors(); 878 _errorListener.assertNoErrors();
879 } 879 }
880 void test_addImport() { 880 void test_addImport() {
881 Library importLibrary = library("/imported.dart"); 881 Library importLibrary = library("/imported.dart");
882 _library5.addImport(ASTFactory.importDirective2("imported.dart", null, []), importLibrary); 882 _library5.addImport(ASTFactory.importDirective2("imported.dart", null, []), importLibrary);
883 List<Library> imports3 = _library5.imports; 883 List<Library> imports2 = _library5.imports;
884 EngineTestCase.assertLength(1, imports3); 884 EngineTestCase.assertLength(1, imports2);
885 JUnitTestCase.assertSame(importLibrary, imports3[0]); 885 JUnitTestCase.assertSame(importLibrary, imports2[0]);
886 _errorListener.assertNoErrors(); 886 _errorListener.assertNoErrors();
887 } 887 }
888 void test_getExplicitlyImportsCore() { 888 void test_getExplicitlyImportsCore() {
889 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore); 889 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore);
890 _errorListener.assertNoErrors(); 890 _errorListener.assertNoErrors();
891 } 891 }
892 void test_getExport() { 892 void test_getExport() {
893 ExportDirective directive = ASTFactory.exportDirective2("exported.dart", []) ; 893 ExportDirective directive = ASTFactory.exportDirective2("exported.dart", []) ;
894 Library exportLibrary = library("/exported.dart"); 894 Library exportLibrary = library("/exported.dart");
895 _library5.addExport(directive, exportLibrary); 895 _library5.addExport(directive, exportLibrary);
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 Source librarySource = new FileBasedSource.con1(factory.contentCache, FileUt ilities2.createFile("/lib.dart")); 1341 Source librarySource = new FileBasedSource.con1(factory.contentCache, FileUt ilities2.createFile("/lib.dart"));
1342 _library = new Library(context, _listener, librarySource); 1342 _library = new Library(context, _listener, librarySource);
1343 LibraryElementImpl element = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["lib"])); 1343 LibraryElementImpl element = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["lib"]));
1344 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart") ; 1344 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart") ;
1345 _library.libraryElement = element; 1345 _library.libraryElement = element;
1346 _typeProvider = new TestTypeProvider(); 1346 _typeProvider = new TestTypeProvider();
1347 _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvid er); 1347 _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvid er);
1348 } 1348 }
1349 void test_visitCatchClause_exception() { 1349 void test_visitCatchClause_exception() {
1350 CatchClause clause = ASTFactory.catchClause("e", []); 1350 CatchClause clause = ASTFactory.catchClause("e", []);
1351 SimpleIdentifier exceptionParameter4 = clause.exceptionParameter; 1351 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter;
1352 exceptionParameter4.element = new LocalVariableElementImpl(exceptionParamete r4); 1352 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete r2);
1353 resolve(clause, _typeProvider.objectType, null, []); 1353 resolve(clause, _typeProvider.objectType, null, []);
1354 _listener.assertNoErrors(); 1354 _listener.assertNoErrors();
1355 } 1355 }
1356 void test_visitCatchClause_exception_stackTrace() { 1356 void test_visitCatchClause_exception_stackTrace() {
1357 CatchClause clause = ASTFactory.catchClause2("e", "s", []); 1357 CatchClause clause = ASTFactory.catchClause2("e", "s", []);
1358 SimpleIdentifier exceptionParameter5 = clause.exceptionParameter; 1358 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter;
1359 exceptionParameter5.element = new LocalVariableElementImpl(exceptionParamete r5); 1359 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete r2);
1360 SimpleIdentifier stackTraceParameter4 = clause.stackTraceParameter; 1360 SimpleIdentifier stackTraceParameter2 = clause.stackTraceParameter;
1361 stackTraceParameter4.element = new LocalVariableElementImpl(stackTraceParame ter4); 1361 stackTraceParameter2.element = new LocalVariableElementImpl(stackTraceParame ter2);
1362 resolve(clause, _typeProvider.objectType, _typeProvider.stackTraceType, []); 1362 resolve(clause, _typeProvider.objectType, _typeProvider.stackTraceType, []);
1363 _listener.assertNoErrors(); 1363 _listener.assertNoErrors();
1364 } 1364 }
1365 void test_visitCatchClause_on_exception() { 1365 void test_visitCatchClause_on_exception() {
1366 ClassElement exceptionElement = ElementFactory.classElement2("E", []); 1366 ClassElement exceptionElement = ElementFactory.classElement2("E", []);
1367 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); 1367 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []);
1368 CatchClause clause = ASTFactory.catchClause4(exceptionType, "e", []); 1368 CatchClause clause = ASTFactory.catchClause4(exceptionType, "e", []);
1369 SimpleIdentifier exceptionParameter6 = clause.exceptionParameter; 1369 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter;
1370 exceptionParameter6.element = new LocalVariableElementImpl(exceptionParamete r6); 1370 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete r2);
1371 resolve(clause, exceptionElement.type, null, [exceptionElement]); 1371 resolve(clause, exceptionElement.type, null, [exceptionElement]);
1372 _listener.assertNoErrors(); 1372 _listener.assertNoErrors();
1373 } 1373 }
1374 void test_visitCatchClause_on_exception_stackTrace() { 1374 void test_visitCatchClause_on_exception_stackTrace() {
1375 ClassElement exceptionElement = ElementFactory.classElement2("E", []); 1375 ClassElement exceptionElement = ElementFactory.classElement2("E", []);
1376 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); 1376 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []);
1377 ((exceptionType.name as SimpleIdentifier)).element = exceptionElement; 1377 ((exceptionType.name as SimpleIdentifier)).element = exceptionElement;
1378 CatchClause clause = ASTFactory.catchClause5(exceptionType, "e", "s", []); 1378 CatchClause clause = ASTFactory.catchClause5(exceptionType, "e", "s", []);
1379 SimpleIdentifier exceptionParameter7 = clause.exceptionParameter; 1379 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter;
1380 exceptionParameter7.element = new LocalVariableElementImpl(exceptionParamete r7); 1380 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete r2);
1381 SimpleIdentifier stackTraceParameter5 = clause.stackTraceParameter; 1381 SimpleIdentifier stackTraceParameter2 = clause.stackTraceParameter;
1382 stackTraceParameter5.element = new LocalVariableElementImpl(stackTraceParame ter5); 1382 stackTraceParameter2.element = new LocalVariableElementImpl(stackTraceParame ter2);
1383 resolve(clause, exceptionElement.type, _typeProvider.stackTraceType, [except ionElement]); 1383 resolve(clause, exceptionElement.type, _typeProvider.stackTraceType, [except ionElement]);
1384 _listener.assertNoErrors(); 1384 _listener.assertNoErrors();
1385 } 1385 }
1386 void test_visitClassDeclaration() { 1386 void test_visitClassDeclaration() {
1387 ClassElement elementA = ElementFactory.classElement2("A", []); 1387 ClassElement elementA = ElementFactory.classElement2("A", []);
1388 ClassElement elementB = ElementFactory.classElement2("B", []); 1388 ClassElement elementB = ElementFactory.classElement2("B", []);
1389 ClassElement elementC = ElementFactory.classElement2("C", []); 1389 ClassElement elementC = ElementFactory.classElement2("C", []);
1390 ClassElement elementD = ElementFactory.classElement2("D", []); 1390 ClassElement elementD = ElementFactory.classElement2("D", []);
1391 ExtendsClause extendsClause2 = ASTFactory.extendsClause(ASTFactory.typeName( elementB, [])); 1391 ExtendsClause extendsClause2 = ASTFactory.extendsClause(ASTFactory.typeName( elementB, []));
1392 WithClause withClause2 = ASTFactory.withClause([ASTFactory.typeName(elementC , [])]); 1392 WithClause withClause2 = ASTFactory.withClause([ASTFactory.typeName(elementC , [])]);
1393 ImplementsClause implementsClause2 = ASTFactory.implementsClause([ASTFactory .typeName(elementD, [])]); 1393 ImplementsClause implementsClause2 = ASTFactory.implementsClause([ASTFactory .typeName(elementD, [])]);
1394 ClassDeclaration declaration = ASTFactory.classDeclaration(null, "A", null, extendsClause2, withClause2, implementsClause2, []); 1394 ClassDeclaration declaration = ASTFactory.classDeclaration(null, "A", null, extendsClause2, withClause2, implementsClause2, []);
1395 declaration.name.element = elementA; 1395 declaration.name.element = elementA;
1396 resolveNode(declaration, [elementA, elementB, elementC, elementD]); 1396 resolveNode(declaration, [elementA, elementB, elementC, elementD]);
1397 JUnitTestCase.assertSame(elementB.type, elementA.supertype); 1397 JUnitTestCase.assertSame(elementB.type, elementA.supertype);
1398 List<InterfaceType> mixins4 = elementA.mixins; 1398 List<InterfaceType> mixins2 = elementA.mixins;
1399 EngineTestCase.assertLength(1, mixins4); 1399 EngineTestCase.assertLength(1, mixins2);
1400 JUnitTestCase.assertSame(elementC.type, mixins4[0]); 1400 JUnitTestCase.assertSame(elementC.type, mixins2[0]);
1401 List<InterfaceType> interfaces5 = elementA.interfaces; 1401 List<InterfaceType> interfaces2 = elementA.interfaces;
1402 EngineTestCase.assertLength(1, interfaces5); 1402 EngineTestCase.assertLength(1, interfaces2);
1403 JUnitTestCase.assertSame(elementD.type, interfaces5[0]); 1403 JUnitTestCase.assertSame(elementD.type, interfaces2[0]);
1404 _listener.assertNoErrors(); 1404 _listener.assertNoErrors();
1405 } 1405 }
1406 void test_visitClassTypeAlias() { 1406 void test_visitClassTypeAlias() {
1407 ClassElement elementA = ElementFactory.classElement2("A", []); 1407 ClassElement elementA = ElementFactory.classElement2("A", []);
1408 ClassElement elementB = ElementFactory.classElement2("B", []); 1408 ClassElement elementB = ElementFactory.classElement2("B", []);
1409 ClassElement elementC = ElementFactory.classElement2("C", []); 1409 ClassElement elementC = ElementFactory.classElement2("C", []);
1410 ClassElement elementD = ElementFactory.classElement2("D", []); 1410 ClassElement elementD = ElementFactory.classElement2("D", []);
1411 WithClause withClause3 = ASTFactory.withClause([ASTFactory.typeName(elementC , [])]); 1411 WithClause withClause2 = ASTFactory.withClause([ASTFactory.typeName(elementC , [])]);
1412 ImplementsClause implementsClause3 = ASTFactory.implementsClause([ASTFactory .typeName(elementD, [])]); 1412 ImplementsClause implementsClause2 = ASTFactory.implementsClause([ASTFactory .typeName(elementD, [])]);
1413 ClassTypeAlias alias = ASTFactory.classTypeAlias("A", null, null, ASTFactory .typeName(elementB, []), withClause3, implementsClause3); 1413 ClassTypeAlias alias = ASTFactory.classTypeAlias("A", null, null, ASTFactory .typeName(elementB, []), withClause2, implementsClause2);
1414 alias.name.element = elementA; 1414 alias.name.element = elementA;
1415 resolveNode(alias, [elementA, elementB, elementC, elementD]); 1415 resolveNode(alias, [elementA, elementB, elementC, elementD]);
1416 JUnitTestCase.assertSame(elementB.type, elementA.supertype); 1416 JUnitTestCase.assertSame(elementB.type, elementA.supertype);
1417 List<InterfaceType> mixins5 = elementA.mixins; 1417 List<InterfaceType> mixins2 = elementA.mixins;
1418 EngineTestCase.assertLength(1, mixins5); 1418 EngineTestCase.assertLength(1, mixins2);
1419 JUnitTestCase.assertSame(elementC.type, mixins5[0]); 1419 JUnitTestCase.assertSame(elementC.type, mixins2[0]);
1420 List<InterfaceType> interfaces6 = elementA.interfaces; 1420 List<InterfaceType> interfaces2 = elementA.interfaces;
1421 EngineTestCase.assertLength(1, interfaces6); 1421 EngineTestCase.assertLength(1, interfaces2);
1422 JUnitTestCase.assertSame(elementD.type, interfaces6[0]); 1422 JUnitTestCase.assertSame(elementD.type, interfaces2[0]);
1423 _listener.assertNoErrors(); 1423 _listener.assertNoErrors();
1424 } 1424 }
1425 void test_visitSimpleFormalParameter_noType() { 1425 void test_visitSimpleFormalParameter_noType() {
1426 FormalParameter node = ASTFactory.simpleFormalParameter3("p"); 1426 FormalParameter node = ASTFactory.simpleFormalParameter3("p");
1427 node.identifier.element = new ParameterElementImpl(ASTFactory.identifier3("p ")); 1427 node.identifier.element = new ParameterElementImpl(ASTFactory.identifier3("p "));
1428 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve5(node, [])); 1428 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve5(node, []));
1429 _listener.assertNoErrors(); 1429 _listener.assertNoErrors();
1430 } 1430 }
1431 void test_visitSimpleFormalParameter_type() { 1431 void test_visitSimpleFormalParameter_type() {
1432 InterfaceType intType10 = _typeProvider.intType; 1432 InterfaceType intType2 = _typeProvider.intType;
1433 ClassElement intElement = intType10.element; 1433 ClassElement intElement = intType2.element;
1434 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName (intElement, []), "p"); 1434 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName (intElement, []), "p");
1435 SimpleIdentifier identifier20 = node.identifier; 1435 SimpleIdentifier identifier2 = node.identifier;
1436 ParameterElementImpl element = new ParameterElementImpl(identifier20); 1436 ParameterElementImpl element = new ParameterElementImpl(identifier2);
1437 identifier20.element = element; 1437 identifier2.element = element;
1438 JUnitTestCase.assertSame(intType10, resolve5(node, [intElement])); 1438 JUnitTestCase.assertSame(intType2, resolve5(node, [intElement]));
1439 _listener.assertNoErrors(); 1439 _listener.assertNoErrors();
1440 } 1440 }
1441 void test_visitTypeName_noParameters_noArguments() { 1441 void test_visitTypeName_noParameters_noArguments() {
1442 ClassElement classA = ElementFactory.classElement2("A", []); 1442 ClassElement classA = ElementFactory.classElement2("A", []);
1443 TypeName typeName6 = ASTFactory.typeName(classA, []); 1443 TypeName typeName2 = ASTFactory.typeName(classA, []);
1444 typeName6.type = null; 1444 typeName2.type = null;
1445 resolveNode(typeName6, [classA]); 1445 resolveNode(typeName2, [classA]);
1446 JUnitTestCase.assertSame(classA.type, typeName6.type); 1446 JUnitTestCase.assertSame(classA.type, typeName2.type);
1447 _listener.assertNoErrors(); 1447 _listener.assertNoErrors();
1448 } 1448 }
1449 void test_visitTypeName_parameters_arguments() { 1449 void test_visitTypeName_parameters_arguments() {
1450 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 1450 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
1451 ClassElement classB = ElementFactory.classElement2("B", []); 1451 ClassElement classB = ElementFactory.classElement2("B", []);
1452 TypeName typeName7 = ASTFactory.typeName(classA, [ASTFactory.typeName(classB , [])]); 1452 TypeName typeName2 = ASTFactory.typeName(classA, [ASTFactory.typeName(classB , [])]);
1453 typeName7.type = null; 1453 typeName2.type = null;
1454 resolveNode(typeName7, [classA, classB]); 1454 resolveNode(typeName2, [classA, classB]);
1455 InterfaceType resultType = typeName7.type as InterfaceType; 1455 InterfaceType resultType = typeName2.type as InterfaceType;
1456 JUnitTestCase.assertSame(classA, resultType.element); 1456 JUnitTestCase.assertSame(classA, resultType.element);
1457 List<Type2> resultArguments = resultType.typeArguments; 1457 List<Type2> resultArguments = resultType.typeArguments;
1458 EngineTestCase.assertLength(1, resultArguments); 1458 EngineTestCase.assertLength(1, resultArguments);
1459 JUnitTestCase.assertSame(classB.type, resultArguments[0]); 1459 JUnitTestCase.assertSame(classB.type, resultArguments[0]);
1460 _listener.assertNoErrors(); 1460 _listener.assertNoErrors();
1461 } 1461 }
1462 void test_visitTypeName_parameters_noArguments() { 1462 void test_visitTypeName_parameters_noArguments() {
1463 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 1463 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
1464 TypeName typeName8 = ASTFactory.typeName(classA, []); 1464 TypeName typeName2 = ASTFactory.typeName(classA, []);
1465 typeName8.type = null; 1465 typeName2.type = null;
1466 resolveNode(typeName8, [classA]); 1466 resolveNode(typeName2, [classA]);
1467 InterfaceType resultType = typeName8.type as InterfaceType; 1467 InterfaceType resultType = typeName2.type as InterfaceType;
1468 JUnitTestCase.assertSame(classA, resultType.element); 1468 JUnitTestCase.assertSame(classA, resultType.element);
1469 List<Type2> resultArguments = resultType.typeArguments; 1469 List<Type2> resultArguments = resultType.typeArguments;
1470 EngineTestCase.assertLength(1, resultArguments); 1470 EngineTestCase.assertLength(1, resultArguments);
1471 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]); 1471 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]);
1472 _listener.assertNoErrors(); 1472 _listener.assertNoErrors();
1473 } 1473 }
1474 void test_visitTypeName_void() { 1474 void test_visitTypeName_void() {
1475 ClassElement classA = ElementFactory.classElement2("A", []); 1475 ClassElement classA = ElementFactory.classElement2("A", []);
1476 TypeName typeName = ASTFactory.typeName4("void", []); 1476 TypeName typeName = ASTFactory.typeName4("void", []);
1477 resolveNode(typeName, [classA]); 1477 resolveNode(typeName, [classA]);
1478 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type); 1478 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type);
1479 _listener.assertNoErrors(); 1479 _listener.assertNoErrors();
1480 } 1480 }
1481 /** 1481 /**
1482 * Analyze the given catch clause and assert that the types of the parameters have been set to the 1482 * Analyze the given catch clause and assert that the types of the parameters have been set to the
1483 * given types. The types can be null if the catch clause does not have the co rresponding 1483 * given types. The types can be null if the catch clause does not have the co rresponding
1484 * parameter. 1484 * parameter.
1485 * @param node the catch clause to be analyzed 1485 * @param node the catch clause to be analyzed
1486 * @param exceptionType the expected type of the exception parameter 1486 * @param exceptionType the expected type of the exception parameter
1487 * @param stackTraceType the expected type of the stack trace parameter 1487 * @param stackTraceType the expected type of the stack trace parameter
1488 * @param definedElements the elements that are to be defined in the scope in which the element is 1488 * @param definedElements the elements that are to be defined in the scope in which the element is
1489 * being resolved 1489 * being resolved
1490 */ 1490 */
1491 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac kTraceType, List<Element> definedElements) { 1491 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac kTraceType, List<Element> definedElements) {
1492 resolveNode(node, definedElements); 1492 resolveNode(node, definedElements);
1493 SimpleIdentifier exceptionParameter8 = node.exceptionParameter; 1493 SimpleIdentifier exceptionParameter2 = node.exceptionParameter;
1494 if (exceptionParameter8 != null) { 1494 if (exceptionParameter2 != null) {
1495 JUnitTestCase.assertSame(exceptionType, exceptionParameter8.staticType); 1495 JUnitTestCase.assertSame(exceptionType, exceptionParameter2.staticType);
1496 } 1496 }
1497 SimpleIdentifier stackTraceParameter6 = node.stackTraceParameter; 1497 SimpleIdentifier stackTraceParameter2 = node.stackTraceParameter;
1498 if (stackTraceParameter6 != null) { 1498 if (stackTraceParameter2 != null) {
1499 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter6.staticType); 1499 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter2.staticType);
1500 } 1500 }
1501 } 1501 }
1502 /** 1502 /**
1503 * Return the type associated with the given parameter after the static type a nalyzer has computed 1503 * Return the type associated with the given parameter after the static type a nalyzer has computed
1504 * a type for it. 1504 * a type for it.
1505 * @param node the parameter with which the type is associated 1505 * @param node the parameter with which the type is associated
1506 * @param definedElements the elements that are to be defined in the scope in which the element is 1506 * @param definedElements the elements that are to be defined in the scope in which the element is
1507 * being resolved 1507 * being resolved
1508 * @return the type associated with the parameter 1508 * @return the type associated with the parameter
1509 */ 1509 */
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 return null; 3217 return null;
3218 } 3218 }
3219 Object visitLibraryIdentifier(LibraryIdentifier node) => null; 3219 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
3220 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 3220 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
3221 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) { 3221 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) {
3222 return null; 3222 return null;
3223 } 3223 }
3224 return super.visitPrefixedIdentifier(node); 3224 return super.visitPrefixedIdentifier(node);
3225 } 3225 }
3226 Object visitSimpleIdentifier(SimpleIdentifier node) { 3226 Object visitSimpleIdentifier(SimpleIdentifier node) {
3227 ASTNode parent21 = node.parent; 3227 ASTNode parent2 = node.parent;
3228 if (parent21 is MethodInvocation && identical(node, ((parent21 as MethodInvo cation)).methodName)) { 3228 if (parent2 is MethodInvocation && identical(node, ((parent2 as MethodInvoca tion)).methodName)) {
3229 return null; 3229 return null;
3230 } else if (parent21 is RedirectingConstructorInvocation && identical(node, ( (parent21 as RedirectingConstructorInvocation)).constructorName)) { 3230 } else if (parent2 is RedirectingConstructorInvocation && identical(node, (( parent2 as RedirectingConstructorInvocation)).constructorName)) {
3231 return null; 3231 return null;
3232 } else if (parent21 is SuperConstructorInvocation && identical(node, ((paren t21 as SuperConstructorInvocation)).constructorName)) { 3232 } else if (parent2 is SuperConstructorInvocation && identical(node, ((parent 2 as SuperConstructorInvocation)).constructorName)) {
3233 return null; 3233 return null;
3234 } else if (parent21 is ConstructorName && identical(node, ((parent21 as Cons tructorName)).name)) { 3234 } else if (parent2 is ConstructorName && identical(node, ((parent2 as Constr uctorName)).name)) {
3235 return null; 3235 return null;
3236 } else if (parent21 is Label && identical(node, ((parent21 as Label)).label) ) { 3236 } else if (parent2 is Label && identical(node, ((parent2 as Label)).label)) {
3237 return null; 3237 return null;
3238 } else if (parent21 is ImportDirective && identical(node, ((parent21 as Impo rtDirective)).prefix)) { 3238 } else if (parent2 is ImportDirective && identical(node, ((parent2 as Import Directive)).prefix)) {
3239 return null; 3239 return null;
3240 } else if (node.element is PrefixElement) { 3240 } else if (node.element is PrefixElement) {
3241 return null; 3241 return null;
3242 } 3242 }
3243 return super.visitSimpleIdentifier(node); 3243 return super.visitSimpleIdentifier(node);
3244 } 3244 }
3245 Object visitTypeName(TypeName node) { 3245 Object visitTypeName(TypeName node) {
3246 if (node.type == null) { 3246 if (node.type == null) {
3247 _unresolvedTypes.add(node); 3247 _unresolvedTypes.add(node);
3248 } else { 3248 } else {
3249 _resolvedTypeCount++; 3249 _resolvedTypeCount++;
3250 } 3250 }
3251 return null; 3251 return null;
3252 } 3252 }
3253 String getFileName(ASTNode node) { 3253 String getFileName(ASTNode node) {
3254 if (node != null) { 3254 if (node != null) {
3255 ASTNode root3 = node.root; 3255 ASTNode root2 = node.root;
3256 if (root3 is CompilationUnit) { 3256 if (root2 is CompilationUnit) {
3257 CompilationUnit rootCU = (root3 as CompilationUnit); 3257 CompilationUnit rootCU = (root2 as CompilationUnit);
3258 if (rootCU.element != null) { 3258 if (rootCU.element != null) {
3259 return rootCU.element.source.fullName; 3259 return rootCU.element.source.fullName;
3260 } else { 3260 } else {
3261 return "<unknown file- CompilationUnit.getElement() returned null>"; 3261 return "<unknown file- CompilationUnit.getElement() returned null>";
3262 } 3262 }
3263 } else { 3263 } else {
3264 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>"; 3264 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
3265 } 3265 }
3266 } 3266 }
3267 return "<unknown file- ASTNode is null>"; 3267 return "<unknown file- ASTNode is null>";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 void fail_visitRedirectingConstructorInvocation() { 3315 void fail_visitRedirectingConstructorInvocation() {
3316 JUnitTestCase.fail("Not yet tested"); 3316 JUnitTestCase.fail("Not yet tested");
3317 _listener.assertNoErrors(); 3317 _listener.assertNoErrors();
3318 } 3318 }
3319 void setUp() { 3319 void setUp() {
3320 _listener = new GatheringErrorListener(); 3320 _listener = new GatheringErrorListener();
3321 _typeProvider = new TestTypeProvider(); 3321 _typeProvider = new TestTypeProvider();
3322 _resolver = createResolver(); 3322 _resolver = createResolver();
3323 } 3323 }
3324 void test_visitAssignmentExpression_compound() { 3324 void test_visitAssignmentExpression_compound() {
3325 InterfaceType intType3 = _typeProvider.intType; 3325 InterfaceType intType2 = _typeProvider.intType;
3326 SimpleIdentifier leftHandSide = ASTFactory.identifier3("a"); 3326 SimpleIdentifier leftHandSide = ASTFactory.identifier3("a");
3327 leftHandSide.staticType = intType3; 3327 leftHandSide.staticType = intType2;
3328 AssignmentExpression assignment = ASTFactory.assignmentExpression(leftHandSi de, TokenType.PLUS_EQ, ASTFactory.integer(1)); 3328 AssignmentExpression assignment = ASTFactory.assignmentExpression(leftHandSi de, TokenType.PLUS_EQ, ASTFactory.integer(1));
3329 resolveNode(assignment, []); 3329 resolveNode(assignment, []);
3330 JUnitTestCase.assertSame(getMethod(_typeProvider.numType, "+"), assignment.e lement); 3330 JUnitTestCase.assertSame(getMethod(_typeProvider.numType, "+"), assignment.e lement);
3331 _listener.assertNoErrors(); 3331 _listener.assertNoErrors();
3332 } 3332 }
3333 void test_visitAssignmentExpression_simple() { 3333 void test_visitAssignmentExpression_simple() {
3334 AssignmentExpression expression = ASTFactory.assignmentExpression(ASTFactory .identifier3("x"), TokenType.EQ, ASTFactory.integer(0)); 3334 AssignmentExpression expression = ASTFactory.assignmentExpression(ASTFactory .identifier3("x"), TokenType.EQ, ASTFactory.integer(0));
3335 resolveNode(expression, []); 3335 resolveNode(expression, []);
3336 JUnitTestCase.assertNull(expression.element); 3336 JUnitTestCase.assertNull(expression.element);
3337 _listener.assertNoErrors(); 3337 _listener.assertNoErrors();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 String prefixName = "p"; 3405 String prefixName = "p";
3406 ImportElement importElement = ElementFactory.importFor(ElementFactory.librar y(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName), []); 3406 ImportElement importElement = ElementFactory.importFor(ElementFactory.librar y(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName), []);
3407 _definingLibrary.imports = <ImportElement> [importElement]; 3407 _definingLibrary.imports = <ImportElement> [importElement];
3408 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, [] ); 3408 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, [] );
3409 directive.element = importElement; 3409 directive.element = importElement;
3410 resolveNode(directive, []); 3410 resolveNode(directive, []);
3411 _listener.assertNoErrors(); 3411 _listener.assertNoErrors();
3412 } 3412 }
3413 void test_visitIndexExpression_get() { 3413 void test_visitIndexExpression_get() {
3414 ClassElementImpl classA = ElementFactory.classElement2("A", []); 3414 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3415 InterfaceType intType4 = _typeProvider.intType; 3415 InterfaceType intType2 = _typeProvider.intType;
3416 MethodElement getter = ElementFactory.methodElement("[]", intType4, [intType 4]); 3416 MethodElement getter = ElementFactory.methodElement("[]", intType2, [intType 2]);
3417 classA.methods = <MethodElement> [getter]; 3417 classA.methods = <MethodElement> [getter];
3418 SimpleIdentifier array = ASTFactory.identifier3("a"); 3418 SimpleIdentifier array = ASTFactory.identifier3("a");
3419 array.staticType = classA.type; 3419 array.staticType = classA.type;
3420 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i")); 3420 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i"));
3421 JUnitTestCase.assertSame(getter, resolve4(expression, [])); 3421 JUnitTestCase.assertSame(getter, resolve4(expression, []));
3422 _listener.assertNoErrors(); 3422 _listener.assertNoErrors();
3423 } 3423 }
3424 void test_visitIndexExpression_set() { 3424 void test_visitIndexExpression_set() {
3425 ClassElementImpl classA = ElementFactory.classElement2("A", []); 3425 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3426 InterfaceType intType5 = _typeProvider.intType; 3426 InterfaceType intType2 = _typeProvider.intType;
3427 MethodElement setter = ElementFactory.methodElement("[]=", intType5, [intTyp e5]); 3427 MethodElement setter = ElementFactory.methodElement("[]=", intType2, [intTyp e2]);
3428 classA.methods = <MethodElement> [setter]; 3428 classA.methods = <MethodElement> [setter];
3429 SimpleIdentifier array = ASTFactory.identifier3("a"); 3429 SimpleIdentifier array = ASTFactory.identifier3("a");
3430 array.staticType = classA.type; 3430 array.staticType = classA.type;
3431 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i")); 3431 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i"));
3432 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer (0)); 3432 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer (0));
3433 JUnitTestCase.assertSame(setter, resolve4(expression, [])); 3433 JUnitTestCase.assertSame(setter, resolve4(expression, []));
3434 _listener.assertNoErrors(); 3434 _listener.assertNoErrors();
3435 } 3435 }
3436 void test_visitInstanceCreationExpression_named() { 3436 void test_visitInstanceCreationExpression_named() {
3437 ClassElementImpl classA = ElementFactory.classElement2("A", []); 3437 ClassElementImpl classA = ElementFactory.classElement2("A", []);
(...skipping 29 matching lines...) Expand all
3467 classA.constructors = <ConstructorElement> [constructor]; 3467 classA.constructors = <ConstructorElement> [constructor];
3468 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName); 3468 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
3469 name.element = constructor; 3469 name.element = constructor;
3470 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege r(0))]); 3470 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege r(0))]);
3471 resolveNode(creation, []); 3471 resolveNode(creation, []);
3472 JUnitTestCase.assertSame(constructor, creation.element); 3472 JUnitTestCase.assertSame(constructor, creation.element);
3473 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as NamedExpression)).name.label.element); 3473 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as NamedExpression)).name.label.element);
3474 _listener.assertNoErrors(); 3474 _listener.assertNoErrors();
3475 } 3475 }
3476 void test_visitMethodInvocation() { 3476 void test_visitMethodInvocation() {
3477 InterfaceType numType3 = _typeProvider.numType; 3477 InterfaceType numType2 = _typeProvider.numType;
3478 SimpleIdentifier left = ASTFactory.identifier3("i"); 3478 SimpleIdentifier left = ASTFactory.identifier3("i");
3479 left.staticType = numType3; 3479 left.staticType = numType2;
3480 String methodName = "abs"; 3480 String methodName = "abs";
3481 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName, []); 3481 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName, []);
3482 resolveNode(invocation, []); 3482 resolveNode(invocation, []);
3483 JUnitTestCase.assertSame(getMethod(numType3, methodName), invocation.methodN ame.element); 3483 JUnitTestCase.assertSame(getMethod(numType2, methodName), invocation.methodN ame.element);
3484 _listener.assertNoErrors(); 3484 _listener.assertNoErrors();
3485 } 3485 }
3486 void test_visitMethodInvocation_namedParameter() { 3486 void test_visitMethodInvocation_namedParameter() {
3487 ClassElementImpl classA = ElementFactory.classElement2("A", []); 3487 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3488 String methodName = "m"; 3488 String methodName = "m";
3489 String parameterName = "p"; 3489 String parameterName = "p";
3490 MethodElementImpl method = ElementFactory.methodElement(methodName, null, [] ); 3490 MethodElementImpl method = ElementFactory.methodElement(methodName, null, [] );
3491 ParameterElement parameter = ElementFactory.namedParameter(parameterName); 3491 ParameterElement parameter = ElementFactory.namedParameter(parameterName);
3492 method.parameters = <ParameterElement> [parameter]; 3492 method.parameters = <ParameterElement> [parameter];
3493 classA.methods = <MethodElement> [method]; 3493 classA.methods = <MethodElement> [method];
3494 SimpleIdentifier left = ASTFactory.identifier3("i"); 3494 SimpleIdentifier left = ASTFactory.identifier3("i");
3495 left.staticType = classA.type; 3495 left.staticType = classA.type;
3496 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName, [ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); 3496 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName, [ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]);
3497 resolveNode(invocation, []); 3497 resolveNode(invocation, []);
3498 JUnitTestCase.assertSame(method, invocation.methodName.element); 3498 JUnitTestCase.assertSame(method, invocation.methodName.element);
3499 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.element); 3499 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.element);
3500 _listener.assertNoErrors(); 3500 _listener.assertNoErrors();
3501 } 3501 }
3502 void test_visitPostfixExpression() { 3502 void test_visitPostfixExpression() {
3503 InterfaceType numType4 = _typeProvider.numType; 3503 InterfaceType numType2 = _typeProvider.numType;
3504 SimpleIdentifier operand = ASTFactory.identifier3("i"); 3504 SimpleIdentifier operand = ASTFactory.identifier3("i");
3505 operand.staticType = numType4; 3505 operand.staticType = numType2;
3506 PostfixExpression expression = ASTFactory.postfixExpression(operand, TokenTy pe.PLUS_PLUS); 3506 PostfixExpression expression = ASTFactory.postfixExpression(operand, TokenTy pe.PLUS_PLUS);
3507 resolveNode(expression, []); 3507 resolveNode(expression, []);
3508 JUnitTestCase.assertEquals(getMethod(numType4, "+"), expression.element); 3508 JUnitTestCase.assertEquals(getMethod(numType2, "+"), expression.element);
3509 _listener.assertNoErrors(); 3509 _listener.assertNoErrors();
3510 } 3510 }
3511 void test_visitPrefixedIdentifier_dynamic() { 3511 void test_visitPrefixedIdentifier_dynamic() {
3512 Type2 dynamicType2 = _typeProvider.dynamicType; 3512 Type2 dynamicType2 = _typeProvider.dynamicType;
3513 SimpleIdentifier target = ASTFactory.identifier3("a"); 3513 SimpleIdentifier target = ASTFactory.identifier3("a");
3514 VariableElementImpl variable = ElementFactory.localVariableElement(target); 3514 VariableElementImpl variable = ElementFactory.localVariableElement(target);
3515 variable.type = dynamicType2; 3515 variable.type = dynamicType2;
3516 target.element = variable; 3516 target.element = variable;
3517 target.staticType = dynamicType2; 3517 target.staticType = dynamicType2;
3518 PrefixedIdentifier identifier6 = ASTFactory.identifier(target, ASTFactory.id entifier3("b")); 3518 PrefixedIdentifier identifier2 = ASTFactory.identifier(target, ASTFactory.id entifier3("b"));
3519 resolveNode(identifier6, []); 3519 resolveNode(identifier2, []);
3520 JUnitTestCase.assertNull(identifier6.element); 3520 JUnitTestCase.assertNull(identifier2.element);
3521 JUnitTestCase.assertNull(identifier6.identifier.element); 3521 JUnitTestCase.assertNull(identifier2.identifier.element);
3522 _listener.assertNoErrors(); 3522 _listener.assertNoErrors();
3523 } 3523 }
3524 void test_visitPrefixedIdentifier_nonDynamic() { 3524 void test_visitPrefixedIdentifier_nonDynamic() {
3525 ClassElementImpl classA = ElementFactory.classElement2("A", []); 3525 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3526 String getterName = "b"; 3526 String getterName = "b";
3527 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType); 3527 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType);
3528 classA.accessors = <PropertyAccessorElement> [getter]; 3528 classA.accessors = <PropertyAccessorElement> [getter];
3529 SimpleIdentifier target = ASTFactory.identifier3("a"); 3529 SimpleIdentifier target = ASTFactory.identifier3("a");
3530 VariableElementImpl variable = ElementFactory.localVariableElement(target); 3530 VariableElementImpl variable = ElementFactory.localVariableElement(target);
3531 variable.type = classA.type; 3531 variable.type = classA.type;
3532 target.element = variable; 3532 target.element = variable;
3533 target.staticType = classA.type; 3533 target.staticType = classA.type;
3534 PrefixedIdentifier identifier7 = ASTFactory.identifier(target, ASTFactory.id entifier3(getterName)); 3534 PrefixedIdentifier identifier2 = ASTFactory.identifier(target, ASTFactory.id entifier3(getterName));
3535 resolveNode(identifier7, []); 3535 resolveNode(identifier2, []);
3536 JUnitTestCase.assertSame(getter, identifier7.element); 3536 JUnitTestCase.assertSame(getter, identifier2.element);
3537 JUnitTestCase.assertSame(getter, identifier7.identifier.element); 3537 JUnitTestCase.assertSame(getter, identifier2.identifier.element);
3538 _listener.assertNoErrors(); 3538 _listener.assertNoErrors();
3539 } 3539 }
3540 void test_visitPrefixExpression() { 3540 void test_visitPrefixExpression() {
3541 InterfaceType numType5 = _typeProvider.numType; 3541 InterfaceType numType2 = _typeProvider.numType;
3542 SimpleIdentifier operand = ASTFactory.identifier3("i"); 3542 SimpleIdentifier operand = ASTFactory.identifier3("i");
3543 operand.staticType = numType5; 3543 operand.staticType = numType2;
3544 PrefixExpression expression = ASTFactory.prefixExpression(TokenType.PLUS_PLU S, operand); 3544 PrefixExpression expression = ASTFactory.prefixExpression(TokenType.PLUS_PLU S, operand);
3545 resolveNode(expression, []); 3545 resolveNode(expression, []);
3546 JUnitTestCase.assertEquals(getMethod(numType5, "+"), expression.element); 3546 JUnitTestCase.assertEquals(getMethod(numType2, "+"), expression.element);
3547 _listener.assertNoErrors(); 3547 _listener.assertNoErrors();
3548 } 3548 }
3549 void test_visitPropertyAccess_getter_identifier() { 3549 void test_visitPropertyAccess_getter_identifier() {
3550 ClassElementImpl classA = ElementFactory.classElement2("A", []); 3550 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3551 String getterName = "b"; 3551 String getterName = "b";
3552 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType); 3552 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType);
3553 classA.accessors = <PropertyAccessorElement> [getter]; 3553 classA.accessors = <PropertyAccessorElement> [getter];
3554 SimpleIdentifier target = ASTFactory.identifier3("a"); 3554 SimpleIdentifier target = ASTFactory.identifier3("a");
3555 target.staticType = classA.type; 3555 target.staticType = classA.type;
3556 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); 3556 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName);
(...skipping 20 matching lines...) Expand all
3577 classA.accessors = <PropertyAccessorElement> [setter]; 3577 classA.accessors = <PropertyAccessorElement> [setter];
3578 ThisExpression target = ASTFactory.thisExpression(); 3578 ThisExpression target = ASTFactory.thisExpression();
3579 target.staticType = classA.type; 3579 target.staticType = classA.type;
3580 PropertyAccess access = ASTFactory.propertyAccess2(target, setterName); 3580 PropertyAccess access = ASTFactory.propertyAccess2(target, setterName);
3581 ASTFactory.assignmentExpression(access, TokenType.EQ, ASTFactory.integer(0)) ; 3581 ASTFactory.assignmentExpression(access, TokenType.EQ, ASTFactory.integer(0)) ;
3582 resolveNode(access, []); 3582 resolveNode(access, []);
3583 JUnitTestCase.assertSame(setter, access.propertyName.element); 3583 JUnitTestCase.assertSame(setter, access.propertyName.element);
3584 _listener.assertNoErrors(); 3584 _listener.assertNoErrors();
3585 } 3585 }
3586 void test_visitSimpleIdentifier_classScope() { 3586 void test_visitSimpleIdentifier_classScope() {
3587 InterfaceType doubleType3 = _typeProvider.doubleType; 3587 InterfaceType doubleType2 = _typeProvider.doubleType;
3588 String fieldName = "NAN"; 3588 String fieldName = "NAN";
3589 SimpleIdentifier node = ASTFactory.identifier3(fieldName); 3589 SimpleIdentifier node = ASTFactory.identifier3(fieldName);
3590 resolveInClass(node, doubleType3.element); 3590 resolveInClass(node, doubleType2.element);
3591 JUnitTestCase.assertEquals(getGetter(doubleType3, fieldName), node.element); 3591 JUnitTestCase.assertEquals(getGetter(doubleType2, fieldName), node.element);
3592 _listener.assertNoErrors(); 3592 _listener.assertNoErrors();
3593 } 3593 }
3594 void test_visitSimpleIdentifier_lexicalScope() { 3594 void test_visitSimpleIdentifier_lexicalScope() {
3595 SimpleIdentifier node = ASTFactory.identifier3("i"); 3595 SimpleIdentifier node = ASTFactory.identifier3("i");
3596 VariableElementImpl element = ElementFactory.localVariableElement(node); 3596 VariableElementImpl element = ElementFactory.localVariableElement(node);
3597 JUnitTestCase.assertSame(element, resolve3(node, [element])); 3597 JUnitTestCase.assertSame(element, resolve3(node, [element]));
3598 _listener.assertNoErrors(); 3598 _listener.assertNoErrors();
3599 } 3599 }
3600 void test_visitSimpleIdentifier_lexicalScope_field_setter() { 3600 void test_visitSimpleIdentifier_lexicalScope_field_setter() {
3601 InterfaceType intType6 = _typeProvider.intType; 3601 InterfaceType intType2 = _typeProvider.intType;
3602 ClassElementImpl classA = ElementFactory.classElement2("A", []); 3602 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3603 String fieldName = "a"; 3603 String fieldName = "a";
3604 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa lse, intType6); 3604 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa lse, intType2);
3605 classA.fields = <FieldElement> [field]; 3605 classA.fields = <FieldElement> [field];
3606 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter]; 3606 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter];
3607 SimpleIdentifier node = ASTFactory.identifier3(fieldName); 3607 SimpleIdentifier node = ASTFactory.identifier3(fieldName);
3608 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); 3608 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
3609 resolveInClass(node, classA); 3609 resolveInClass(node, classA);
3610 Element element65 = node.element; 3610 Element element2 = node.element;
3611 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element65); 3611 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element2);
3612 JUnitTestCase.assertTrue(((element65 as PropertyAccessorElement)).isSetter() ); 3612 JUnitTestCase.assertTrue(((element2 as PropertyAccessorElement)).isSetter()) ;
3613 _listener.assertNoErrors(); 3613 _listener.assertNoErrors();
3614 } 3614 }
3615 void test_visitSuperConstructorInvocation() { 3615 void test_visitSuperConstructorInvocation() {
3616 ClassElementImpl superclass = ElementFactory.classElement2("A", []); 3616 ClassElementImpl superclass = ElementFactory.classElement2("A", []);
3617 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( null); 3617 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( null);
3618 superclass.constructors = <ConstructorElement> [superConstructor]; 3618 superclass.constructors = <ConstructorElement> [superConstructor];
3619 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []); 3619 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []);
3620 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(nu ll); 3620 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(nu ll);
3621 subclass.constructors = <ConstructorElement> [subConstructor]; 3621 subclass.constructors = <ConstructorElement> [subConstructor];
3622 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([]); 3622 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([]);
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 manager.exitScope(); 3939 manager.exitScope();
3940 try { 3940 try {
3941 manager.exitScope(); 3941 manager.exitScope();
3942 JUnitTestCase.fail("Expected IllegalStateException"); 3942 JUnitTestCase.fail("Expected IllegalStateException");
3943 } on IllegalStateException catch (exception) { 3943 } on IllegalStateException catch (exception) {
3944 } 3944 }
3945 } 3945 }
3946 void test_getType_enclosedOverride() { 3946 void test_getType_enclosedOverride() {
3947 TypeOverrideManager manager = new TypeOverrideManager(); 3947 TypeOverrideManager manager = new TypeOverrideManager();
3948 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v") ; 3948 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v") ;
3949 InterfaceType type30 = ElementFactory.classElement2("C", []).type; 3949 InterfaceType type2 = ElementFactory.classElement2("C", []).type;
3950 manager.enterScope(); 3950 manager.enterScope();
3951 manager.setType(element, type30); 3951 manager.setType(element, type2);
3952 manager.enterScope(); 3952 manager.enterScope();
3953 JUnitTestCase.assertSame(type30, manager.getType(element)); 3953 JUnitTestCase.assertSame(type2, manager.getType(element));
3954 } 3954 }
3955 void test_getType_immediateOverride() { 3955 void test_getType_immediateOverride() {
3956 TypeOverrideManager manager = new TypeOverrideManager(); 3956 TypeOverrideManager manager = new TypeOverrideManager();
3957 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v") ; 3957 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v") ;
3958 InterfaceType type31 = ElementFactory.classElement2("C", []).type; 3958 InterfaceType type2 = ElementFactory.classElement2("C", []).type;
3959 manager.enterScope(); 3959 manager.enterScope();
3960 manager.setType(element, type31); 3960 manager.setType(element, type2);
3961 JUnitTestCase.assertSame(type31, manager.getType(element)); 3961 JUnitTestCase.assertSame(type2, manager.getType(element));
3962 } 3962 }
3963 void test_getType_noOverride() { 3963 void test_getType_noOverride() {
3964 TypeOverrideManager manager = new TypeOverrideManager(); 3964 TypeOverrideManager manager = new TypeOverrideManager();
3965 manager.enterScope(); 3965 manager.enterScope();
3966 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement 2("v"))); 3966 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement 2("v")));
3967 } 3967 }
3968 void test_getType_noScope() { 3968 void test_getType_noScope() {
3969 TypeOverrideManager manager = new TypeOverrideManager(); 3969 TypeOverrideManager manager = new TypeOverrideManager();
3970 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement 2("v"))); 3970 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement 2("v")));
3971 } 3971 }
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
4773 _wrongTypedNodes.add(node); 4773 _wrongTypedNodes.add(node);
4774 } 4774 }
4775 return null; 4775 return null;
4776 } 4776 }
4777 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 4777 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
4778 node.visitChildren(this); 4778 node.visitChildren(this);
4779 return checkResolved2(node, node.element, FunctionElement); 4779 return checkResolved2(node, node.element, FunctionElement);
4780 } 4780 }
4781 Object visitImportDirective(ImportDirective node) { 4781 Object visitImportDirective(ImportDirective node) {
4782 checkResolved2(node, node.element, ImportElement); 4782 checkResolved2(node, node.element, ImportElement);
4783 SimpleIdentifier prefix9 = node.prefix; 4783 SimpleIdentifier prefix2 = node.prefix;
4784 if (prefix9 == null) { 4784 if (prefix2 == null) {
4785 return null; 4785 return null;
4786 } 4786 }
4787 return checkResolved2(prefix9, prefix9.element, PrefixElement); 4787 return checkResolved2(prefix2, prefix2.element, PrefixElement);
4788 } 4788 }
4789 Object visitIndexExpression(IndexExpression node) { 4789 Object visitIndexExpression(IndexExpression node) {
4790 node.visitChildren(this); 4790 node.visitChildren(this);
4791 return checkResolved2(node, node.element, MethodElement); 4791 return checkResolved2(node, node.element, MethodElement);
4792 } 4792 }
4793 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no de.element, LibraryElement); 4793 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no de.element, LibraryElement);
4794 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele ment, CompilationUnitElement); 4794 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele ment, CompilationUnitElement);
4795 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node .element, LibraryElement); 4795 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node .element, LibraryElement);
4796 Object visitPostfixExpression(PostfixExpression node) { 4796 Object visitPostfixExpression(PostfixExpression node) {
4797 node.visitChildren(this); 4797 node.visitChildren(this);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
4952 } 4952 }
4953 void test_visitAsExpression() { 4953 void test_visitAsExpression() {
4954 ClassElement superclass = ElementFactory.classElement2("A", []); 4954 ClassElement superclass = ElementFactory.classElement2("A", []);
4955 InterfaceType superclassType = superclass.type; 4955 InterfaceType superclassType = superclass.type;
4956 ClassElement subclass = ElementFactory.classElement("B", superclassType, []) ; 4956 ClassElement subclass = ElementFactory.classElement("B", superclassType, []) ;
4957 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa ctory.typeName(subclass, [])); 4957 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa ctory.typeName(subclass, []));
4958 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType)); 4958 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType));
4959 _listener.assertNoErrors(); 4959 _listener.assertNoErrors();
4960 } 4960 }
4961 void test_visitAssignmentExpression_compound() { 4961 void test_visitAssignmentExpression_compound() {
4962 InterfaceType numType6 = _typeProvider.numType; 4962 InterfaceType numType2 = _typeProvider.numType;
4963 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i"); 4963 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i");
4964 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke nType.PLUS_EQ, resolvedInteger(1)); 4964 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke nType.PLUS_EQ, resolvedInteger(1));
4965 node.element = getMethod(numType6, "+"); 4965 node.element = getMethod(numType2, "+");
4966 JUnitTestCase.assertSame(numType6, analyze(node)); 4966 JUnitTestCase.assertSame(numType2, analyze(node));
4967 _listener.assertNoErrors(); 4967 _listener.assertNoErrors();
4968 } 4968 }
4969 void test_visitAssignmentExpression_simple() { 4969 void test_visitAssignmentExpression_simple() {
4970 InterfaceType intType7 = _typeProvider.intType; 4970 InterfaceType intType2 = _typeProvider.intType;
4971 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType7, "i"), TokenType.EQ, resolvedInteger(0)); 4971 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType2, "i"), TokenType.EQ, resolvedInteger(0));
4972 JUnitTestCase.assertSame(intType7, analyze(node)); 4972 JUnitTestCase.assertSame(intType2, analyze(node));
4973 _listener.assertNoErrors(); 4973 _listener.assertNoErrors();
4974 } 4974 }
4975 void test_visitBinaryExpression_equals() { 4975 void test_visitBinaryExpression_equals() {
4976 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. EQ_EQ, resolvedInteger(3)); 4976 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. EQ_EQ, resolvedInteger(3));
4977 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 4977 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
4978 _listener.assertNoErrors(); 4978 _listener.assertNoErrors();
4979 } 4979 }
4980 void test_visitBinaryExpression_logicalAnd() { 4980 void test_visitBinaryExpression_logicalAnd() {
4981 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true)); 4981 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true));
4982 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 4982 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral (true), resolvedInteger(1), resolvedInteger(0)); 5022 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral (true), resolvedInteger(1), resolvedInteger(0));
5023 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); 5023 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
5024 _listener.assertNoErrors(); 5024 _listener.assertNoErrors();
5025 } 5025 }
5026 void test_visitDoubleLiteral() { 5026 void test_visitDoubleLiteral() {
5027 Expression node = ASTFactory.doubleLiteral(4.33); 5027 Expression node = ASTFactory.doubleLiteral(4.33);
5028 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); 5028 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
5029 _listener.assertNoErrors(); 5029 _listener.assertNoErrors();
5030 } 5030 }
5031 void test_visitFunctionExpression_named_block() { 5031 void test_visitFunctionExpression_named_block() {
5032 Type2 dynamicType3 = _typeProvider.dynamicType; 5032 Type2 dynamicType2 = _typeProvider.dynamicType;
5033 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p1"), resolvedInteger(0)); 5033 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p1"), resolvedInteger(0));
5034 setType(p1, dynamicType3); 5034 setType(p1, dynamicType2);
5035 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0)); 5035 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0));
5036 setType(p2, dynamicType3); 5036 setType(p2, dynamicType2);
5037 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([])); 5037 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([]));
5038 analyze3(p1); 5038 analyze3(p1);
5039 analyze3(p2); 5039 analyze3(p2);
5040 Type2 resultType = analyze(node); 5040 Type2 resultType = analyze(node);
5041 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); 5041 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
5042 expectedNamedTypes["p1"] = dynamicType3; 5042 expectedNamedTypes["p1"] = dynamicType2;
5043 expectedNamedTypes["p2"] = dynamicType3; 5043 expectedNamedTypes["p2"] = dynamicType2;
5044 assertFunctionType(dynamicType3, null, null, expectedNamedTypes, resultType) ; 5044 assertFunctionType(dynamicType2, null, null, expectedNamedTypes, resultType) ;
5045 _listener.assertNoErrors(); 5045 _listener.assertNoErrors();
5046 } 5046 }
5047 void test_visitFunctionExpression_named_expression() { 5047 void test_visitFunctionExpression_named_expression() {
5048 Type2 dynamicType4 = _typeProvider.dynamicType; 5048 Type2 dynamicType2 = _typeProvider.dynamicType;
5049 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP arameter3("p"), resolvedInteger(0)); 5049 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP arameter3("p"), resolvedInteger(0));
5050 setType(p, dynamicType4); 5050 setType(p, dynamicType2);
5051 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); 5051 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
5052 analyze3(p); 5052 analyze3(p);
5053 Type2 resultType = analyze(node); 5053 Type2 resultType = analyze(node);
5054 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); 5054 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
5055 expectedNamedTypes["p"] = dynamicType4; 5055 expectedNamedTypes["p"] = dynamicType2;
5056 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re sultType); 5056 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re sultType);
5057 _listener.assertNoErrors(); 5057 _listener.assertNoErrors();
5058 } 5058 }
5059 void test_visitFunctionExpression_normal_block() { 5059 void test_visitFunctionExpression_normal_block() {
5060 Type2 dynamicType5 = _typeProvider.dynamicType; 5060 Type2 dynamicType2 = _typeProvider.dynamicType;
5061 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); 5061 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
5062 setType(p1, dynamicType5); 5062 setType(p1, dynamicType2);
5063 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2"); 5063 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2");
5064 setType(p2, dynamicType5); 5064 setType(p2, dynamicType2);
5065 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([])); 5065 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([]));
5066 analyze3(p1); 5066 analyze3(p1);
5067 analyze3(p2); 5067 analyze3(p2);
5068 Type2 resultType = analyze(node); 5068 Type2 resultType = analyze(node);
5069 assertFunctionType(dynamicType5, <Type2> [dynamicType5, dynamicType5], null, null, resultType); 5069 assertFunctionType(dynamicType2, <Type2> [dynamicType2, dynamicType2], null, null, resultType);
5070 _listener.assertNoErrors(); 5070 _listener.assertNoErrors();
5071 } 5071 }
5072 void test_visitFunctionExpression_normal_expression() { 5072 void test_visitFunctionExpression_normal_expression() {
5073 Type2 dynamicType6 = _typeProvider.dynamicType; 5073 Type2 dynamicType2 = _typeProvider.dynamicType;
5074 FormalParameter p = ASTFactory.simpleFormalParameter3("p"); 5074 FormalParameter p = ASTFactory.simpleFormalParameter3("p");
5075 setType(p, dynamicType6); 5075 setType(p, dynamicType2);
5076 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); 5076 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
5077 analyze3(p); 5077 analyze3(p);
5078 Type2 resultType = analyze(node); 5078 Type2 resultType = analyze(node);
5079 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType6], null, null , resultType); 5079 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType2], null, null , resultType);
5080 _listener.assertNoErrors(); 5080 _listener.assertNoErrors();
5081 } 5081 }
5082 void test_visitFunctionExpression_normalAndNamed_block() { 5082 void test_visitFunctionExpression_normalAndNamed_block() {
5083 Type2 dynamicType7 = _typeProvider.dynamicType; 5083 Type2 dynamicType2 = _typeProvider.dynamicType;
5084 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); 5084 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
5085 setType(p1, dynamicType7); 5085 setType(p1, dynamicType2);
5086 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0)); 5086 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0));
5087 setType(p2, dynamicType7); 5087 setType(p2, dynamicType2);
5088 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([])); 5088 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([]));
5089 analyze3(p2); 5089 analyze3(p2);
5090 Type2 resultType = analyze(node); 5090 Type2 resultType = analyze(node);
5091 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); 5091 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
5092 expectedNamedTypes["p2"] = dynamicType7; 5092 expectedNamedTypes["p2"] = dynamicType2;
5093 assertFunctionType(dynamicType7, <Type2> [dynamicType7], null, expectedNamed Types, resultType); 5093 assertFunctionType(dynamicType2, <Type2> [dynamicType2], null, expectedNamed Types, resultType);
5094 _listener.assertNoErrors(); 5094 _listener.assertNoErrors();
5095 } 5095 }
5096 void test_visitFunctionExpression_normalAndNamed_expression() { 5096 void test_visitFunctionExpression_normalAndNamed_expression() {
5097 Type2 dynamicType8 = _typeProvider.dynamicType; 5097 Type2 dynamicType2 = _typeProvider.dynamicType;
5098 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); 5098 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
5099 setType(p1, dynamicType8); 5099 setType(p1, dynamicType2);
5100 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0)); 5100 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0));
5101 setType(p2, dynamicType8); 5101 setType(p2, dynamicType2);
5102 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); 5102 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
5103 analyze3(p2); 5103 analyze3(p2);
5104 Type2 resultType = analyze(node); 5104 Type2 resultType = analyze(node);
5105 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); 5105 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
5106 expectedNamedTypes["p2"] = dynamicType8; 5106 expectedNamedTypes["p2"] = dynamicType2;
5107 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType8], null, expe ctedNamedTypes, resultType); 5107 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType2], null, expe ctedNamedTypes, resultType);
5108 _listener.assertNoErrors(); 5108 _listener.assertNoErrors();
5109 } 5109 }
5110 void test_visitFunctionExpression_normalAndPositional_block() { 5110 void test_visitFunctionExpression_normalAndPositional_block() {
5111 Type2 dynamicType9 = _typeProvider.dynamicType; 5111 Type2 dynamicType2 = _typeProvider.dynamicType;
5112 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); 5112 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
5113 setType(p1, dynamicType9); 5113 setType(p1, dynamicType2);
5114 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0)); 5114 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0));
5115 setType(p2, dynamicType9); 5115 setType(p2, dynamicType2);
5116 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([])); 5116 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([]));
5117 analyze3(p1); 5117 analyze3(p1);
5118 analyze3(p2); 5118 analyze3(p2);
5119 Type2 resultType = analyze(node); 5119 Type2 resultType = analyze(node);
5120 assertFunctionType(dynamicType9, <Type2> [dynamicType9], <Type2> [dynamicTyp e9], null, resultType); 5120 assertFunctionType(dynamicType2, <Type2> [dynamicType2], <Type2> [dynamicTyp e2], null, resultType);
5121 _listener.assertNoErrors(); 5121 _listener.assertNoErrors();
5122 } 5122 }
5123 void test_visitFunctionExpression_normalAndPositional_expression() { 5123 void test_visitFunctionExpression_normalAndPositional_expression() {
5124 Type2 dynamicType10 = _typeProvider.dynamicType; 5124 Type2 dynamicType2 = _typeProvider.dynamicType;
5125 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); 5125 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
5126 setType(p1, dynamicType10); 5126 setType(p1, dynamicType2);
5127 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0)); 5127 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0));
5128 setType(p2, dynamicType10); 5128 setType(p2, dynamicType2);
5129 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); 5129 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
5130 analyze3(p1); 5130 analyze3(p1);
5131 analyze3(p2); 5131 analyze3(p2);
5132 Type2 resultType = analyze(node); 5132 Type2 resultType = analyze(node);
5133 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType10], <Type2> [ dynamicType10], null, resultType); 5133 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType2], <Type2> [d ynamicType2], null, resultType);
5134 _listener.assertNoErrors(); 5134 _listener.assertNoErrors();
5135 } 5135 }
5136 void test_visitFunctionExpression_positional_block() { 5136 void test_visitFunctionExpression_positional_block() {
5137 Type2 dynamicType11 = _typeProvider.dynamicType; 5137 Type2 dynamicType2 = _typeProvider.dynamicType;
5138 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p1"), resolvedInteger(0)); 5138 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p1"), resolvedInteger(0));
5139 setType(p1, dynamicType11); 5139 setType(p1, dynamicType2);
5140 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0)); 5140 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0));
5141 setType(p2, dynamicType11); 5141 setType(p2, dynamicType2);
5142 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([])); 5142 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody([]));
5143 analyze3(p1); 5143 analyze3(p1);
5144 analyze3(p2); 5144 analyze3(p2);
5145 Type2 resultType = analyze(node); 5145 Type2 resultType = analyze(node);
5146 assertFunctionType(dynamicType11, null, <Type2> [dynamicType11, dynamicType1 1], null, resultType); 5146 assertFunctionType(dynamicType2, null, <Type2> [dynamicType2, dynamicType2], null, resultType);
5147 _listener.assertNoErrors(); 5147 _listener.assertNoErrors();
5148 } 5148 }
5149 void test_visitFunctionExpression_positional_expression() { 5149 void test_visitFunctionExpression_positional_expression() {
5150 Type2 dynamicType12 = _typeProvider.dynamicType; 5150 Type2 dynamicType2 = _typeProvider.dynamicType;
5151 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo rmalParameter3("p"), resolvedInteger(0)); 5151 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo rmalParameter3("p"), resolvedInteger(0));
5152 setType(p, dynamicType12); 5152 setType(p, dynamicType2);
5153 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); 5153 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
5154 analyze3(p); 5154 analyze3(p);
5155 Type2 resultType = analyze(node); 5155 Type2 resultType = analyze(node);
5156 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType12], nul l, resultType); 5156 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType2], null , resultType);
5157 _listener.assertNoErrors(); 5157 _listener.assertNoErrors();
5158 } 5158 }
5159 void test_visitIndexExpression_getter() { 5159 void test_visitIndexExpression_getter() {
5160 InterfaceType listType2 = _typeProvider.listType; 5160 InterfaceType listType2 = _typeProvider.listType;
5161 SimpleIdentifier identifier = resolvedVariable(listType2, "a"); 5161 SimpleIdentifier identifier = resolvedVariable(listType2, "a");
5162 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2)); 5162 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
5163 node.element = listType2.element.methods[0]; 5163 node.element = listType2.element.methods[0];
5164 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node)); 5164 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node));
5165 _listener.assertNoErrors(); 5165 _listener.assertNoErrors();
5166 } 5166 }
5167 void test_visitIndexExpression_setter() { 5167 void test_visitIndexExpression_setter() {
5168 InterfaceType listType3 = _typeProvider.listType; 5168 InterfaceType listType2 = _typeProvider.listType;
5169 SimpleIdentifier identifier = resolvedVariable(listType3, "a"); 5169 SimpleIdentifier identifier = resolvedVariable(listType2, "a");
5170 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2)); 5170 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
5171 node.element = listType3.element.methods[1]; 5171 node.element = listType2.element.methods[1];
5172 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); 5172 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
5173 JUnitTestCase.assertSame(listType3.typeArguments[0], analyze(node)); 5173 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node));
5174 _listener.assertNoErrors(); 5174 _listener.assertNoErrors();
5175 } 5175 }
5176 void test_visitIndexExpression_typeParameters() { 5176 void test_visitIndexExpression_typeParameters() {
5177 InterfaceType intType8 = _typeProvider.intType; 5177 InterfaceType intType2 = _typeProvider.intType;
5178 InterfaceType listType4 = _typeProvider.listType; 5178 InterfaceType listType2 = _typeProvider.listType;
5179 MethodElement methodElement = getMethod(listType4, "[]"); 5179 MethodElement methodElement = getMethod(listType2, "[]");
5180 SimpleIdentifier identifier = ASTFactory.identifier3("list"); 5180 SimpleIdentifier identifier = ASTFactory.identifier3("list");
5181 InterfaceType listOfIntType = listType4.substitute5(<Type2> [intType8]); 5181 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]);
5182 identifier.staticType = listOfIntType; 5182 identifier.staticType = listOfIntType;
5183 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0)); 5183 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0));
5184 indexExpression2.element = MethodMember.from(methodElement, listOfIntType); 5184 indexExpression2.element = MethodMember.from(methodElement, listOfIntType);
5185 JUnitTestCase.assertSame(intType8, analyze(indexExpression2)); 5185 JUnitTestCase.assertSame(intType2, analyze(indexExpression2));
5186 _listener.assertNoErrors(); 5186 _listener.assertNoErrors();
5187 } 5187 }
5188 void test_visitIndexExpression_typeParameters_inSetterContext() { 5188 void test_visitIndexExpression_typeParameters_inSetterContext() {
5189 InterfaceType intType9 = _typeProvider.intType; 5189 InterfaceType intType2 = _typeProvider.intType;
5190 InterfaceType listType5 = _typeProvider.listType; 5190 InterfaceType listType2 = _typeProvider.listType;
5191 MethodElement methodElement = getMethod(listType5, "[]="); 5191 MethodElement methodElement = getMethod(listType2, "[]=");
5192 SimpleIdentifier identifier = ASTFactory.identifier3("list"); 5192 SimpleIdentifier identifier = ASTFactory.identifier3("list");
5193 InterfaceType listOfIntType = listType5.substitute5(<Type2> [intType9]); 5193 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]);
5194 identifier.staticType = listOfIntType; 5194 identifier.staticType = listOfIntType;
5195 IndexExpression indexExpression3 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0)); 5195 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0));
5196 indexExpression3.element = MethodMember.from(methodElement, listOfIntType); 5196 indexExpression2.element = MethodMember.from(methodElement, listOfIntType);
5197 ASTFactory.assignmentExpression(indexExpression3, TokenType.EQ, ASTFactory.i nteger(0)); 5197 ASTFactory.assignmentExpression(indexExpression2, TokenType.EQ, ASTFactory.i nteger(0));
5198 JUnitTestCase.assertSame(intType9, analyze(indexExpression3)); 5198 JUnitTestCase.assertSame(intType2, analyze(indexExpression2));
5199 _listener.assertNoErrors(); 5199 _listener.assertNoErrors();
5200 } 5200 }
5201 void test_visitInstanceCreationExpression_named() { 5201 void test_visitInstanceCreationExpression_named() {
5202 ClassElementImpl classElement = ElementFactory.classElement2("C", []); 5202 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
5203 String constructorName = "m"; 5203 String constructorName = "m";
5204 ConstructorElementImpl constructor = ElementFactory.constructorElement(const ructorName); 5204 ConstructorElementImpl constructor = ElementFactory.constructorElement(const ructorName);
5205 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 5205 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
5206 constructorType.returnType = classElement.type; 5206 constructorType.returnType = classElement.type;
5207 constructor.type = constructorType; 5207 constructor.type = constructorType;
5208 classElement.constructors = <ConstructorElement> [constructor]; 5208 classElement.constructors = <ConstructorElement> [constructor];
5209 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam e)]); 5209 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam e)]);
5210 node.element = constructor; 5210 node.element = constructor;
5211 JUnitTestCase.assertSame(classElement.type, analyze(node)); 5211 JUnitTestCase.assertSame(classElement.type, analyze(node));
5212 _listener.assertNoErrors(); 5212 _listener.assertNoErrors();
5213 } 5213 }
5214 void test_visitInstanceCreationExpression_typeParameters() { 5214 void test_visitInstanceCreationExpression_typeParameters() {
5215 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); 5215 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]);
5216 ClassElementImpl elementI = ElementFactory.classElement2("I", []); 5216 ClassElementImpl elementI = ElementFactory.classElement2("I", []);
5217 ConstructorElementImpl constructor = ElementFactory.constructorElement(null) ; 5217 ConstructorElementImpl constructor = ElementFactory.constructorElement(null) ;
5218 elementC.constructors = <ConstructorElement> [constructor]; 5218 elementC.constructors = <ConstructorElement> [constructor];
5219 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 5219 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
5220 constructorType.returnType = elementC.type; 5220 constructorType.returnType = elementC.type;
5221 constructor.type = constructorType; 5221 constructor.type = constructorType;
5222 TypeName typeName5 = ASTFactory.typeName(elementC, [ASTFactory.typeName(elem entI, [])]); 5222 TypeName typeName2 = ASTFactory.typeName(elementC, [ASTFactory.typeName(elem entI, [])]);
5223 typeName5.type = elementC.type.substitute5(<Type2> [elementI.type]); 5223 typeName2.type = elementC.type.substitute5(<Type2> [elementI.type]);
5224 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, typeName5, []); 5224 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, typeName2, []);
5225 node.element = constructor; 5225 node.element = constructor;
5226 InterfaceType interfaceType = analyze(node) as InterfaceType; 5226 InterfaceType interfaceType = analyze(node) as InterfaceType;
5227 List<Type2> typeArgs = interfaceType.typeArguments; 5227 List<Type2> typeArgs = interfaceType.typeArguments;
5228 JUnitTestCase.assertEquals(1, typeArgs.length); 5228 JUnitTestCase.assertEquals(1, typeArgs.length);
5229 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); 5229 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]);
5230 _listener.assertNoErrors(); 5230 _listener.assertNoErrors();
5231 } 5231 }
5232 void test_visitInstanceCreationExpression_unnamed() { 5232 void test_visitInstanceCreationExpression_unnamed() {
5233 ClassElementImpl classElement = ElementFactory.classElement2("C", []); 5233 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
5234 ConstructorElementImpl constructor = ElementFactory.constructorElement(null) ; 5234 ConstructorElementImpl constructor = ElementFactory.constructorElement(null) ;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
5307 } 5307 }
5308 void test_visitPrefixedIdentifier_getter() { 5308 void test_visitPrefixedIdentifier_getter() {
5309 Type2 boolType2 = _typeProvider.boolType; 5309 Type2 boolType2 = _typeProvider.boolType;
5310 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType2); 5310 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType2);
5311 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); 5311 PrefixedIdentifier node = ASTFactory.identifier5("a", "b");
5312 node.identifier.element = getter; 5312 node.identifier.element = getter;
5313 JUnitTestCase.assertSame(boolType2, analyze(node)); 5313 JUnitTestCase.assertSame(boolType2, analyze(node));
5314 _listener.assertNoErrors(); 5314 _listener.assertNoErrors();
5315 } 5315 }
5316 void test_visitPrefixedIdentifier_setter() { 5316 void test_visitPrefixedIdentifier_setter() {
5317 Type2 boolType3 = _typeProvider.boolType; 5317 Type2 boolType2 = _typeProvider.boolType;
5318 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals e, boolType3); 5318 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals e, boolType2);
5319 PropertyAccessorElement setter5 = field.setter; 5319 PropertyAccessorElement setter2 = field.setter;
5320 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); 5320 PrefixedIdentifier node = ASTFactory.identifier5("a", "b");
5321 node.identifier.element = setter5; 5321 node.identifier.element = setter2;
5322 JUnitTestCase.assertSame(boolType3, analyze(node)); 5322 JUnitTestCase.assertSame(boolType2, analyze(node));
5323 _listener.assertNoErrors(); 5323 _listener.assertNoErrors();
5324 } 5324 }
5325 void test_visitPrefixedIdentifier_variable() { 5325 void test_visitPrefixedIdentifier_variable() {
5326 VariableElementImpl variable = ElementFactory.localVariableElement2("b"); 5326 VariableElementImpl variable = ElementFactory.localVariableElement2("b");
5327 variable.type = _typeProvider.boolType; 5327 variable.type = _typeProvider.boolType;
5328 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); 5328 PrefixedIdentifier node = ASTFactory.identifier5("a", "b");
5329 node.identifier.element = variable; 5329 node.identifier.element = variable;
5330 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 5330 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5331 _listener.assertNoErrors(); 5331 _listener.assertNoErrors();
5332 } 5332 }
(...skipping 25 matching lines...) Expand all
5358 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); 5358 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node));
5359 _listener.assertNoErrors(); 5359 _listener.assertNoErrors();
5360 } 5360 }
5361 void test_visitPrefixExpression_tilde() { 5361 void test_visitPrefixExpression_tilde() {
5362 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve dInteger(0)); 5362 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve dInteger(0));
5363 node.element = getMethod(_typeProvider.intType, "~"); 5363 node.element = getMethod(_typeProvider.intType, "~");
5364 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); 5364 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
5365 _listener.assertNoErrors(); 5365 _listener.assertNoErrors();
5366 } 5366 }
5367 void test_visitPropertyAccess_getter() { 5367 void test_visitPropertyAccess_getter() {
5368 Type2 boolType4 = _typeProvider.boolType; 5368 Type2 boolType2 = _typeProvider.boolType;
5369 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType4); 5369 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType2);
5370 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b"); 5370 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b");
5371 node.propertyName.element = getter; 5371 node.propertyName.element = getter;
5372 JUnitTestCase.assertSame(boolType4, analyze(node)); 5372 JUnitTestCase.assertSame(boolType2, analyze(node));
5373 _listener.assertNoErrors(); 5373 _listener.assertNoErrors();
5374 } 5374 }
5375 void test_visitPropertyAccess_setter() { 5375 void test_visitPropertyAccess_setter() {
5376 Type2 boolType5 = _typeProvider.boolType; 5376 Type2 boolType2 = _typeProvider.boolType;
5377 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals e, boolType5); 5377 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals e, boolType2);
5378 PropertyAccessorElement setter6 = field.setter; 5378 PropertyAccessorElement setter2 = field.setter;
5379 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b"); 5379 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b");
5380 node.propertyName.element = setter6; 5380 node.propertyName.element = setter2;
5381 JUnitTestCase.assertSame(boolType5, analyze(node)); 5381 JUnitTestCase.assertSame(boolType2, analyze(node));
5382 _listener.assertNoErrors(); 5382 _listener.assertNoErrors();
5383 } 5383 }
5384 void test_visitSimpleStringLiteral() { 5384 void test_visitSimpleStringLiteral() {
5385 Expression node = resolvedString("a"); 5385 Expression node = resolvedString("a");
5386 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); 5386 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
5387 _listener.assertNoErrors(); 5387 _listener.assertNoErrors();
5388 } 5388 }
5389 void test_visitStringInterpolation() { 5389 void test_visitStringInterpolation() {
5390 Expression node = ASTFactory.string([ASTFactory.interpolationString("a", "a" ), ASTFactory.interpolationExpression(resolvedString("b")), ASTFactory.interpola tionString("c", "c")]); 5390 Expression node = ASTFactory.string([ASTFactory.interpolationString("a", "a" ), ASTFactory.interpolationExpression(resolvedString("b")), ASTFactory.interpola tionString("c", "c")]);
5391 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); 5391 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
5486 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes)) { 5486 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes)) {
5487 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]); 5487 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]);
5488 } 5488 }
5489 } 5489 }
5490 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType); 5490 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType);
5491 } 5491 }
5492 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) { 5492 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) {
5493 JUnitTestCase.assertEquals(expectedType.name, actualType.name); 5493 JUnitTestCase.assertEquals(expectedType.name, actualType.name);
5494 JUnitTestCase.assertEquals(expectedType.element, actualType.element); 5494 JUnitTestCase.assertEquals(expectedType.element, actualType.element);
5495 List<Type2> expectedArguments = expectedType.typeArguments; 5495 List<Type2> expectedArguments = expectedType.typeArguments;
5496 int length9 = expectedArguments.length; 5496 int length2 = expectedArguments.length;
5497 List<Type2> actualArguments = actualType.typeArguments; 5497 List<Type2> actualArguments = actualType.typeArguments;
5498 EngineTestCase.assertLength(length9, actualArguments); 5498 EngineTestCase.assertLength(length2, actualArguments);
5499 for (int i = 0; i < length9; i++) { 5499 for (int i = 0; i < length2; i++) {
5500 assertType2(expectedArguments[i], actualArguments[i]); 5500 assertType2(expectedArguments[i], actualArguments[i]);
5501 } 5501 }
5502 } 5502 }
5503 void assertType2(Type2 expectedType, Type2 actualType) { 5503 void assertType2(Type2 expectedType, Type2 actualType) {
5504 if (expectedType is InterfaceTypeImpl) { 5504 if (expectedType is InterfaceTypeImpl) {
5505 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); 5505 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType);
5506 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl)); 5506 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl));
5507 } 5507 }
5508 } 5508 }
5509 /** 5509 /**
(...skipping 30 matching lines...) Expand all
5540 return literal; 5540 return literal;
5541 } 5541 }
5542 /** 5542 /**
5543 * Create a function expression that has an element associated with it, where the element has an 5543 * Create a function expression that has an element associated with it, where the element has an
5544 * incomplete type associated with it (just like the one{@link ElementBuilder# visitFunctionExpression(FunctionExpression)} would have built if we had 5544 * incomplete type associated with it (just like the one{@link ElementBuilder# visitFunctionExpression(FunctionExpression)} would have built if we had
5545 * run it). 5545 * run it).
5546 * @param parameters the parameters to the function 5546 * @param parameters the parameters to the function
5547 * @param body the body of the function 5547 * @param body the body of the function
5548 * @return a resolved function expression 5548 * @return a resolved function expression
5549 */ 5549 */
5550 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters18 , FunctionBody body) { 5550 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) {
5551 for (FormalParameter parameter in parameters18.parameters) { 5551 for (FormalParameter parameter in parameters2.parameters) {
5552 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er); 5552 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er);
5553 element.parameterKind = parameter.kind; 5553 element.parameterKind = parameter.kind;
5554 element.type = _typeProvider.dynamicType; 5554 element.type = _typeProvider.dynamicType;
5555 parameter.identifier.element = element; 5555 parameter.identifier.element = element;
5556 } 5556 }
5557 FunctionExpression node = ASTFactory.functionExpression2(parameters18, body) ; 5557 FunctionExpression node = ASTFactory.functionExpression2(parameters2, body);
5558 FunctionElementImpl element = new FunctionElementImpl.con1(null); 5558 FunctionElementImpl element = new FunctionElementImpl.con1(null);
5559 element.type = new FunctionTypeImpl.con1(element); 5559 element.type = new FunctionTypeImpl.con1(element);
5560 node.element = element; 5560 node.element = element;
5561 return node; 5561 return node;
5562 } 5562 }
5563 /** 5563 /**
5564 * Return an integer literal that has been resolved to the correct type. 5564 * Return an integer literal that has been resolved to the correct type.
5565 * @param value the value of the literal 5565 * @param value the value of the literal
5566 * @return an integer literal that has been resolved to the correct type 5566 * @return an integer literal that has been resolved to the correct type
5567 */ 5567 */
(...skipping 11 matching lines...) Expand all
5579 SimpleStringLiteral string = ASTFactory.string2(value); 5579 SimpleStringLiteral string = ASTFactory.string2(value);
5580 string.staticType = _typeProvider.stringType; 5580 string.staticType = _typeProvider.stringType;
5581 return string; 5581 return string;
5582 } 5582 }
5583 /** 5583 /**
5584 * Return a simple identifier that has been resolved to a variable element wit h the given type. 5584 * Return a simple identifier that has been resolved to a variable element wit h the given type.
5585 * @param type the type of the variable being represented 5585 * @param type the type of the variable being represented
5586 * @param variableName the name of the variable 5586 * @param variableName the name of the variable
5587 * @return a simple identifier that has been resolved to a variable element wi th the given type 5587 * @return a simple identifier that has been resolved to a variable element wi th the given type
5588 */ 5588 */
5589 SimpleIdentifier resolvedVariable(InterfaceType type46, String variableName) { 5589 SimpleIdentifier resolvedVariable(InterfaceType type2, String variableName) {
5590 SimpleIdentifier identifier = ASTFactory.identifier3(variableName); 5590 SimpleIdentifier identifier = ASTFactory.identifier3(variableName);
5591 VariableElementImpl element = ElementFactory.localVariableElement(identifier ); 5591 VariableElementImpl element = ElementFactory.localVariableElement(identifier );
5592 element.type = type46; 5592 element.type = type2;
5593 identifier.element = element; 5593 identifier.element = element;
5594 identifier.staticType = type46; 5594 identifier.staticType = type2;
5595 return identifier; 5595 return identifier;
5596 } 5596 }
5597 /** 5597 /**
5598 * Set the type of the given parameter to the given type. 5598 * Set the type of the given parameter to the given type.
5599 * @param parameter the parameter whose type is to be set 5599 * @param parameter the parameter whose type is to be set
5600 * @param type the new type of the given parameter 5600 * @param type the new type of the given parameter
5601 */ 5601 */
5602 void setType(FormalParameter parameter, Type2 type47) { 5602 void setType(FormalParameter parameter, Type2 type2) {
5603 SimpleIdentifier identifier19 = parameter.identifier; 5603 SimpleIdentifier identifier2 = parameter.identifier;
5604 Element element66 = identifier19.element; 5604 Element element2 = identifier2.element;
5605 if (element66 is! ParameterElement) { 5605 if (element2 is! ParameterElement) {
5606 element66 = new ParameterElementImpl(identifier19); 5606 element2 = new ParameterElementImpl(identifier2);
5607 identifier19.element = element66; 5607 identifier2.element = element2;
5608 } 5608 }
5609 ((element66 as ParameterElementImpl)).type = type47; 5609 ((element2 as ParameterElementImpl)).type = type2;
5610 } 5610 }
5611 static dartSuite() { 5611 static dartSuite() {
5612 _ut.group('StaticTypeAnalyzerTest', () { 5612 _ut.group('StaticTypeAnalyzerTest', () {
5613 _ut.test('test_visitAdjacentStrings', () { 5613 _ut.test('test_visitAdjacentStrings', () {
5614 final __test = new StaticTypeAnalyzerTest(); 5614 final __test = new StaticTypeAnalyzerTest();
5615 runJUnitTest(__test, __test.test_visitAdjacentStrings); 5615 runJUnitTest(__test, __test.test_visitAdjacentStrings);
5616 }); 5616 });
5617 _ut.test('test_visitArgumentDefinitionTest', () { 5617 _ut.test('test_visitArgumentDefinitionTest', () {
5618 final __test = new StaticTypeAnalyzerTest(); 5618 final __test = new StaticTypeAnalyzerTest();
5619 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest); 5619 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
5856 }); 5856 });
5857 _ut.test('test_visitThrowExpression_withoutValue', () { 5857 _ut.test('test_visitThrowExpression_withoutValue', () {
5858 final __test = new StaticTypeAnalyzerTest(); 5858 final __test = new StaticTypeAnalyzerTest();
5859 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); 5859 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue);
5860 }); 5860 });
5861 }); 5861 });
5862 } 5862 }
5863 } 5863 }
5864 class EnclosedScopeTest extends ResolverTestCase { 5864 class EnclosedScopeTest extends ResolverTestCase {
5865 void test_define_duplicate() { 5865 void test_define_duplicate() {
5866 LibraryElement definingLibrary3 = createTestLibrary(); 5866 LibraryElement definingLibrary2 = createTestLibrary();
5867 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 5867 GatheringErrorListener errorListener2 = new GatheringErrorListener();
5868 Scope rootScope = new Scope_16(definingLibrary3, errorListener3); 5868 Scope rootScope = new Scope_16(definingLibrary2, errorListener2);
5869 EnclosedScope scope = new EnclosedScope(rootScope); 5869 EnclosedScope scope = new EnclosedScope(rootScope);
5870 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 5870 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
5871 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 5871 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
5872 scope.define(element1); 5872 scope.define(element1);
5873 scope.define(element2); 5873 scope.define(element2);
5874 errorListener3.assertErrors3([ErrorSeverity.ERROR]); 5874 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
5875 } 5875 }
5876 void test_define_normal() { 5876 void test_define_normal() {
5877 LibraryElement definingLibrary4 = createTestLibrary(); 5877 LibraryElement definingLibrary3 = createTestLibrary();
5878 GatheringErrorListener errorListener4 = new GatheringErrorListener(); 5878 GatheringErrorListener errorListener3 = new GatheringErrorListener();
5879 Scope rootScope = new Scope_17(definingLibrary4, errorListener4); 5879 Scope rootScope = new Scope_17(definingLibrary3, errorListener3);
5880 EnclosedScope outerScope = new EnclosedScope(rootScope); 5880 EnclosedScope outerScope = new EnclosedScope(rootScope);
5881 EnclosedScope innerScope = new EnclosedScope(outerScope); 5881 EnclosedScope innerScope = new EnclosedScope(outerScope);
5882 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 5882 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
5883 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2")); 5883 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
5884 outerScope.define(element1); 5884 outerScope.define(element1);
5885 innerScope.define(element2); 5885 innerScope.define(element2);
5886 errorListener4.assertNoErrors(); 5886 errorListener3.assertNoErrors();
5887 } 5887 }
5888 static dartSuite() { 5888 static dartSuite() {
5889 _ut.group('EnclosedScopeTest', () { 5889 _ut.group('EnclosedScopeTest', () {
5890 _ut.test('test_define_duplicate', () { 5890 _ut.test('test_define_duplicate', () {
5891 final __test = new EnclosedScopeTest(); 5891 final __test = new EnclosedScopeTest();
5892 runJUnitTest(__test, __test.test_define_duplicate); 5892 runJUnitTest(__test, __test.test_define_duplicate);
5893 }); 5893 });
5894 _ut.test('test_define_normal', () { 5894 _ut.test('test_define_normal', () {
5895 final __test = new EnclosedScopeTest(); 5895 final __test = new EnclosedScopeTest();
5896 runJUnitTest(__test, __test.test_define_normal); 5896 runJUnitTest(__test, __test.test_define_normal);
5897 }); 5897 });
5898 }); 5898 });
5899 } 5899 }
5900 } 5900 }
5901 class Scope_16 extends Scope { 5901 class Scope_16 extends Scope {
5902 LibraryElement definingLibrary3; 5902 LibraryElement definingLibrary2;
5903 GatheringErrorListener errorListener3; 5903 GatheringErrorListener errorListener2;
5904 Scope_16(this.definingLibrary3, this.errorListener3) : super(); 5904 Scope_16(this.definingLibrary2, this.errorListener2) : super();
5905 LibraryElement get definingLibrary => definingLibrary3; 5905 LibraryElement get definingLibrary => definingLibrary2;
5906 AnalysisErrorListener get errorListener => errorListener3; 5906 AnalysisErrorListener get errorListener => errorListener2;
5907 Element lookup3(String name, LibraryElement referencingLibrary) => null; 5907 Element lookup3(String name, LibraryElement referencingLibrary) => null;
5908 } 5908 }
5909 class Scope_17 extends Scope { 5909 class Scope_17 extends Scope {
5910 LibraryElement definingLibrary4; 5910 LibraryElement definingLibrary3;
5911 GatheringErrorListener errorListener4; 5911 GatheringErrorListener errorListener3;
5912 Scope_17(this.definingLibrary4, this.errorListener4) : super(); 5912 Scope_17(this.definingLibrary3, this.errorListener3) : super();
5913 LibraryElement get definingLibrary => definingLibrary4; 5913 LibraryElement get definingLibrary => definingLibrary3;
5914 AnalysisErrorListener get errorListener => errorListener4; 5914 AnalysisErrorListener get errorListener => errorListener3;
5915 Element lookup3(String name, LibraryElement referencingLibrary) => null; 5915 Element lookup3(String name, LibraryElement referencingLibrary) => null;
5916 } 5916 }
5917 class LibraryElementBuilderTest extends EngineTestCase { 5917 class LibraryElementBuilderTest extends EngineTestCase {
5918 /** 5918 /**
5919 * The source factory used to create {@link Source sources}. 5919 * The source factory used to create {@link Source sources}.
5920 */ 5920 */
5921 SourceFactory _sourceFactory; 5921 SourceFactory _sourceFactory;
5922 void setUp() { 5922 void setUp() {
5923 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); 5923 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
5924 } 5924 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
5994 _sourceFactory.setContents(source, contents); 5994 _sourceFactory.setContents(source, contents);
5995 return source; 5995 return source;
5996 } 5996 }
5997 /** 5997 /**
5998 * Ensure that there are elements representing all of the types in the given a rray of type names. 5998 * Ensure that there are elements representing all of the types in the given a rray of type names.
5999 * @param unit the compilation unit containing the types 5999 * @param unit the compilation unit containing the types
6000 * @param typeNames the names of the types that should be found 6000 * @param typeNames the names of the types that should be found
6001 */ 6001 */
6002 void assertTypes(CompilationUnitElement unit, List<String> typeNames) { 6002 void assertTypes(CompilationUnitElement unit, List<String> typeNames) {
6003 JUnitTestCase.assertNotNull(unit); 6003 JUnitTestCase.assertNotNull(unit);
6004 List<ClassElement> types3 = unit.types; 6004 List<ClassElement> types2 = unit.types;
6005 EngineTestCase.assertLength(typeNames.length, types3); 6005 EngineTestCase.assertLength(typeNames.length, types2);
6006 for (ClassElement type in types3) { 6006 for (ClassElement type in types2) {
6007 JUnitTestCase.assertNotNull(type); 6007 JUnitTestCase.assertNotNull(type);
6008 String actualTypeName = type.name; 6008 String actualTypeName = type.name;
6009 bool wasExpected = false; 6009 bool wasExpected = false;
6010 for (String expectedTypeName in typeNames) { 6010 for (String expectedTypeName in typeNames) {
6011 if (expectedTypeName == actualTypeName) { 6011 if (expectedTypeName == actualTypeName) {
6012 wasExpected = true; 6012 wasExpected = true;
6013 } 6013 }
6014 } 6014 }
6015 if (!wasExpected) { 6015 if (!wasExpected) {
6016 JUnitTestCase.fail("Found unexpected type ${actualTypeName}"); 6016 JUnitTestCase.fail("Found unexpected type ${actualTypeName}");
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
6392 // LibraryScopeTest.dartSuite(); 6392 // LibraryScopeTest.dartSuite();
6393 // ScopeTest.dartSuite(); 6393 // ScopeTest.dartSuite();
6394 // CompileTimeErrorCodeTest.dartSuite(); 6394 // CompileTimeErrorCodeTest.dartSuite();
6395 // ErrorResolverTest.dartSuite(); 6395 // ErrorResolverTest.dartSuite();
6396 // NonErrorResolverTest.dartSuite(); 6396 // NonErrorResolverTest.dartSuite();
6397 // SimpleResolverTest.dartSuite(); 6397 // SimpleResolverTest.dartSuite();
6398 // StaticTypeWarningCodeTest.dartSuite(); 6398 // StaticTypeWarningCodeTest.dartSuite();
6399 // StaticWarningCodeTest.dartSuite(); 6399 // StaticWarningCodeTest.dartSuite();
6400 // TypePropagationTest.dartSuite(); 6400 // TypePropagationTest.dartSuite();
6401 } 6401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698