| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.non_error_resolver_test; | 5 library engine.non_error_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/source_io.dart'; | 7 import 'package:analyzer/src/generated/source_io.dart'; |
| 8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 11 import 'package:analyzer/src/generated/element.dart'; | 11 import 'package:analyzer/src/generated/element.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:unittest/unittest.dart' as _ut; | 13 import 'package:unittest/unittest.dart' as _ut; |
| 14 import 'resolver_test.dart'; | 14 import 'resolver_test.dart'; |
| 15 import 'test_support.dart'; | 15 import 'test_support.dart'; |
| 16 import '../reflective_tests.dart'; | 16 import '../reflective_tests.dart'; |
| 17 | 17 |
| 18 | 18 |
| 19 class NonErrorResolverTest extends ResolverTestCase { | 19 class NonErrorResolverTest extends ResolverTestCase { |
| 20 void fail_undefinedEnumConstant() { | 20 void fail_undefinedEnumConstant() { |
| 21 Source source = addSource(EngineTestCase.createSource(["enum E { ONE }", "E
e() {", " return E.ONE;", "}"])); | 21 Source source = addSource(r''' |
| 22 enum E { ONE } |
| 23 E e() { |
| 24 return E.ONE; |
| 25 }'''); |
| 22 resolve(source); | 26 resolve(source); |
| 23 assertNoErrors(source); | 27 assertNoErrors(source); |
| 24 verify([source]); | 28 verify([source]); |
| 25 } | 29 } |
| 26 | 30 |
| 27 void test_ambiguousExport() { | 31 void test_ambiguousExport() { |
| 28 Source source = addSource(EngineTestCase.createSource([ | 32 Source source = addSource(r''' |
| 29 "library L;", | 33 library L; |
| 30 "export 'lib1.dart';", | 34 export 'lib1.dart'; |
| 31 "export 'lib2.dart';"])); | 35 export 'lib2.dart';'''); |
| 32 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;", "
class M {}"])); | 36 addNamedSource("/lib1.dart", r''' |
| 33 addNamedSource("/lib2.dart", EngineTestCase.createSource(["library lib2;", "
class N {}"])); | 37 library lib1; |
| 38 class M {}'''); |
| 39 addNamedSource("/lib2.dart", r''' |
| 40 library lib2; |
| 41 class N {}'''); |
| 34 resolve(source); | 42 resolve(source); |
| 35 assertNoErrors(source); | 43 assertNoErrors(source); |
| 36 verify([source]); | 44 verify([source]); |
| 37 } | 45 } |
| 38 | 46 |
| 39 void test_ambiguousExport_combinators_hide() { | 47 void test_ambiguousExport_combinators_hide() { |
| 40 Source source = addSource(EngineTestCase.createSource([ | 48 Source source = addSource(r''' |
| 41 "library L;", | 49 library L; |
| 42 "export 'lib1.dart';", | 50 export 'lib1.dart'; |
| 43 "export 'lib2.dart' hide B;"])); | 51 export 'lib2.dart' hide B;'''); |
| 44 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library L1;", "cl
ass A {}", "class B {}"])); | 52 addNamedSource("/lib1.dart", r''' |
| 45 addNamedSource("/lib2.dart", EngineTestCase.createSource(["library L2;", "cl
ass B {}", "class C {}"])); | 53 library L1; |
| 54 class A {} |
| 55 class B {}'''); |
| 56 addNamedSource("/lib2.dart", r''' |
| 57 library L2; |
| 58 class B {} |
| 59 class C {}'''); |
| 46 resolve(source); | 60 resolve(source); |
| 47 assertNoErrors(source); | 61 assertNoErrors(source); |
| 48 verify([source]); | 62 verify([source]); |
| 49 } | 63 } |
| 50 | 64 |
| 51 void test_ambiguousExport_combinators_show() { | 65 void test_ambiguousExport_combinators_show() { |
| 52 Source source = addSource(EngineTestCase.createSource([ | 66 Source source = addSource(r''' |
| 53 "library L;", | 67 library L; |
| 54 "export 'lib1.dart';", | 68 export 'lib1.dart'; |
| 55 "export 'lib2.dart' show C;"])); | 69 export 'lib2.dart' show C;'''); |
| 56 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library L1;", "cl
ass A {}", "class B {}"])); | 70 addNamedSource("/lib1.dart", r''' |
| 57 addNamedSource("/lib2.dart", EngineTestCase.createSource(["library L2;", "cl
ass B {}", "class C {}"])); | 71 library L1; |
| 72 class A {} |
| 73 class B {}'''); |
| 74 addNamedSource("/lib2.dart", r''' |
| 75 library L2; |
| 76 class B {} |
| 77 class C {}'''); |
| 58 resolve(source); | 78 resolve(source); |
| 59 assertNoErrors(source); | 79 assertNoErrors(source); |
| 60 verify([source]); | 80 verify([source]); |
| 61 } | 81 } |
| 62 | 82 |
| 63 void test_ambiguousExport_sameDeclaration() { | 83 void test_ambiguousExport_sameDeclaration() { |
| 64 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib.dart';", "export 'lib.dart';"])); | 84 Source source = addSource(r''' |
| 65 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "cl
ass N {}"])); | 85 library L; |
| 86 export 'lib.dart'; |
| 87 export 'lib.dart';'''); |
| 88 addNamedSource("/lib.dart", r''' |
| 89 library lib; |
| 90 class N {}'''); |
| 66 resolve(source); | 91 resolve(source); |
| 67 assertNoErrors(source); | 92 assertNoErrors(source); |
| 68 verify([source]); | 93 verify([source]); |
| 69 } | 94 } |
| 70 | 95 |
| 71 void test_ambiguousImport_hideCombinator() { | 96 void test_ambiguousImport_hideCombinator() { |
| 72 Source source = addSource(EngineTestCase.createSource([ | 97 Source source = addSource(r''' |
| 73 "import 'lib1.dart';", | 98 import 'lib1.dart'; |
| 74 "import 'lib2.dart';", | 99 import 'lib2.dart'; |
| 75 "import 'lib3.dart' hide N;", | 100 import 'lib3.dart' hide N; |
| 76 "main() {", | 101 main() { |
| 77 " new N1();", | 102 new N1(); |
| 78 " new N2();", | 103 new N2(); |
| 79 " new N3();", | 104 new N3(); |
| 80 "}"])); | 105 }'''); |
| 81 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;", "
class N {}", "class N1 {}"])); | 106 addNamedSource("/lib1.dart", r''' |
| 82 addNamedSource("/lib2.dart", EngineTestCase.createSource(["library lib2;", "
class N {}", "class N2 {}"])); | 107 library lib1; |
| 83 addNamedSource("/lib3.dart", EngineTestCase.createSource(["library lib3;", "
class N {}", "class N3 {}"])); | 108 class N {} |
| 109 class N1 {}'''); |
| 110 addNamedSource("/lib2.dart", r''' |
| 111 library lib2; |
| 112 class N {} |
| 113 class N2 {}'''); |
| 114 addNamedSource("/lib3.dart", r''' |
| 115 library lib3; |
| 116 class N {} |
| 117 class N3 {}'''); |
| 84 resolve(source); | 118 resolve(source); |
| 85 assertNoErrors(source); | 119 assertNoErrors(source); |
| 86 } | 120 } |
| 87 | 121 |
| 88 void test_ambiguousImport_showCombinator() { | 122 void test_ambiguousImport_showCombinator() { |
| 89 Source source = addSource(EngineTestCase.createSource([ | 123 Source source = addSource(r''' |
| 90 "import 'lib1.dart';", | 124 import 'lib1.dart'; |
| 91 "import 'lib2.dart' show N, N2;", | 125 import 'lib2.dart' show N, N2; |
| 92 "main() {", | 126 main() { |
| 93 " new N1();", | 127 new N1(); |
| 94 " new N2();", | 128 new N2(); |
| 95 "}"])); | 129 }'''); |
| 96 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;", "
class N {}", "class N1 {}"])); | 130 addNamedSource("/lib1.dart", r''' |
| 97 addNamedSource("/lib2.dart", EngineTestCase.createSource(["library lib2;", "
class N {}", "class N2 {}"])); | 131 library lib1; |
| 132 class N {} |
| 133 class N1 {}'''); |
| 134 addNamedSource("/lib2.dart", r''' |
| 135 library lib2; |
| 136 class N {} |
| 137 class N2 {}'''); |
| 98 resolve(source); | 138 resolve(source); |
| 99 assertNoErrors(source); | 139 assertNoErrors(source); |
| 100 } | 140 } |
| 101 | 141 |
| 102 void test_argumentTypeNotAssignable_classWithCall_Function() { | 142 void test_argumentTypeNotAssignable_classWithCall_Function() { |
| 103 Source source = addSource(EngineTestCase.createSource([ | 143 Source source = addSource(r''' |
| 104 " caller(Function callee) {", | 144 caller(Function callee) { |
| 105 " callee();", | 145 callee(); |
| 106 " }", | 146 } |
| 107 "", | 147 |
| 108 " class CallMeBack {", | 148 class CallMeBack { |
| 109 " call() => 0;", | 149 call() => 0; |
| 110 " }", | 150 } |
| 111 "", | 151 |
| 112 " main() {", | 152 main() { |
| 113 " caller(new CallMeBack());", | 153 caller(new CallMeBack()); |
| 114 " }"])); | 154 }'''); |
| 115 resolve(source); | 155 resolve(source); |
| 116 assertNoErrors(source); | 156 assertNoErrors(source); |
| 117 verify([source]); | 157 verify([source]); |
| 118 } | 158 } |
| 119 | 159 |
| 120 void test_argumentTypeNotAssignable_fieldFormalParameterElement_member() { | 160 void test_argumentTypeNotAssignable_fieldFormalParameterElement_member() { |
| 121 Source source = addSource(EngineTestCase.createSource([ | 161 Source source = addSource(r''' |
| 122 "class ObjectSink<T> {", | 162 class ObjectSink<T> { |
| 123 " void sink(T object) {", | 163 void sink(T object) { |
| 124 " new TimestampedObject<T>(object);", | 164 new TimestampedObject<T>(object); |
| 125 " }", | 165 } |
| 126 "}", | 166 } |
| 127 "class TimestampedObject<E> {", | 167 class TimestampedObject<E> { |
| 128 " E object2;", | 168 E object2; |
| 129 " TimestampedObject(this.object2);", | 169 TimestampedObject(this.object2); |
| 130 "}"])); | 170 }'''); |
| 131 resolve(source); | 171 resolve(source); |
| 132 assertNoErrors(source); | 172 assertNoErrors(source); |
| 133 verify([source]); | 173 verify([source]); |
| 134 } | 174 } |
| 135 | 175 |
| 136 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { | 176 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { |
| 137 Source source = addSource(EngineTestCase.createSource([ | 177 Source source = addSource(r''' |
| 138 "class A<K> {", | 178 class A<K> { |
| 139 " m(f(K k), K v) {", | 179 m(f(K k), K v) { |
| 140 " f(v);", | 180 f(v); |
| 141 " }", | 181 } |
| 142 "}"])); | 182 }'''); |
| 143 resolve(source); | 183 resolve(source); |
| 144 assertNoErrors(source); | 184 assertNoErrors(source); |
| 145 verify([source]); | 185 verify([source]); |
| 146 } | 186 } |
| 147 | 187 |
| 148 void test_argumentTypeNotAssignable_invocation_typedef_generic() { | 188 void test_argumentTypeNotAssignable_invocation_typedef_generic() { |
| 149 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a(1);", "}"])); | 189 Source source = addSource(r''' |
| 190 typedef A<T>(T p); |
| 191 f(A<int> a) { |
| 192 a(1); |
| 193 }'''); |
| 150 resolve(source); | 194 resolve(source); |
| 151 assertNoErrors(source); | 195 assertNoErrors(source); |
| 152 verify([source]); | 196 verify([source]); |
| 153 } | 197 } |
| 154 | 198 |
| 155 void test_argumentTypeNotAssignable_Object_Function() { | 199 void test_argumentTypeNotAssignable_Object_Function() { |
| 156 Source source = addSource(EngineTestCase.createSource([ | 200 Source source = addSource(r''' |
| 157 "main() {", | 201 main() { |
| 158 " process(() {});", | 202 process(() {}); |
| 159 "}", | 203 } |
| 160 "process(Object x) {}"])); | 204 process(Object x) {}'''); |
| 161 resolve(source); | 205 resolve(source); |
| 162 assertNoErrors(source); | 206 assertNoErrors(source); |
| 163 verify([source]); | 207 verify([source]); |
| 164 } | 208 } |
| 165 | 209 |
| 166 void test_argumentTypeNotAssignable_typedef_local() { | 210 void test_argumentTypeNotAssignable_typedef_local() { |
| 167 Source source = addSource(EngineTestCase.createSource([ | 211 Source source = addSource(r''' |
| 168 "typedef A(int p1, String p2);", | 212 typedef A(int p1, String p2); |
| 169 "A getA() => null;", | 213 A getA() => null; |
| 170 "f() {", | 214 f() { |
| 171 " A a = getA();", | 215 A a = getA(); |
| 172 " a(1, '2');", | 216 a(1, '2'); |
| 173 "}"])); | 217 }'''); |
| 174 resolve(source); | 218 resolve(source); |
| 175 assertNoErrors(source); | 219 assertNoErrors(source); |
| 176 verify([source]); | 220 verify([source]); |
| 177 } | 221 } |
| 178 | 222 |
| 179 void test_argumentTypeNotAssignable_typedef_parameter() { | 223 void test_argumentTypeNotAssignable_typedef_parameter() { |
| 180 Source source = addSource(EngineTestCase.createSource([ | 224 Source source = addSource(r''' |
| 181 "typedef A(int p1, String p2);", | 225 typedef A(int p1, String p2); |
| 182 "f(A a) {", | 226 f(A a) { |
| 183 " a(1, '2');", | 227 a(1, '2'); |
| 184 "}"])); | 228 }'''); |
| 185 resolve(source); | 229 resolve(source); |
| 186 assertNoErrors(source); | 230 assertNoErrors(source); |
| 187 verify([source]); | 231 verify([source]); |
| 188 } | 232 } |
| 189 | 233 |
| 190 void test_assignmentToFinal_prefixNegate() { | 234 void test_assignmentToFinal_prefixNegate() { |
| 191 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " -x;", "}"])); | 235 Source source = addSource(r''' |
| 236 f() { |
| 237 final x = 0; |
| 238 -x; |
| 239 }'''); |
| 192 resolve(source); | 240 resolve(source); |
| 193 assertNoErrors(source); | 241 assertNoErrors(source); |
| 194 verify([source]); | 242 verify([source]); |
| 195 } | 243 } |
| 196 | 244 |
| 197 void test_assignmentToFinalNoSetter_prefixedIdentifier() { | 245 void test_assignmentToFinalNoSetter_prefixedIdentifier() { |
| 198 Source source = addSource(EngineTestCase.createSource([ | 246 Source source = addSource(r''' |
| 199 "class A {", | 247 class A { |
| 200 " int get x => 0;", | 248 int get x => 0; |
| 201 " set x(v) {}", | 249 set x(v) {} |
| 202 "}", | 250 } |
| 203 "main() {", | 251 main() { |
| 204 " A a = new A();", | 252 A a = new A(); |
| 205 " a.x = 0;", | 253 a.x = 0; |
| 206 "}"])); | 254 }'''); |
| 207 resolve(source); | 255 resolve(source); |
| 208 assertNoErrors(source); | 256 assertNoErrors(source); |
| 209 verify([source]); | 257 verify([source]); |
| 210 } | 258 } |
| 211 | 259 |
| 212 void test_assignmentToFinalNoSetter_propertyAccess() { | 260 void test_assignmentToFinalNoSetter_propertyAccess() { |
| 213 Source source = addSource(EngineTestCase.createSource([ | 261 Source source = addSource(r''' |
| 214 "class A {", | 262 class A { |
| 215 " int get x => 0;", | 263 int get x => 0; |
| 216 " set x(v) {}", | 264 set x(v) {} |
| 217 "}", | 265 } |
| 218 "class B {", | 266 class B { |
| 219 " static A a;", | 267 static A a; |
| 220 "}", | 268 } |
| 221 "main() {", | 269 main() { |
| 222 " B.a.x = 0;", | 270 B.a.x = 0; |
| 223 "}"])); | 271 }'''); |
| 224 resolve(source); | 272 resolve(source); |
| 225 assertNoErrors(source); | 273 assertNoErrors(source); |
| 226 verify([source]); | 274 verify([source]); |
| 227 } | 275 } |
| 228 | 276 |
| 229 void test_assignmentToFinals_importWithPrefix() { | 277 void test_assignmentToFinals_importWithPrefix() { |
| 230 Source source = addSource(EngineTestCase.createSource([ | 278 Source source = addSource(r''' |
| 231 "library lib;", | 279 library lib; |
| 232 "import 'lib1.dart' as foo;", | 280 import 'lib1.dart' as foo; |
| 233 "main() {", | 281 main() { |
| 234 " foo.x = true;", | 282 foo.x = true; |
| 235 "}"])); | 283 }'''); |
| 236 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;", "
bool x = false;"])); | 284 addNamedSource("/lib1.dart", r''' |
| 237 resolve(source); | 285 library lib1; |
| 238 assertNoErrors(source); | 286 bool x = false;'''); |
| 239 verify([source]); | 287 resolve(source); |
| 288 assertNoErrors(source); |
| 289 verify([source]); |
| 240 } | 290 } |
| 241 | 291 |
| 242 void test_asyncForInWrongContext_async() { | 292 void test_asyncForInWrongContext_async() { |
| 243 resetWithAsync(); | 293 resetWithAsync(); |
| 244 Source source = addSource(EngineTestCase.createSource([ | 294 Source source = addSource(r''' |
| 245 "f(list) async {", | 295 f(list) async { |
| 246 " await for (var e in list) {", | 296 await for (var e in list) { |
| 247 " }", | 297 } |
| 248 "}"])); | 298 }'''); |
| 249 resolve(source); | 299 resolve(source); |
| 250 assertNoErrors(source); | 300 assertNoErrors(source); |
| 251 verify([source]); | 301 verify([source]); |
| 252 } | 302 } |
| 253 | 303 |
| 254 void test_asyncForInWrongContext_asyncStar() { | 304 void test_asyncForInWrongContext_asyncStar() { |
| 255 resetWithAsync(); | 305 resetWithAsync(); |
| 256 Source source = addSource(EngineTestCase.createSource([ | 306 Source source = addSource(r''' |
| 257 "f(list) async* {", | 307 f(list) async* { |
| 258 " await for (var e in list) {", | 308 await for (var e in list) { |
| 259 " }", | 309 } |
| 260 "}"])); | 310 }'''); |
| 261 resolve(source); | 311 resolve(source); |
| 262 assertNoErrors(source); | 312 assertNoErrors(source); |
| 263 verify([source]); | 313 verify([source]); |
| 264 } | 314 } |
| 265 | 315 |
| 266 void test_awaitInWrongContext_async() { | 316 void test_awaitInWrongContext_async() { |
| 267 resetWithAsync(); | 317 resetWithAsync(); |
| 268 Source source = addSource(EngineTestCase.createSource(["f(x, y) async {", "
return await x + await y;", "}"])); | 318 Source source = addSource(r''' |
| 319 f(x, y) async { |
| 320 return await x + await y; |
| 321 }'''); |
| 269 resolve(source); | 322 resolve(source); |
| 270 assertNoErrors(source); | 323 assertNoErrors(source); |
| 271 verify([source]); | 324 verify([source]); |
| 272 } | 325 } |
| 273 | 326 |
| 274 void test_awaitInWrongContext_asyncStar() { | 327 void test_awaitInWrongContext_asyncStar() { |
| 275 resetWithAsync(); | 328 resetWithAsync(); |
| 276 Source source = addSource(EngineTestCase.createSource(["f(x, y) async* {", "
yield await x + await y;", "}"])); | 329 Source source = addSource(r''' |
| 330 f(x, y) async* { |
| 331 yield await x + await y; |
| 332 }'''); |
| 277 resolve(source); | 333 resolve(source); |
| 278 assertNoErrors(source); | 334 assertNoErrors(source); |
| 279 verify([source]); | 335 verify([source]); |
| 280 } | 336 } |
| 281 | 337 |
| 282 void test_breakWithoutLabelInSwitch() { | 338 void test_breakWithoutLabelInSwitch() { |
| 283 Source source = addSource(EngineTestCase.createSource([ | 339 Source source = addSource(r''' |
| 284 "class A {", | 340 class A { |
| 285 " void m(int i) {", | 341 void m(int i) { |
| 286 " switch (i) {", | 342 switch (i) { |
| 287 " case 0:", | 343 case 0: |
| 288 " break;", | 344 break; |
| 289 " }", | 345 } |
| 290 " }", | 346 } |
| 291 "}"])); | 347 }'''); |
| 292 resolve(source); | 348 resolve(source); |
| 293 assertNoErrors(source); | 349 assertNoErrors(source); |
| 294 verify([source]); | 350 verify([source]); |
| 295 } | 351 } |
| 296 | 352 |
| 297 void test_builtInIdentifierAsType_dynamic() { | 353 void test_builtInIdentifierAsType_dynamic() { |
| 298 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x
;", "}"])); | 354 Source source = addSource(r''' |
| 355 f() { |
| 356 dynamic x; |
| 357 }'''); |
| 299 resolve(source); | 358 resolve(source); |
| 300 assertNoErrors(source); | 359 assertNoErrors(source); |
| 301 verify([source]); | 360 verify([source]); |
| 302 } | 361 } |
| 303 | 362 |
| 304 void test_caseBlockNotTerminated() { | 363 void test_caseBlockNotTerminated() { |
| 305 Source source = addSource(EngineTestCase.createSource([ | 364 Source source = addSource(r''' |
| 306 "f(int p) {", | 365 f(int p) { |
| 307 " for (int i = 0; i < 10; i++) {", | 366 for (int i = 0; i < 10; i++) { |
| 308 " switch (p) {", | 367 switch (p) { |
| 309 " case 0:", | 368 case 0: |
| 310 " break;", | 369 break; |
| 311 " case 1:", | 370 case 1: |
| 312 " continue;", | 371 continue; |
| 313 " case 2:", | 372 case 2: |
| 314 " return;", | 373 return; |
| 315 " case 3:", | 374 case 3: |
| 316 " throw new Object();", | 375 throw new Object(); |
| 317 " case 4:", | 376 case 4: |
| 318 " case 5:", | 377 case 5: |
| 319 " return;", | 378 return; |
| 320 " case 6:", | 379 case 6: |
| 321 " default:", | 380 default: |
| 322 " return;", | 381 return; |
| 323 " }", | 382 } |
| 324 " }", | 383 } |
| 325 "}"])); | 384 }'''); |
| 326 resolve(source); | 385 resolve(source); |
| 327 assertNoErrors(source); | 386 assertNoErrors(source); |
| 328 verify([source]); | 387 verify([source]); |
| 329 } | 388 } |
| 330 | 389 |
| 331 void test_caseBlockNotTerminated_lastCase() { | 390 void test_caseBlockNotTerminated_lastCase() { |
| 332 Source source = addSource(EngineTestCase.createSource([ | 391 Source source = addSource(r''' |
| 333 "f(int p) {", | 392 f(int p) { |
| 334 " switch (p) {", | 393 switch (p) { |
| 335 " case 0:", | 394 case 0: |
| 336 " p = p + 1;", | 395 p = p + 1; |
| 337 " }", | 396 } |
| 338 "}"])); | 397 }'''); |
| 339 resolve(source); | 398 resolve(source); |
| 340 assertNoErrors(source); | 399 assertNoErrors(source); |
| 341 verify([source]); | 400 verify([source]); |
| 342 } | 401 } |
| 343 | 402 |
| 344 void test_caseExpressionTypeImplementsEquals() { | 403 void test_caseExpressionTypeImplementsEquals() { |
| 345 Source source = addSource(EngineTestCase.createSource([ | 404 Source source = addSource(r''' |
| 346 "print(p) {}", | 405 print(p) {} |
| 347 "", | 406 |
| 348 "abstract class B {", | 407 abstract class B { |
| 349 " final id;", | 408 final id; |
| 350 " const B(this.id);", | 409 const B(this.id); |
| 351 " String toString() => 'C(\$id)';", | 410 String toString() => 'C($id)'; |
| 352 " /** Equality is identity equality, the id isn't used. */", | 411 /** Equality is identity equality, the id isn't used. */ |
| 353 " bool operator==(Object other);", | 412 bool operator==(Object other); |
| 354 " }", | 413 } |
| 355 "", | 414 |
| 356 "class C extends B {", | 415 class C extends B { |
| 357 " const C(id) : super(id);", | 416 const C(id) : super(id); |
| 358 "}", | 417 } |
| 359 "", | 418 |
| 360 "void doSwitch(c) {", | 419 void doSwitch(c) { |
| 361 " switch (c) {", | 420 switch (c) { |
| 362 " case const C(0): print('Switch: 0'); break;", | 421 case const C(0): print('Switch: 0'); break; |
| 363 " case const C(1): print('Switch: 1'); break;", | 422 case const C(1): print('Switch: 1'); break; |
| 364 " }", | 423 } |
| 365 "}"])); | 424 }'''); |
| 366 resolve(source); | 425 resolve(source); |
| 367 assertNoErrors(source); | 426 assertNoErrors(source); |
| 368 verify([source]); | 427 verify([source]); |
| 369 } | 428 } |
| 370 | 429 |
| 371 void test_caseExpressionTypeImplementsEquals_int() { | 430 void test_caseExpressionTypeImplementsEquals_int() { |
| 372 Source source = addSource(EngineTestCase.createSource([ | 431 Source source = addSource(r''' |
| 373 "f(int i) {", | 432 f(int i) { |
| 374 " switch(i) {", | 433 switch(i) { |
| 375 " case(1) : return 1;", | 434 case(1) : return 1; |
| 376 " default: return 0;", | 435 default: return 0; |
| 377 " }", | 436 } |
| 378 "}"])); | 437 }'''); |
| 379 resolve(source); | 438 resolve(source); |
| 380 assertNoErrors(source); | 439 assertNoErrors(source); |
| 381 verify([source]); | 440 verify([source]); |
| 382 } | 441 } |
| 383 | 442 |
| 384 void test_caseExpressionTypeImplementsEquals_Object() { | 443 void test_caseExpressionTypeImplementsEquals_Object() { |
| 385 Source source = addSource(EngineTestCase.createSource([ | 444 Source source = addSource(r''' |
| 386 "class IntWrapper {", | 445 class IntWrapper { |
| 387 " final int value;", | 446 final int value; |
| 388 " const IntWrapper(this.value);", | 447 const IntWrapper(this.value); |
| 389 "}", | 448 } |
| 390 "", | 449 |
| 391 "f(IntWrapper intWrapper) {", | 450 f(IntWrapper intWrapper) { |
| 392 " switch(intWrapper) {", | 451 switch(intWrapper) { |
| 393 " case(const IntWrapper(1)) : return 1;", | 452 case(const IntWrapper(1)) : return 1; |
| 394 " default: return 0;", | 453 default: return 0; |
| 395 " }", | 454 } |
| 396 "}"])); | 455 }'''); |
| 397 resolve(source); | 456 resolve(source); |
| 398 assertNoErrors(source); | 457 assertNoErrors(source); |
| 399 verify([source]); | 458 verify([source]); |
| 400 } | 459 } |
| 401 | 460 |
| 402 void test_caseExpressionTypeImplementsEquals_String() { | 461 void test_caseExpressionTypeImplementsEquals_String() { |
| 403 Source source = addSource(EngineTestCase.createSource([ | 462 Source source = addSource(r''' |
| 404 "f(String s) {", | 463 f(String s) { |
| 405 " switch(s) {", | 464 switch(s) { |
| 406 " case('1') : return 1;", | 465 case('1') : return 1; |
| 407 " default: return 0;", | 466 default: return 0; |
| 408 " }", | 467 } |
| 409 "}"])); | 468 }'''); |
| 410 resolve(source); | 469 resolve(source); |
| 411 assertNoErrors(source); | 470 assertNoErrors(source); |
| 412 verify([source]); | 471 verify([source]); |
| 413 } | 472 } |
| 414 | 473 |
| 415 void test_commentReference_beforeConstructor() { | 474 void test_commentReference_beforeConstructor() { |
| 416 String code = EngineTestCase.createSource(["abstract class A {", " /// [p]"
, " A(int p) {}", "}"]); | 475 String code = r''' |
| 476 abstract class A { |
| 477 /// [p] |
| 478 A(int p) {} |
| 479 }'''; |
| 417 Source source = addSource(code); | 480 Source source = addSource(code); |
| 418 resolve(source); | 481 resolve(source); |
| 419 assertNoErrors(source); | 482 assertNoErrors(source); |
| 420 verify([source]); | 483 verify([source]); |
| 421 CompilationUnit unit = analysisContext.parseCompilationUnit(source); | 484 CompilationUnit unit = analysisContext.parseCompilationUnit(source); |
| 422 { | 485 { |
| 423 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p]", (node) =>
node is SimpleIdentifier); | 486 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p]", (node) =>
node is SimpleIdentifier); |
| 424 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, Paramete
rElement, ref.staticElement); | 487 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, Paramete
rElement, ref.staticElement); |
| 425 } | 488 } |
| 426 } | 489 } |
| 427 | 490 |
| 428 void test_commentReference_beforeFunction_blockBody() { | 491 void test_commentReference_beforeFunction_blockBody() { |
| 429 String code = EngineTestCase.createSource(["/// [p]", "foo(int p) {", "}"]); | 492 String code = r''' |
| 493 /// [p] |
| 494 foo(int p) { |
| 495 }'''; |
| 430 Source source = addSource(code); | 496 Source source = addSource(code); |
| 431 resolve(source); | 497 resolve(source); |
| 432 assertNoErrors(source); | 498 assertNoErrors(source); |
| 433 verify([source]); | 499 verify([source]); |
| 434 CompilationUnit unit = analysisContext.parseCompilationUnit(source); | 500 CompilationUnit unit = analysisContext.parseCompilationUnit(source); |
| 435 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p]", (node) => n
ode is SimpleIdentifier); | 501 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p]", (node) => n
ode is SimpleIdentifier); |
| 436 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, ParameterE
lement, ref.staticElement); | 502 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, ParameterE
lement, ref.staticElement); |
| 437 } | 503 } |
| 438 | 504 |
| 439 void test_commentReference_beforeFunction_expressionBody() { | 505 void test_commentReference_beforeFunction_expressionBody() { |
| 440 String code = EngineTestCase.createSource(["/// [p]", "foo(int p) => null;"]
); | 506 String code = r''' |
| 507 /// [p] |
| 508 foo(int p) => null;'''; |
| 441 Source source = addSource(code); | 509 Source source = addSource(code); |
| 442 resolve(source); | 510 resolve(source); |
| 443 assertNoErrors(source); | 511 assertNoErrors(source); |
| 444 verify([source]); | 512 verify([source]); |
| 445 CompilationUnit unit = analysisContext.parseCompilationUnit(source); | 513 CompilationUnit unit = analysisContext.parseCompilationUnit(source); |
| 446 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p]", (node) => n
ode is SimpleIdentifier); | 514 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p]", (node) => n
ode is SimpleIdentifier); |
| 447 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, ParameterE
lement, ref.staticElement); | 515 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, ParameterE
lement, ref.staticElement); |
| 448 } | 516 } |
| 449 | 517 |
| 450 void test_commentReference_beforeMethod() { | 518 void test_commentReference_beforeMethod() { |
| 451 String code = EngineTestCase.createSource([ | 519 String code = r''' |
| 452 "abstract class A {", | 520 abstract class A { |
| 453 " /// [p1]", | 521 /// [p1] |
| 454 " ma(int p1) {}", | 522 ma(int p1) {} |
| 455 " /// [p2]", | 523 /// [p2] |
| 456 " mb(int p2);", | 524 mb(int p2); |
| 457 "}"]); | 525 }'''; |
| 458 Source source = addSource(code); | 526 Source source = addSource(code); |
| 459 resolve(source); | 527 resolve(source); |
| 460 assertNoErrors(source); | 528 assertNoErrors(source); |
| 461 verify([source]); | 529 verify([source]); |
| 462 CompilationUnit unit = analysisContext.parseCompilationUnit(source); | 530 CompilationUnit unit = analysisContext.parseCompilationUnit(source); |
| 463 { | 531 { |
| 464 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p1]", (node) =
> node is SimpleIdentifier); | 532 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p1]", (node) =
> node is SimpleIdentifier); |
| 465 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, Paramete
rElement, ref.staticElement); | 533 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, Paramete
rElement, ref.staticElement); |
| 466 } | 534 } |
| 467 { | 535 { |
| 468 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p2]", (node) =
> node is SimpleIdentifier); | 536 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "p2]", (node) =
> node is SimpleIdentifier); |
| 469 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, Paramete
rElement, ref.staticElement); | 537 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, Paramete
rElement, ref.staticElement); |
| 470 } | 538 } |
| 471 } | 539 } |
| 472 | 540 |
| 473 void test_commentReference_class() { | 541 void test_commentReference_class() { |
| 474 String code = EngineTestCase.createSource(["/// [foo]", "class A {", " foo(
) {}", "}"]); | 542 String code = r''' |
| 543 /// [foo] |
| 544 class A { |
| 545 foo() {} |
| 546 }'''; |
| 475 Source source = addSource(code); | 547 Source source = addSource(code); |
| 476 resolve(source); | 548 resolve(source); |
| 477 assertNoErrors(source); | 549 assertNoErrors(source); |
| 478 verify([source]); | 550 verify([source]); |
| 479 CompilationUnit unit = analysisContext.parseCompilationUnit(source); | 551 CompilationUnit unit = analysisContext.parseCompilationUnit(source); |
| 480 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "foo]", (node) =>
node is SimpleIdentifier); | 552 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "foo]", (node) =>
node is SimpleIdentifier); |
| 481 EngineTestCase.assertInstanceOf((obj) => obj is MethodElement, MethodElement
, ref.staticElement); | 553 EngineTestCase.assertInstanceOf((obj) => obj is MethodElement, MethodElement
, ref.staticElement); |
| 482 } | 554 } |
| 483 | 555 |
| 484 void test_commentReference_setter() { | 556 void test_commentReference_setter() { |
| 485 String code = EngineTestCase.createSource([ | 557 String code = r''' |
| 486 "class A {", | 558 class A { |
| 487 " /// [x] in A", | 559 /// [x] in A |
| 488 " mA() {}", | 560 mA() {} |
| 489 " set x(value) {}", | 561 set x(value) {} |
| 490 "}", | 562 } |
| 491 "class B extends A {", | 563 class B extends A { |
| 492 " /// [x] in B", | 564 /// [x] in B |
| 493 " mB() {}", | 565 mB() {} |
| 494 "}", | 566 } |
| 495 ""]); | 567 '''; |
| 496 Source source = addSource(code); | 568 Source source = addSource(code); |
| 497 resolve(source); | 569 resolve(source); |
| 498 assertNoErrors(source); | 570 assertNoErrors(source); |
| 499 verify([source]); | 571 verify([source]); |
| 500 CompilationUnit unit = analysisContext.parseCompilationUnit(source); | 572 CompilationUnit unit = analysisContext.parseCompilationUnit(source); |
| 501 { | 573 { |
| 502 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "x] in A", (nod
e) => node is SimpleIdentifier); | 574 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "x] in A", (nod
e) => node is SimpleIdentifier); |
| 503 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, P
ropertyAccessorElement, ref.staticElement); | 575 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, P
ropertyAccessorElement, ref.staticElement); |
| 504 } | 576 } |
| 505 { | 577 { |
| 506 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "x] in B", (nod
e) => node is SimpleIdentifier); | 578 SimpleIdentifier ref = EngineTestCase.findNode(unit, code, "x] in B", (nod
e) => node is SimpleIdentifier); |
| 507 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, P
ropertyAccessorElement, ref.staticElement); | 579 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, P
ropertyAccessorElement, ref.staticElement); |
| 508 } | 580 } |
| 509 } | 581 } |
| 510 | 582 |
| 511 void test_concreteClassWithAbstractMember() { | 583 void test_concreteClassWithAbstractMember() { |
| 512 Source source = addSource(EngineTestCase.createSource(["abstract class A {",
" m();", "}"])); | 584 Source source = addSource(r''' |
| 585 abstract class A { |
| 586 m(); |
| 587 }'''); |
| 513 resolve(source); | 588 resolve(source); |
| 514 assertNoErrors(source); | 589 assertNoErrors(source); |
| 515 verify([source]); | 590 verify([source]); |
| 516 } | 591 } |
| 517 | 592 |
| 518 void test_concreteClassWithAbstractMember_inherited() { | 593 void test_concreteClassWithAbstractMember_inherited() { |
| 519 Source source = addSource(EngineTestCase.createSource([ | 594 Source source = addSource(r''' |
| 520 "class A {", | 595 class A { |
| 521 " m() {}", | 596 m() {} |
| 522 "}", | 597 } |
| 523 "class B extends A {", | 598 class B extends A { |
| 524 " m();", | 599 m(); |
| 525 "}"])); | 600 }'''); |
| 526 resolve(source); | 601 resolve(source); |
| 527 assertNoErrors(source); | 602 assertNoErrors(source); |
| 528 verify([source]); | 603 verify([source]); |
| 529 } | 604 } |
| 530 | 605 |
| 531 void test_conflictingInstanceGetterAndSuperclassMember_instance() { | 606 void test_conflictingInstanceGetterAndSuperclassMember_instance() { |
| 532 Source source = addSource(EngineTestCase.createSource([ | 607 Source source = addSource(r''' |
| 533 "class A {", | 608 class A { |
| 534 " get v => 0;", | 609 get v => 0; |
| 535 "}", | 610 } |
| 536 "class B extends A {", | 611 class B extends A { |
| 537 " get v => 1;", | 612 get v => 1; |
| 538 "}"])); | 613 }'''); |
| 539 resolve(source); | 614 resolve(source); |
| 540 assertNoErrors(source); | 615 assertNoErrors(source); |
| 541 verify([source]); | 616 verify([source]); |
| 542 } | 617 } |
| 543 | 618 |
| 544 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { | 619 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { |
| 545 Source source = addSource(EngineTestCase.createSource([ | 620 Source source = addSource(r''' |
| 546 "class A {", | 621 class A { |
| 547 " static get x => 0;", | 622 static get x => 0; |
| 548 " static set x(int p) {}", | 623 static set x(int p) {} |
| 549 "}"])); | 624 }'''); |
| 550 resolve(source); | 625 resolve(source); |
| 551 assertNoErrors(source); | 626 assertNoErrors(source); |
| 552 verify([source]); | 627 verify([source]); |
| 553 } | 628 } |
| 554 | 629 |
| 555 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { | 630 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { |
| 556 Source source = addSource(EngineTestCase.createSource([ | 631 Source source = addSource(r''' |
| 557 "class A {", | 632 class A { |
| 558 " static x() {}", | 633 static x() {} |
| 559 " static set x(int p) {}", | 634 static set x(int p) {} |
| 560 "}"])); | 635 }'''); |
| 561 resolve(source); | 636 resolve(source); |
| 562 assertNoErrors(source); | 637 assertNoErrors(source); |
| 563 verify([source]); | 638 verify([source]); |
| 564 } | 639 } |
| 565 | 640 |
| 566 void test_constConstructorWithNonConstSuper_explicit() { | 641 void test_constConstructorWithNonConstSuper_explicit() { |
| 567 Source source = addSource(EngineTestCase.createSource([ | 642 Source source = addSource(r''' |
| 568 "class A {", | 643 class A { |
| 569 " const A();", | 644 const A(); |
| 570 "}", | 645 } |
| 571 "class B extends A {", | 646 class B extends A { |
| 572 " const B(): super();", | 647 const B(): super(); |
| 573 "}"])); | 648 }'''); |
| 574 resolve(source); | 649 resolve(source); |
| 575 assertNoErrors(source); | 650 assertNoErrors(source); |
| 576 verify([source]); | 651 verify([source]); |
| 577 } | 652 } |
| 578 | 653 |
| 579 void test_constConstructorWithNonConstSuper_redirectingFactory() { | 654 void test_constConstructorWithNonConstSuper_redirectingFactory() { |
| 580 Source source = addSource(EngineTestCase.createSource([ | 655 Source source = addSource(r''' |
| 581 "class A {", | 656 class A { |
| 582 " A();", | 657 A(); |
| 583 "}", | 658 } |
| 584 "class B implements C {", | 659 class B implements C { |
| 585 " const B();", | 660 const B(); |
| 586 "}", | 661 } |
| 587 "class C extends A {", | 662 class C extends A { |
| 588 " const factory C() = B;", | 663 const factory C() = B; |
| 589 "}"])); | 664 }'''); |
| 590 resolve(source); | 665 resolve(source); |
| 591 assertNoErrors(source); | 666 assertNoErrors(source); |
| 592 verify([source]); | 667 verify([source]); |
| 593 } | 668 } |
| 594 | 669 |
| 595 void test_constConstructorWithNonConstSuper_unresolved() { | 670 void test_constConstructorWithNonConstSuper_unresolved() { |
| 596 Source source = addSource(EngineTestCase.createSource([ | 671 Source source = addSource(r''' |
| 597 "class A {", | 672 class A { |
| 598 " A.a();", | 673 A.a(); |
| 599 "}", | 674 } |
| 600 "class B extends A {", | 675 class B extends A { |
| 601 " const B(): super();", | 676 const B(): super(); |
| 602 "}"])); | 677 }'''); |
| 603 resolve(source); | 678 resolve(source); |
| 604 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); | 679 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); |
| 605 verify([source]); | 680 verify([source]); |
| 606 } | 681 } |
| 607 | 682 |
| 608 void test_constConstructorWithNonFinalField_finalInstanceVar() { | 683 void test_constConstructorWithNonFinalField_finalInstanceVar() { |
| 609 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " const A();", "}"])); | 684 Source source = addSource(r''' |
| 685 class A { |
| 686 final int x = 0; |
| 687 const A(); |
| 688 }'''); |
| 610 resolve(source); | 689 resolve(source); |
| 611 assertNoErrors(source); | 690 assertNoErrors(source); |
| 612 verify([source]); | 691 verify([source]); |
| 613 } | 692 } |
| 614 | 693 |
| 615 void test_constConstructorWithNonFinalField_mixin() { | 694 void test_constConstructorWithNonFinalField_mixin() { |
| 616 Source source = addSource(EngineTestCase.createSource([ | 695 Source source = addSource(r''' |
| 617 "class A {", | 696 class A { |
| 618 " a() {}", | 697 a() {} |
| 619 "}", | 698 } |
| 620 "class B extends Object with A {", | 699 class B extends Object with A { |
| 621 " const B();", | 700 const B(); |
| 622 "}"])); | 701 }'''); |
| 623 resolve(source); | 702 resolve(source); |
| 624 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]); | 703 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]); |
| 625 verify([source]); | 704 verify([source]); |
| 626 } | 705 } |
| 627 | 706 |
| 628 void test_constConstructorWithNonFinalField_static() { | 707 void test_constConstructorWithNonFinalField_static() { |
| 629 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " const A();", "}"])); | 708 Source source = addSource(r''' |
| 709 class A { |
| 710 static int x; |
| 711 const A(); |
| 712 }'''); |
| 630 resolve(source); | 713 resolve(source); |
| 631 assertNoErrors(source); | 714 assertNoErrors(source); |
| 632 verify([source]); | 715 verify([source]); |
| 633 } | 716 } |
| 634 | 717 |
| 635 void test_constConstructorWithNonFinalField_syntheticField() { | 718 void test_constConstructorWithNonFinalField_syntheticField() { |
| 636 Source source = addSource(EngineTestCase.createSource([ | 719 Source source = addSource(r''' |
| 637 "class A {", | 720 class A { |
| 638 " const A();", | 721 const A(); |
| 639 " set x(value) {}", | 722 set x(value) {} |
| 640 " get x {return 0;}", | 723 get x {return 0;} |
| 641 "}"])); | 724 }'''); |
| 642 resolve(source); | 725 resolve(source); |
| 643 assertNoErrors(source); | 726 assertNoErrors(source); |
| 644 verify([source]); | 727 verify([source]); |
| 645 } | 728 } |
| 646 | 729 |
| 647 void test_constDeferredClass_new() { | 730 void test_constDeferredClass_new() { |
| 648 resolveWithAndWithoutExperimental(<String> [ | 731 resolveWithAndWithoutExperimental(<String> [ |
| 649 EngineTestCase.createSource(["library lib1;", "class A {", " const A.b(
);", "}"]), | 732 r''' |
| 650 EngineTestCase.createSource([ | 733 library lib1; |
| 651 "library root;", | 734 class A { |
| 652 "import 'lib1.dart' deferred as a;", | 735 const A.b(); |
| 653 "main() {", | 736 }''', |
| 654 " new a.A.b();", | 737 r''' |
| 655 "}"])], <ErrorCode> [ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED], <E
rrorCode> []); | 738 library root; |
| 739 import 'lib1.dart' deferred as a; |
| 740 main() { |
| 741 new a.A.b(); |
| 742 }'''], <ErrorCode> [ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED], <ErrorCode>
[]); |
| 656 } | 743 } |
| 657 | 744 |
| 658 void test_constEval_functionTypeLiteral() { | 745 void test_constEval_functionTypeLiteral() { |
| 659 Source source = addSource(EngineTestCase.createSource(["typedef F();", "cons
t C = F;"])); | 746 Source source = addSource(r''' |
| 747 typedef F(); |
| 748 const C = F;'''); |
| 660 resolve(source); | 749 resolve(source); |
| 661 assertNoErrors(source); | 750 assertNoErrors(source); |
| 662 verify([source]); | 751 verify([source]); |
| 663 } | 752 } |
| 664 | 753 |
| 665 void test_constEval_propertyExtraction_fieldStatic_targetType() { | 754 void test_constEval_propertyExtraction_fieldStatic_targetType() { |
| 666 addNamedSource("/math.dart", EngineTestCase.createSource(["library math;", "
const PI = 3.14;"])); | 755 addNamedSource("/math.dart", r''' |
| 667 Source source = addSource(EngineTestCase.createSource(["import 'math.dart' a
s math;", "const C = math.PI;"])); | 756 library math; |
| 757 const PI = 3.14;'''); |
| 758 Source source = addSource(r''' |
| 759 import 'math.dart' as math; |
| 760 const C = math.PI;'''); |
| 668 resolve(source); | 761 resolve(source); |
| 669 assertNoErrors(source); | 762 assertNoErrors(source); |
| 670 verify([source]); | 763 verify([source]); |
| 671 } | 764 } |
| 672 | 765 |
| 673 void test_constEval_propertyExtraction_methodStatic_targetType() { | 766 void test_constEval_propertyExtraction_methodStatic_targetType() { |
| 674 Source source = addSource(EngineTestCase.createSource([ | 767 Source source = addSource(r''' |
| 675 "class A {", | 768 class A { |
| 676 " const A();", | 769 const A(); |
| 677 " static m() {}", | 770 static m() {} |
| 678 "}", | 771 } |
| 679 "const C = A.m;"])); | 772 const C = A.m;'''); |
| 680 resolve(source); | 773 resolve(source); |
| 681 assertNoErrors(source); | 774 assertNoErrors(source); |
| 682 verify([source]); | 775 verify([source]); |
| 683 } | 776 } |
| 684 | 777 |
| 685 void test_constEval_symbol() { | 778 void test_constEval_symbol() { |
| 686 addNamedSource("/math.dart", EngineTestCase.createSource(["library math;", "
const PI = 3.14;"])); | 779 addNamedSource("/math.dart", r''' |
| 687 Source source = addSource(EngineTestCase.createSource(["const C = #foo;", "f
oo() {}"])); | 780 library math; |
| 781 const PI = 3.14;'''); |
| 782 Source source = addSource(r''' |
| 783 const C = #foo; |
| 784 foo() {}'''); |
| 688 resolve(source); | 785 resolve(source); |
| 689 assertNoErrors(source); | 786 assertNoErrors(source); |
| 690 verify([source]); | 787 verify([source]); |
| 691 } | 788 } |
| 692 | 789 |
| 693 void test_constEvalTypeBoolNumString_equal() { | 790 void test_constEvalTypeBoolNumString_equal() { |
| 694 Source source = addSource(EngineTestCase.createSource([ | 791 Source source = addSource(r''' |
| 695 "class A {", | 792 class A { |
| 696 " const A();", | 793 const A(); |
| 697 "}", | 794 } |
| 698 "class B {", | 795 class B { |
| 699 " final v;", | 796 final v; |
| 700 " const B.a1(bool p) : v = p == true;", | 797 const B.a1(bool p) : v = p == true; |
| 701 " const B.a2(bool p) : v = p == false;", | 798 const B.a2(bool p) : v = p == false; |
| 702 " const B.a3(bool p) : v = p == 0;", | 799 const B.a3(bool p) : v = p == 0; |
| 703 " const B.a4(bool p) : v = p == 0.0;", | 800 const B.a4(bool p) : v = p == 0.0; |
| 704 " const B.a5(bool p) : v = p == '';", | 801 const B.a5(bool p) : v = p == ''; |
| 705 " const B.b1(int p) : v = p == true;", | 802 const B.b1(int p) : v = p == true; |
| 706 " const B.b2(int p) : v = p == false;", | 803 const B.b2(int p) : v = p == false; |
| 707 " const B.b3(int p) : v = p == 0;", | 804 const B.b3(int p) : v = p == 0; |
| 708 " const B.b4(int p) : v = p == 0.0;", | 805 const B.b4(int p) : v = p == 0.0; |
| 709 " const B.b5(int p) : v = p == '';", | 806 const B.b5(int p) : v = p == ''; |
| 710 " const B.c1(String p) : v = p == true;", | 807 const B.c1(String p) : v = p == true; |
| 711 " const B.c2(String p) : v = p == false;", | 808 const B.c2(String p) : v = p == false; |
| 712 " const B.c3(String p) : v = p == 0;", | 809 const B.c3(String p) : v = p == 0; |
| 713 " const B.c4(String p) : v = p == 0.0;", | 810 const B.c4(String p) : v = p == 0.0; |
| 714 " const B.c5(String p) : v = p == '';", | 811 const B.c5(String p) : v = p == ''; |
| 715 " const B.n1(num p) : v = p == null;", | 812 const B.n1(num p) : v = p == null; |
| 716 " const B.n2(num p) : v = null == p;", | 813 const B.n2(num p) : v = null == p; |
| 717 "}"])); | 814 }'''); |
| 718 resolve(source); | 815 resolve(source); |
| 719 assertNoErrors(source); | 816 assertNoErrors(source); |
| 720 } | 817 } |
| 721 | 818 |
| 722 void test_constEvalTypeBoolNumString_notEqual() { | 819 void test_constEvalTypeBoolNumString_notEqual() { |
| 723 Source source = addSource(EngineTestCase.createSource([ | 820 Source source = addSource(r''' |
| 724 "class A {", | 821 class A { |
| 725 " const A();", | 822 const A(); |
| 726 "}", | 823 } |
| 727 "class B {", | 824 class B { |
| 728 " final v;", | 825 final v; |
| 729 " const B.a1(bool p) : v = p != true;", | 826 const B.a1(bool p) : v = p != true; |
| 730 " const B.a2(bool p) : v = p != false;", | 827 const B.a2(bool p) : v = p != false; |
| 731 " const B.a3(bool p) : v = p != 0;", | 828 const B.a3(bool p) : v = p != 0; |
| 732 " const B.a4(bool p) : v = p != 0.0;", | 829 const B.a4(bool p) : v = p != 0.0; |
| 733 " const B.a5(bool p) : v = p != '';", | 830 const B.a5(bool p) : v = p != ''; |
| 734 " const B.b1(int p) : v = p != true;", | 831 const B.b1(int p) : v = p != true; |
| 735 " const B.b2(int p) : v = p != false;", | 832 const B.b2(int p) : v = p != false; |
| 736 " const B.b3(int p) : v = p != 0;", | 833 const B.b3(int p) : v = p != 0; |
| 737 " const B.b4(int p) : v = p != 0.0;", | 834 const B.b4(int p) : v = p != 0.0; |
| 738 " const B.b5(int p) : v = p != '';", | 835 const B.b5(int p) : v = p != ''; |
| 739 " const B.c1(String p) : v = p != true;", | 836 const B.c1(String p) : v = p != true; |
| 740 " const B.c2(String p) : v = p != false;", | 837 const B.c2(String p) : v = p != false; |
| 741 " const B.c3(String p) : v = p != 0;", | 838 const B.c3(String p) : v = p != 0; |
| 742 " const B.c4(String p) : v = p != 0.0;", | 839 const B.c4(String p) : v = p != 0.0; |
| 743 " const B.c5(String p) : v = p != '';", | 840 const B.c5(String p) : v = p != ''; |
| 744 " const B.n1(num p) : v = p != null;", | 841 const B.n1(num p) : v = p != null; |
| 745 " const B.n2(num p) : v = null != p;", | 842 const B.n2(num p) : v = null != p; |
| 746 "}"])); | 843 }'''); |
| 747 resolve(source); | 844 resolve(source); |
| 748 assertNoErrors(source); | 845 assertNoErrors(source); |
| 749 verify([source]); | 846 verify([source]); |
| 750 } | 847 } |
| 751 | 848 |
| 752 void test_constMapKeyExpressionTypeImplementsEquals_abstract() { | 849 void test_constMapKeyExpressionTypeImplementsEquals_abstract() { |
| 753 Source source = addSource(EngineTestCase.createSource([ | 850 Source source = addSource(r''' |
| 754 "abstract class B {", | 851 abstract class B { |
| 755 " final id;", | 852 final id; |
| 756 " const B(this.id);", | 853 const B(this.id); |
| 757 " String toString() => 'C(\$id)';", | 854 String toString() => 'C($id)'; |
| 758 " /** Equality is identity equality, the id isn't used. */", | 855 /** Equality is identity equality, the id isn't used. */ |
| 759 " bool operator==(Object other);", | 856 bool operator==(Object other); |
| 760 " }", | 857 } |
| 761 "", | 858 |
| 762 "class C extends B {", | 859 class C extends B { |
| 763 " const C(id) : super(id);", | 860 const C(id) : super(id); |
| 764 "}", | 861 } |
| 765 "", | 862 |
| 766 "Map getMap() {", | 863 Map getMap() { |
| 767 " return const { const C(0): 'Map: 0' };", | 864 return const { const C(0): 'Map: 0' }; |
| 768 "}"])); | 865 }'''); |
| 769 resolve(source); | 866 resolve(source); |
| 770 assertNoErrors(source); | 867 assertNoErrors(source); |
| 771 verify([source]); | 868 verify([source]); |
| 772 } | 869 } |
| 773 | 870 |
| 774 void test_constNotInitialized_field() { | 871 void test_constNotInitialized_field() { |
| 775 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const int x = 0;", "}"])); | 872 Source source = addSource(r''' |
| 873 class A { |
| 874 static const int x = 0; |
| 875 }'''); |
| 776 resolve(source); | 876 resolve(source); |
| 777 assertNoErrors(source); | 877 assertNoErrors(source); |
| 778 verify([source]); | 878 verify([source]); |
| 779 } | 879 } |
| 780 | 880 |
| 781 void test_constNotInitialized_local() { | 881 void test_constNotInitialized_local() { |
| 782 Source source = addSource(EngineTestCase.createSource(["main() {", " const
int x = 0;", "}"])); | 882 Source source = addSource(r''' |
| 883 main() { |
| 884 const int x = 0; |
| 885 }'''); |
| 783 resolve(source); | 886 resolve(source); |
| 784 assertNoErrors(source); | 887 assertNoErrors(source); |
| 785 verify([source]); | 888 verify([source]); |
| 786 } | 889 } |
| 787 | 890 |
| 788 void test_constructorDeclaration_scope_signature() { | 891 void test_constructorDeclaration_scope_signature() { |
| 789 Source source = addSource(EngineTestCase.createSource([ | 892 Source source = addSource(r''' |
| 790 "const app = 0;", | 893 const app = 0; |
| 791 "class A {", | 894 class A { |
| 792 " A(@app int app) {}", | 895 A(@app int app) {} |
| 793 "}"])); | 896 }'''); |
| 794 resolve(source); | 897 resolve(source); |
| 795 assertNoErrors(source); | 898 assertNoErrors(source); |
| 796 verify([source]); | 899 verify([source]); |
| 797 } | 900 } |
| 798 | 901 |
| 799 void test_constWithNonConstantArgument_literals() { | 902 void test_constWithNonConstantArgument_literals() { |
| 800 Source source = addSource(EngineTestCase.createSource([ | 903 Source source = addSource(r''' |
| 801 "class A {", | 904 class A { |
| 802 " const A(a, b, c, d);", | 905 const A(a, b, c, d); |
| 803 "}", | 906 } |
| 804 "f() { return const A(true, 0, 1.0, '2'); }"])); | 907 f() { return const A(true, 0, 1.0, '2'); }'''); |
| 805 resolve(source); | 908 resolve(source); |
| 806 assertNoErrors(source); | 909 assertNoErrors(source); |
| 807 verify([source]); | 910 verify([source]); |
| 808 } | 911 } |
| 809 | 912 |
| 810 void test_constWithTypeParameters_direct() { | 913 void test_constWithTypeParameters_direct() { |
| 811 Source source = addSource(EngineTestCase.createSource([ | 914 Source source = addSource(r''' |
| 812 "class A<T> {", | 915 class A<T> { |
| 813 " static const V = const A<int>();", | 916 static const V = const A<int>(); |
| 814 " const A();", | 917 const A(); |
| 815 "}"])); | 918 }'''); |
| 816 resolve(source); | 919 resolve(source); |
| 817 assertNoErrors(source); | 920 assertNoErrors(source); |
| 818 verify([source]); | 921 verify([source]); |
| 819 } | 922 } |
| 820 | 923 |
| 821 void test_constWithUndefinedConstructor() { | 924 void test_constWithUndefinedConstructor() { |
| 822 Source source = addSource(EngineTestCase.createSource([ | 925 Source source = addSource(r''' |
| 823 "class A {", | 926 class A { |
| 824 " const A.name();", | 927 const A.name(); |
| 825 "}", | 928 } |
| 826 "f() {", | 929 f() { |
| 827 " return const A.name();", | 930 return const A.name(); |
| 828 "}"])); | 931 }'''); |
| 829 resolve(source); | 932 resolve(source); |
| 830 assertNoErrors(source); | 933 assertNoErrors(source); |
| 831 verify([source]); | 934 verify([source]); |
| 832 } | 935 } |
| 833 | 936 |
| 834 void test_constWithUndefinedConstructorDefault() { | 937 void test_constWithUndefinedConstructorDefault() { |
| 835 Source source = addSource(EngineTestCase.createSource([ | 938 Source source = addSource(r''' |
| 836 "class A {", | 939 class A { |
| 837 " const A();", | 940 const A(); |
| 838 "}", | 941 } |
| 839 "f() {", | 942 f() { |
| 840 " return const A();", | 943 return const A(); |
| 841 "}"])); | 944 }'''); |
| 842 resolve(source); | 945 resolve(source); |
| 843 assertNoErrors(source); | 946 assertNoErrors(source); |
| 844 verify([source]); | 947 verify([source]); |
| 845 } | 948 } |
| 846 | 949 |
| 847 void test_defaultValueInFunctionTypeAlias() { | 950 void test_defaultValueInFunctionTypeAlias() { |
| 848 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"])); | 951 Source source = addSource("typedef F([x]);"); |
| 849 resolve(source); | 952 resolve(source); |
| 850 assertNoErrors(source); | 953 assertNoErrors(source); |
| 851 verify([source]); | 954 verify([source]); |
| 852 } | 955 } |
| 853 | 956 |
| 854 void test_defaultValueInFunctionTypedParameter_named() { | 957 void test_defaultValueInFunctionTypedParameter_named() { |
| 855 Source source = addSource(EngineTestCase.createSource(["f(g({p})) {}"])); | 958 Source source = addSource("f(g({p})) {}"); |
| 856 resolve(source); | 959 resolve(source); |
| 857 assertNoErrors(source); | 960 assertNoErrors(source); |
| 858 verify([source]); | 961 verify([source]); |
| 859 } | 962 } |
| 860 | 963 |
| 861 void test_defaultValueInFunctionTypedParameter_optional() { | 964 void test_defaultValueInFunctionTypedParameter_optional() { |
| 862 Source source = addSource(EngineTestCase.createSource(["f(g([p])) {}"])); | 965 Source source = addSource("f(g([p])) {}"); |
| 863 resolve(source); | 966 resolve(source); |
| 864 assertNoErrors(source); | 967 assertNoErrors(source); |
| 865 verify([source]); | 968 verify([source]); |
| 866 } | 969 } |
| 867 | 970 |
| 868 void test_deprecatedMemberUse_hide() { | 971 void test_deprecatedMemberUse_hide() { |
| 869 Source source = addSource(EngineTestCase.createSource([ | 972 Source source = addSource(r''' |
| 870 "library lib;", | 973 library lib; |
| 871 "import 'lib1.dart' hide B;", | 974 import 'lib1.dart' hide B; |
| 872 "A a = new A();"])); | 975 A a = new A();'''); |
| 873 addNamedSource("/lib1.dart", EngineTestCase.createSource([ | 976 addNamedSource("/lib1.dart", r''' |
| 874 "library lib1;", | 977 library lib1; |
| 875 "class A {}", | 978 class A {} |
| 876 "@deprecated", | 979 @deprecated |
| 877 "class B {}"])); | 980 class B {}'''); |
| 878 resolve(source); | 981 resolve(source); |
| 879 assertNoErrors(source); | 982 assertNoErrors(source); |
| 880 verify([source]); | 983 verify([source]); |
| 881 } | 984 } |
| 882 | 985 |
| 883 void test_duplicateDefinition_emptyName() { | 986 void test_duplicateDefinition_emptyName() { |
| 884 // Note: This code has two FunctionElements '() {}' with an empty name, this
tests that the | 987 // Note: This code has two FunctionElements '() {}' with an empty name, this
tests that the |
| 885 // empty string is not put into the scope (more than once). | 988 // empty string is not put into the scope (more than once). |
| 886 Source source = addSource(EngineTestCase.createSource([ | 989 Source source = addSource(r''' |
| 887 "Map _globalMap = {", | 990 Map _globalMap = { |
| 888 " 'a' : () {},", | 991 'a' : () {}, |
| 889 " 'b' : () {}", | 992 'b' : () {} |
| 890 "};"])); | 993 };'''); |
| 891 resolve(source); | 994 resolve(source); |
| 892 assertNoErrors(source); | 995 assertNoErrors(source); |
| 893 verify([source]); | 996 verify([source]); |
| 894 } | 997 } |
| 895 | 998 |
| 896 void test_duplicateDefinition_getter() { | 999 void test_duplicateDefinition_getter() { |
| 897 Source source = addSource(EngineTestCase.createSource(["bool get a => true;"
])); | 1000 Source source = addSource("bool get a => true;"); |
| 898 resolve(source); | 1001 resolve(source); |
| 899 assertNoErrors(source); | 1002 assertNoErrors(source); |
| 900 verify([source]); | 1003 verify([source]); |
| 901 } | 1004 } |
| 902 | 1005 |
| 903 void test_dynamicIdentifier() { | 1006 void test_dynamicIdentifier() { |
| 904 Source source = addSource(EngineTestCase.createSource(["main() {", " var v
= dynamic;", "}"])); | 1007 Source source = addSource(r''' |
| 1008 main() { |
| 1009 var v = dynamic; |
| 1010 }'''); |
| 905 resolve(source); | 1011 resolve(source); |
| 906 assertNoErrors(source); | 1012 assertNoErrors(source); |
| 907 verify([source]); | 1013 verify([source]); |
| 908 } | 1014 } |
| 909 | 1015 |
| 910 void test_expectedOneListTypeArgument() { | 1016 void test_expectedOneListTypeArgument() { |
| 911 Source source = addSource(EngineTestCase.createSource(["main() {", " <int>
[];", "}"])); | 1017 Source source = addSource(r''' |
| 1018 main() { |
| 1019 <int> []; |
| 1020 }'''); |
| 912 resolve(source); | 1021 resolve(source); |
| 913 assertNoErrors(source); | 1022 assertNoErrors(source); |
| 914 verify([source]); | 1023 verify([source]); |
| 915 } | 1024 } |
| 916 | 1025 |
| 917 void test_expectedTwoMapTypeArguments() { | 1026 void test_expectedTwoMapTypeArguments() { |
| 918 Source source = addSource(EngineTestCase.createSource(["main() {", " <int,
int> {};", "}"])); | 1027 Source source = addSource(r''' |
| 1028 main() { |
| 1029 <int, int> {}; |
| 1030 }'''); |
| 919 resolve(source); | 1031 resolve(source); |
| 920 assertNoErrors(source); | 1032 assertNoErrors(source); |
| 921 verify([source]); | 1033 verify([source]); |
| 922 } | 1034 } |
| 923 | 1035 |
| 924 void test_exportOfNonLibrary_libraryDeclared() { | 1036 void test_exportOfNonLibrary_libraryDeclared() { |
| 925 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 1037 Source source = addSource(r''' |
| 926 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;"]))
; | 1038 library L; |
| 1039 export 'lib1.dart';'''); |
| 1040 addNamedSource("/lib1.dart", "library lib1;"); |
| 927 resolve(source); | 1041 resolve(source); |
| 928 assertNoErrors(source); | 1042 assertNoErrors(source); |
| 929 verify([source]); | 1043 verify([source]); |
| 930 } | 1044 } |
| 931 | 1045 |
| 932 void test_exportOfNonLibrary_libraryNotDeclared() { | 1046 void test_exportOfNonLibrary_libraryNotDeclared() { |
| 933 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 1047 Source source = addSource(r''' |
| 934 addNamedSource("/lib1.dart", EngineTestCase.createSource([""])); | 1048 library L; |
| 1049 export 'lib1.dart';'''); |
| 1050 addNamedSource("/lib1.dart", ""); |
| 935 resolve(source); | 1051 resolve(source); |
| 936 assertNoErrors(source); | 1052 assertNoErrors(source); |
| 937 verify([source]); | 1053 verify([source]); |
| 938 } | 1054 } |
| 939 | 1055 |
| 940 void test_extraPositionalArguments_function() { | 1056 void test_extraPositionalArguments_function() { |
| 941 Source source = addSource(EngineTestCase.createSource(["f(p1, p2) {}", "main
() {", " f(1, 2);", "}"])); | 1057 Source source = addSource(r''' |
| 1058 f(p1, p2) {} |
| 1059 main() { |
| 1060 f(1, 2); |
| 1061 }'''); |
| 942 resolve(source); | 1062 resolve(source); |
| 943 assertNoErrors(source); | 1063 assertNoErrors(source); |
| 944 verify([source]); | 1064 verify([source]); |
| 945 } | 1065 } |
| 946 | 1066 |
| 947 void test_extraPositionalArguments_Function() { | 1067 void test_extraPositionalArguments_Function() { |
| 948 Source source = addSource(EngineTestCase.createSource(["f(Function a) {", "
a(1, 2);", "}"])); | 1068 Source source = addSource(r''' |
| 1069 f(Function a) { |
| 1070 a(1, 2); |
| 1071 }'''); |
| 949 resolve(source); | 1072 resolve(source); |
| 950 assertNoErrors(source); | 1073 assertNoErrors(source); |
| 951 verify([source]); | 1074 verify([source]); |
| 952 } | 1075 } |
| 953 | 1076 |
| 954 void test_extraPositionalArguments_implicitConstructor() { | 1077 void test_extraPositionalArguments_implicitConstructor() { |
| 955 Source source = addSource(EngineTestCase.createSource([ | 1078 Source source = addSource(r''' |
| 956 "class A<E extends num> {", | 1079 class A<E extends num> { |
| 957 " A(E x, E y);", | 1080 A(E x, E y); |
| 958 "}", | 1081 } |
| 959 "class M {}", | 1082 class M {} |
| 960 "class B<E extends num> = A<E> with M;", | 1083 class B<E extends num> = A<E> with M; |
| 961 "void main() {", | 1084 void main() { |
| 962 " B<int> x = new B<int>(0,0);", | 1085 B<int> x = new B<int>(0,0); |
| 963 "}"])); | 1086 }'''); |
| 964 resolve(source); | 1087 resolve(source); |
| 965 assertNoErrors(source); | 1088 assertNoErrors(source); |
| 966 verify([source]); | 1089 verify([source]); |
| 967 } | 1090 } |
| 968 | 1091 |
| 969 void test_extraPositionalArguments_typedef_local() { | 1092 void test_extraPositionalArguments_typedef_local() { |
| 970 Source source = addSource(EngineTestCase.createSource([ | 1093 Source source = addSource(r''' |
| 971 "typedef A(p1, p2);", | 1094 typedef A(p1, p2); |
| 972 "A getA() => null;", | 1095 A getA() => null; |
| 973 "f() {", | 1096 f() { |
| 974 " A a = getA();", | 1097 A a = getA(); |
| 975 " a(1, 2);", | 1098 a(1, 2); |
| 976 "}"])); | 1099 }'''); |
| 977 resolve(source); | 1100 resolve(source); |
| 978 assertNoErrors(source); | 1101 assertNoErrors(source); |
| 979 verify([source]); | 1102 verify([source]); |
| 980 } | 1103 } |
| 981 | 1104 |
| 982 void test_extraPositionalArguments_typedef_parameter() { | 1105 void test_extraPositionalArguments_typedef_parameter() { |
| 983 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);",
"f(A a) {", " a(1, 2);", "}"])); | 1106 Source source = addSource(r''' |
| 1107 typedef A(p1, p2); |
| 1108 f(A a) { |
| 1109 a(1, 2); |
| 1110 }'''); |
| 984 resolve(source); | 1111 resolve(source); |
| 985 assertNoErrors(source); | 1112 assertNoErrors(source); |
| 986 verify([source]); | 1113 verify([source]); |
| 987 } | 1114 } |
| 988 | 1115 |
| 989 void test_fieldInitializedByMultipleInitializers() { | 1116 void test_fieldInitializedByMultipleInitializers() { |
| 990 Source source = addSource(EngineTestCase.createSource([ | 1117 Source source = addSource(r''' |
| 991 "class A {", | 1118 class A { |
| 992 " int x;", | 1119 int x; |
| 993 " int y;", | 1120 int y; |
| 994 " A() : x = 0, y = 0 {}", | 1121 A() : x = 0, y = 0 {} |
| 995 "}"])); | 1122 }'''); |
| 996 resolve(source); | 1123 resolve(source); |
| 997 assertNoErrors(source); | 1124 assertNoErrors(source); |
| 998 verify([source]); | 1125 verify([source]); |
| 999 } | 1126 } |
| 1000 | 1127 |
| 1001 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() { | 1128 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() { |
| 1002 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 0;", " A() : x = 1 {}", "}"])); | 1129 Source source = addSource(r''' |
| 1130 class A { |
| 1131 int x = 0; |
| 1132 A() : x = 1 {} |
| 1133 }'''); |
| 1003 resolve(source); | 1134 resolve(source); |
| 1004 assertNoErrors(source); | 1135 assertNoErrors(source); |
| 1005 verify([source]); | 1136 verify([source]); |
| 1006 } | 1137 } |
| 1007 | 1138 |
| 1008 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() { | 1139 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() { |
| 1009 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 1 {}", "}"])); | 1140 Source source = addSource(r''' |
| 1141 class A { |
| 1142 final int x; |
| 1143 A() : x = 1 {} |
| 1144 }'''); |
| 1010 resolve(source); | 1145 resolve(source); |
| 1011 assertNoErrors(source); | 1146 assertNoErrors(source); |
| 1012 verify([source]); | 1147 verify([source]); |
| 1013 } | 1148 } |
| 1014 | 1149 |
| 1015 void test_fieldInitializerOutsideConstructor() { | 1150 void test_fieldInitializerOutsideConstructor() { |
| 1016 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 1151 Source source = addSource(r''' |
| 1152 class A { |
| 1153 int x; |
| 1154 A(this.x) {} |
| 1155 }'''); |
| 1017 resolve(source); | 1156 resolve(source); |
| 1018 assertNoErrors(source); | 1157 assertNoErrors(source); |
| 1019 verify([source]); | 1158 verify([source]); |
| 1020 } | 1159 } |
| 1021 | 1160 |
| 1022 void test_fieldInitializerOutsideConstructor_defaultParameters() { | 1161 void test_fieldInitializerOutsideConstructor_defaultParameters() { |
| 1023 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A([this.x]) {}", "}"])); | 1162 Source source = addSource(r''' |
| 1163 class A { |
| 1164 int x; |
| 1165 A([this.x]) {} |
| 1166 }'''); |
| 1024 resolve(source); | 1167 resolve(source); |
| 1025 assertNoErrors(source); | 1168 assertNoErrors(source); |
| 1026 verify([source]); | 1169 verify([source]); |
| 1027 } | 1170 } |
| 1028 | 1171 |
| 1029 void test_fieldInitializerRedirectingConstructor_super() { | 1172 void test_fieldInitializerRedirectingConstructor_super() { |
| 1030 Source source = addSource(EngineTestCase.createSource([ | 1173 Source source = addSource(r''' |
| 1031 "class A {", | 1174 class A { |
| 1032 " A() {}", | 1175 A() {} |
| 1033 "}", | 1176 } |
| 1034 "class B extends A {", | 1177 class B extends A { |
| 1035 " int x;", | 1178 int x; |
| 1036 " B(this.x) : super();", | 1179 B(this.x) : super(); |
| 1037 "}"])); | 1180 }'''); |
| 1038 resolve(source); | 1181 resolve(source); |
| 1039 assertNoErrors(source); | 1182 assertNoErrors(source); |
| 1040 verify([source]); | 1183 verify([source]); |
| 1041 } | 1184 } |
| 1042 | 1185 |
| 1043 void test_finalInitializedInDeclarationAndConstructor_initializer() { | 1186 void test_finalInitializedInDeclarationAndConstructor_initializer() { |
| 1044 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 1 {}", "}"])); | 1187 Source source = addSource(r''' |
| 1188 class A { |
| 1189 final x; |
| 1190 A() : x = 1 {} |
| 1191 }'''); |
| 1045 resolve(source); | 1192 resolve(source); |
| 1046 assertNoErrors(source); | 1193 assertNoErrors(source); |
| 1047 verify([source]); | 1194 verify([source]); |
| 1048 } | 1195 } |
| 1049 | 1196 |
| 1050 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { | 1197 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { |
| 1051 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) {}", "}"])); | 1198 Source source = addSource(r''' |
| 1199 class A { |
| 1200 final x; |
| 1201 A(this.x) {} |
| 1202 }'''); |
| 1052 resolve(source); | 1203 resolve(source); |
| 1053 assertNoErrors(source); | 1204 assertNoErrors(source); |
| 1054 verify([source]); | 1205 verify([source]); |
| 1055 } | 1206 } |
| 1056 | 1207 |
| 1057 void test_finalNotInitialized_atDeclaration() { | 1208 void test_finalNotInitialized_atDeclaration() { |
| 1058 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); | 1209 Source source = addSource(r''' |
| 1210 class A { |
| 1211 final int x = 0; |
| 1212 A() {} |
| 1213 }'''); |
| 1059 resolve(source); | 1214 resolve(source); |
| 1060 assertNoErrors(source); | 1215 assertNoErrors(source); |
| 1061 verify([source]); | 1216 verify([source]); |
| 1062 } | 1217 } |
| 1063 | 1218 |
| 1064 void test_finalNotInitialized_fieldFormal() { | 1219 void test_finalNotInitialized_fieldFormal() { |
| 1065 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); | 1220 Source source = addSource(r''' |
| 1221 class A { |
| 1222 final int x = 0; |
| 1223 A() {} |
| 1224 }'''); |
| 1066 resolve(source); | 1225 resolve(source); |
| 1067 assertNoErrors(source); | 1226 assertNoErrors(source); |
| 1068 verify([source]); | 1227 verify([source]); |
| 1069 } | 1228 } |
| 1070 | 1229 |
| 1071 void test_finalNotInitialized_functionTypedFieldFormal() { | 1230 void test_finalNotInitialized_functionTypedFieldFormal() { |
| 1072 Source source = addSource(EngineTestCase.createSource([ | 1231 Source source = addSource(r''' |
| 1073 "class A {", | 1232 class A { |
| 1074 " final Function x;", | 1233 final Function x; |
| 1075 " A(int this.x(int p)) {}", | 1234 A(int this.x(int p)) {} |
| 1076 "}"])); | 1235 }'''); |
| 1077 resolve(source); | 1236 resolve(source); |
| 1078 assertNoErrors(source); | 1237 assertNoErrors(source); |
| 1079 verify([source]); | 1238 verify([source]); |
| 1080 } | 1239 } |
| 1081 | 1240 |
| 1082 void test_finalNotInitialized_hasNativeClause_hasConstructor() { | 1241 void test_finalNotInitialized_hasNativeClause_hasConstructor() { |
| 1083 Source source = addSource(EngineTestCase.createSource([ | 1242 Source source = addSource(r''' |
| 1084 "class A native 'something' {", | 1243 class A native 'something' { |
| 1085 " final int x;", | 1244 final int x; |
| 1086 " A() {}", | 1245 A() {} |
| 1087 "}"])); | 1246 }'''); |
| 1088 resolve(source); | 1247 resolve(source); |
| 1089 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 1248 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 1090 verify([source]); | 1249 verify([source]); |
| 1091 } | 1250 } |
| 1092 | 1251 |
| 1093 void test_finalNotInitialized_hasNativeClause_noConstructor() { | 1252 void test_finalNotInitialized_hasNativeClause_noConstructor() { |
| 1094 Source source = addSource(EngineTestCase.createSource(["class A native 'some
thing' {", " final int x;", "}"])); | 1253 Source source = addSource(r''' |
| 1254 class A native 'something' { |
| 1255 final int x; |
| 1256 }'''); |
| 1095 resolve(source); | 1257 resolve(source); |
| 1096 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 1258 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 1097 verify([source]); | 1259 verify([source]); |
| 1098 } | 1260 } |
| 1099 | 1261 |
| 1100 void test_finalNotInitialized_initializer() { | 1262 void test_finalNotInitialized_initializer() { |
| 1101 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 0 {}", "}"])); | 1263 Source source = addSource(r''' |
| 1264 class A { |
| 1265 final int x; |
| 1266 A() : x = 0 {} |
| 1267 }'''); |
| 1102 resolve(source); | 1268 resolve(source); |
| 1103 assertNoErrors(source); | 1269 assertNoErrors(source); |
| 1104 verify([source]); | 1270 verify([source]); |
| 1105 } | 1271 } |
| 1106 | 1272 |
| 1107 void test_finalNotInitialized_redirectingConstructor() { | 1273 void test_finalNotInitialized_redirectingConstructor() { |
| 1108 Source source = addSource(EngineTestCase.createSource([ | 1274 Source source = addSource(r''' |
| 1109 "class A {", | 1275 class A { |
| 1110 " final int x;", | 1276 final int x; |
| 1111 " A(this.x);", | 1277 A(this.x); |
| 1112 " A.named() : this (42);", | 1278 A.named() : this (42); |
| 1113 "}"])); | 1279 }'''); |
| 1114 resolve(source); | 1280 resolve(source); |
| 1115 assertNoErrors(source); | 1281 assertNoErrors(source); |
| 1116 verify([source]); | 1282 verify([source]); |
| 1117 } | 1283 } |
| 1118 | 1284 |
| 1119 void test_functionDeclaration_scope_returnType() { | 1285 void test_functionDeclaration_scope_returnType() { |
| 1120 Source source = addSource(EngineTestCase.createSource(["int f(int) { return
0; }"])); | 1286 Source source = addSource("int f(int) { return 0; }"); |
| 1121 resolve(source); | 1287 resolve(source); |
| 1122 assertNoErrors(source); | 1288 assertNoErrors(source); |
| 1123 verify([source]); | 1289 verify([source]); |
| 1124 } | 1290 } |
| 1125 | 1291 |
| 1126 void test_functionDeclaration_scope_signature() { | 1292 void test_functionDeclaration_scope_signature() { |
| 1127 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "f(
@app int app) {}"])); | 1293 Source source = addSource(r''' |
| 1294 const app = 0; |
| 1295 f(@app int app) {}'''); |
| 1128 resolve(source); | 1296 resolve(source); |
| 1129 assertNoErrors(source); | 1297 assertNoErrors(source); |
| 1130 verify([source]); | 1298 verify([source]); |
| 1131 } | 1299 } |
| 1132 | 1300 |
| 1133 void test_functionTypeAlias_scope_returnType() { | 1301 void test_functionTypeAlias_scope_returnType() { |
| 1134 Source source = addSource(EngineTestCase.createSource(["typedef int f(int);"
])); | 1302 Source source = addSource("typedef int f(int);"); |
| 1135 resolve(source); | 1303 resolve(source); |
| 1136 assertNoErrors(source); | 1304 assertNoErrors(source); |
| 1137 verify([source]); | 1305 verify([source]); |
| 1138 } | 1306 } |
| 1139 | 1307 |
| 1140 void test_functionTypeAlias_scope_signature() { | 1308 void test_functionTypeAlias_scope_signature() { |
| 1141 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "ty
pedef int f(@app int app);"])); | 1309 Source source = addSource(r''' |
| 1310 const app = 0; |
| 1311 typedef int f(@app int app);'''); |
| 1142 resolve(source); | 1312 resolve(source); |
| 1143 assertNoErrors(source); | 1313 assertNoErrors(source); |
| 1144 verify([source]); | 1314 verify([source]); |
| 1145 } | 1315 } |
| 1146 | 1316 |
| 1147 void test_functionWithoutCall() { | 1317 void test_functionWithoutCall() { |
| 1148 Source source = addSource(EngineTestCase.createSource([ | 1318 Source source = addSource(r''' |
| 1149 "abstract class A implements Function {", | 1319 abstract class A implements Function { |
| 1150 "}", | 1320 } |
| 1151 "class B implements A {", | 1321 class B implements A { |
| 1152 " void call() {}", | 1322 void call() {} |
| 1153 "}", | 1323 } |
| 1154 "class C extends A {", | 1324 class C extends A { |
| 1155 " void call() {}", | 1325 void call() {} |
| 1156 "}", | 1326 } |
| 1157 "class D extends C {", | 1327 class D extends C { |
| 1158 "}"])); | 1328 }'''); |
| 1159 resolve(source); | 1329 resolve(source); |
| 1160 assertNoErrors(source); | 1330 assertNoErrors(source); |
| 1161 verify([source]); | 1331 verify([source]); |
| 1162 } | 1332 } |
| 1163 | 1333 |
| 1164 void test_functionWithoutCall_doesNotImplementFunction() { | 1334 void test_functionWithoutCall_doesNotImplementFunction() { |
| 1165 Source source = addSource(EngineTestCase.createSource(["class A {}"])); | 1335 Source source = addSource("class A {}"); |
| 1166 resolve(source); | 1336 resolve(source); |
| 1167 assertNoErrors(source); | 1337 assertNoErrors(source); |
| 1168 verify([source]); | 1338 verify([source]); |
| 1169 } | 1339 } |
| 1170 | 1340 |
| 1171 void test_functionWithoutCall_withNoSuchMethod() { | 1341 void test_functionWithoutCall_withNoSuchMethod() { |
| 1172 // 16078 | 1342 // 16078 |
| 1173 Source source = addSource(EngineTestCase.createSource([ | 1343 Source source = addSource(r''' |
| 1174 "class A implements Function {", | 1344 class A implements Function { |
| 1175 " noSuchMethod(inv) {", | 1345 noSuchMethod(inv) { |
| 1176 " return 42;", | 1346 return 42; |
| 1177 " }", | 1347 } |
| 1178 "}"])); | 1348 }'''); |
| 1179 resolve(source); | 1349 resolve(source); |
| 1180 assertNoErrors(source); | 1350 assertNoErrors(source); |
| 1181 verify([source]); | 1351 verify([source]); |
| 1182 } | 1352 } |
| 1183 | 1353 |
| 1184 void test_implicitThisReferenceInInitializer_constructorName() { | 1354 void test_implicitThisReferenceInInitializer_constructorName() { |
| 1185 Source source = addSource(EngineTestCase.createSource([ | 1355 Source source = addSource(r''' |
| 1186 "class A {", | 1356 class A { |
| 1187 " A.named() {}", | 1357 A.named() {} |
| 1188 "}", | 1358 } |
| 1189 "class B {", | 1359 class B { |
| 1190 " var v;", | 1360 var v; |
| 1191 " B() : v = new A.named();", | 1361 B() : v = new A.named(); |
| 1192 "}"])); | 1362 }'''); |
| 1193 resolve(source); | 1363 resolve(source); |
| 1194 assertNoErrors(source); | 1364 assertNoErrors(source); |
| 1195 verify([source]); | 1365 verify([source]); |
| 1196 } | 1366 } |
| 1197 | 1367 |
| 1198 void test_implicitThisReferenceInInitializer_importPrefix() { | 1368 void test_implicitThisReferenceInInitializer_importPrefix() { |
| 1199 Source source = addSource(EngineTestCase.createSource([ | 1369 Source source = addSource(r''' |
| 1200 "import 'dart:async' as abstract;", | 1370 import 'dart:async' as abstract; |
| 1201 "class A {", | 1371 class A { |
| 1202 " var v = new abstract.Completer();", | 1372 var v = new abstract.Completer(); |
| 1203 "}"])); | 1373 }'''); |
| 1204 resolve(source); | 1374 resolve(source); |
| 1205 assertNoErrors(source); | 1375 assertNoErrors(source); |
| 1206 verify([source]); | 1376 verify([source]); |
| 1207 } | 1377 } |
| 1208 | 1378 |
| 1209 void test_implicitThisReferenceInInitializer_prefixedIdentifier() { | 1379 void test_implicitThisReferenceInInitializer_prefixedIdentifier() { |
| 1210 Source source = addSource(EngineTestCase.createSource([ | 1380 Source source = addSource(r''' |
| 1211 "class A {", | 1381 class A { |
| 1212 " var f;", | 1382 var f; |
| 1213 "}", | 1383 } |
| 1214 "class B {", | 1384 class B { |
| 1215 " var v;", | 1385 var v; |
| 1216 " B(A a) : v = a.f;", | 1386 B(A a) : v = a.f; |
| 1217 "}"])); | 1387 }'''); |
| 1218 resolve(source); | 1388 resolve(source); |
| 1219 assertNoErrors(source); | 1389 assertNoErrors(source); |
| 1220 verify([source]); | 1390 verify([source]); |
| 1221 } | 1391 } |
| 1222 | 1392 |
| 1223 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() { | 1393 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() { |
| 1224 Source source = addSource(EngineTestCase.createSource([ | 1394 Source source = addSource(r''' |
| 1225 "class A {", | 1395 class A { |
| 1226 " f() {}", | 1396 f() {} |
| 1227 "}", | 1397 } |
| 1228 "class B {", | 1398 class B { |
| 1229 " var v;", | 1399 var v; |
| 1230 " B() : v = new A().f();", | 1400 B() : v = new A().f(); |
| 1231 "}"])); | 1401 }'''); |
| 1232 resolve(source); | 1402 resolve(source); |
| 1233 assertNoErrors(source); | 1403 assertNoErrors(source); |
| 1234 verify([source]); | 1404 verify([source]); |
| 1235 } | 1405 } |
| 1236 | 1406 |
| 1237 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() { | 1407 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() { |
| 1238 Source source = addSource(EngineTestCase.createSource([ | 1408 Source source = addSource(r''' |
| 1239 "class A {", | 1409 class A { |
| 1240 " var f;", | 1410 var f; |
| 1241 "}", | 1411 } |
| 1242 "class B {", | 1412 class B { |
| 1243 " var v;", | 1413 var v; |
| 1244 " B() : v = new A().f;", | 1414 B() : v = new A().f; |
| 1245 "}"])); | 1415 }'''); |
| 1246 resolve(source); | 1416 resolve(source); |
| 1247 assertNoErrors(source); | 1417 assertNoErrors(source); |
| 1248 verify([source]); | 1418 verify([source]); |
| 1249 } | 1419 } |
| 1250 | 1420 |
| 1251 void test_implicitThisReferenceInInitializer_staticField_thisClass() { | 1421 void test_implicitThisReferenceInInitializer_staticField_thisClass() { |
| 1252 Source source = addSource(EngineTestCase.createSource([ | 1422 Source source = addSource(r''' |
| 1253 "class A {", | 1423 class A { |
| 1254 " var v;", | 1424 var v; |
| 1255 " A() : v = f;", | 1425 A() : v = f; |
| 1256 " static var f;", | 1426 static var f; |
| 1257 "}"])); | 1427 }'''); |
| 1258 resolve(source); | 1428 resolve(source); |
| 1259 assertNoErrors(source); | 1429 assertNoErrors(source); |
| 1260 verify([source]); | 1430 verify([source]); |
| 1261 } | 1431 } |
| 1262 | 1432 |
| 1263 void test_implicitThisReferenceInInitializer_staticGetter() { | 1433 void test_implicitThisReferenceInInitializer_staticGetter() { |
| 1264 Source source = addSource(EngineTestCase.createSource([ | 1434 Source source = addSource(r''' |
| 1265 "class A {", | 1435 class A { |
| 1266 " var v;", | 1436 var v; |
| 1267 " A() : v = f;", | 1437 A() : v = f; |
| 1268 " static get f => 42;", | 1438 static get f => 42; |
| 1269 "}"])); | 1439 }'''); |
| 1270 resolve(source); | 1440 resolve(source); |
| 1271 assertNoErrors(source); | 1441 assertNoErrors(source); |
| 1272 verify([source]); | 1442 verify([source]); |
| 1273 } | 1443 } |
| 1274 | 1444 |
| 1275 void test_implicitThisReferenceInInitializer_staticMethod() { | 1445 void test_implicitThisReferenceInInitializer_staticMethod() { |
| 1276 Source source = addSource(EngineTestCase.createSource([ | 1446 Source source = addSource(r''' |
| 1277 "class A {", | 1447 class A { |
| 1278 " var v;", | 1448 var v; |
| 1279 " A() : v = f();", | 1449 A() : v = f(); |
| 1280 " static f() => 42;", | 1450 static f() => 42; |
| 1281 "}"])); | 1451 }'''); |
| 1282 resolve(source); | 1452 resolve(source); |
| 1283 assertNoErrors(source); | 1453 assertNoErrors(source); |
| 1284 verify([source]); | 1454 verify([source]); |
| 1285 } | 1455 } |
| 1286 | 1456 |
| 1287 void test_implicitThisReferenceInInitializer_topLevelField() { | 1457 void test_implicitThisReferenceInInitializer_topLevelField() { |
| 1288 Source source = addSource(EngineTestCase.createSource([ | 1458 Source source = addSource(r''' |
| 1289 "class A {", | 1459 class A { |
| 1290 " var v;", | 1460 var v; |
| 1291 " A() : v = f;", | 1461 A() : v = f; |
| 1292 "}", | 1462 } |
| 1293 "var f = 42;"])); | 1463 var f = 42;'''); |
| 1294 resolve(source); | 1464 resolve(source); |
| 1295 assertNoErrors(source); | 1465 assertNoErrors(source); |
| 1296 verify([source]); | 1466 verify([source]); |
| 1297 } | 1467 } |
| 1298 | 1468 |
| 1299 void test_implicitThisReferenceInInitializer_topLevelFunction() { | 1469 void test_implicitThisReferenceInInitializer_topLevelFunction() { |
| 1300 Source source = addSource(EngineTestCase.createSource([ | 1470 Source source = addSource(r''' |
| 1301 "class A {", | 1471 class A { |
| 1302 " var v;", | 1472 var v; |
| 1303 " A() : v = f();", | 1473 A() : v = f(); |
| 1304 "}", | 1474 } |
| 1305 "f() => 42;"])); | 1475 f() => 42;'''); |
| 1306 resolve(source); | 1476 resolve(source); |
| 1307 assertNoErrors(source); | 1477 assertNoErrors(source); |
| 1308 verify([source]); | 1478 verify([source]); |
| 1309 } | 1479 } |
| 1310 | 1480 |
| 1311 void test_implicitThisReferenceInInitializer_topLevelGetter() { | 1481 void test_implicitThisReferenceInInitializer_topLevelGetter() { |
| 1312 Source source = addSource(EngineTestCase.createSource([ | 1482 Source source = addSource(r''' |
| 1313 "class A {", | 1483 class A { |
| 1314 " var v;", | 1484 var v; |
| 1315 " A() : v = f;", | 1485 A() : v = f; |
| 1316 "}", | 1486 } |
| 1317 "get f => 42;"])); | 1487 get f => 42;'''); |
| 1318 resolve(source); | 1488 resolve(source); |
| 1319 assertNoErrors(source); | 1489 assertNoErrors(source); |
| 1320 verify([source]); | 1490 verify([source]); |
| 1321 } | 1491 } |
| 1322 | 1492 |
| 1323 void test_implicitThisReferenceInInitializer_typeParameter() { | 1493 void test_implicitThisReferenceInInitializer_typeParameter() { |
| 1324 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va
r v;", " A(p) : v = (p is T);", "}"])); | 1494 Source source = addSource(r''' |
| 1495 class A<T> { |
| 1496 var v; |
| 1497 A(p) : v = (p is T); |
| 1498 }'''); |
| 1325 resolve(source); | 1499 resolve(source); |
| 1326 assertNoErrors(source); | 1500 assertNoErrors(source); |
| 1327 verify([source]); | 1501 verify([source]); |
| 1328 } | 1502 } |
| 1329 | 1503 |
| 1330 void test_importDuplicatedLibraryName() { | 1504 void test_importDuplicatedLibraryName() { |
| 1331 Source source = addSource(EngineTestCase.createSource([ | 1505 Source source = addSource(r''' |
| 1332 "library test;", | 1506 library test; |
| 1333 "import 'lib.dart';", | 1507 import 'lib.dart'; |
| 1334 "import 'lib.dart';"])); | 1508 import 'lib.dart';'''); |
| 1335 addNamedSource("/lib.dart", "library lib;"); | 1509 addNamedSource("/lib.dart", "library lib;"); |
| 1336 resolve(source); | 1510 resolve(source); |
| 1337 assertErrors(source, [ | 1511 assertErrors(source, [ |
| 1338 HintCode.UNUSED_IMPORT, | 1512 HintCode.UNUSED_IMPORT, |
| 1339 HintCode.UNUSED_IMPORT, | 1513 HintCode.UNUSED_IMPORT, |
| 1340 HintCode.DUPLICATE_IMPORT]); | 1514 HintCode.DUPLICATE_IMPORT]); |
| 1341 verify([source]); | 1515 verify([source]); |
| 1342 } | 1516 } |
| 1343 | 1517 |
| 1344 void test_importOfNonLibrary_libraryDeclared() { | 1518 void test_importOfNonLibrary_libraryDeclared() { |
| 1345 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 1519 Source source = addSource(r''' |
| 1346 addNamedSource("/part.dart", EngineTestCase.createSource(["library lib1;", "
class A {}"])); | 1520 library lib; |
| 1521 import 'part.dart'; |
| 1522 A a;'''); |
| 1523 addNamedSource("/part.dart", r''' |
| 1524 library lib1; |
| 1525 class A {}'''); |
| 1347 resolve(source); | 1526 resolve(source); |
| 1348 assertNoErrors(source); | 1527 assertNoErrors(source); |
| 1349 verify([source]); | 1528 verify([source]); |
| 1350 } | 1529 } |
| 1351 | 1530 |
| 1352 void test_importOfNonLibrary_libraryNotDeclared() { | 1531 void test_importOfNonLibrary_libraryNotDeclared() { |
| 1353 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 1532 Source source = addSource(r''' |
| 1354 addNamedSource("/part.dart", EngineTestCase.createSource(["class A {}"])); | 1533 library lib; |
| 1534 import 'part.dart'; |
| 1535 A a;'''); |
| 1536 addNamedSource("/part.dart", "class A {}"); |
| 1355 resolve(source); | 1537 resolve(source); |
| 1356 assertNoErrors(source); | 1538 assertNoErrors(source); |
| 1357 verify([source]); | 1539 verify([source]); |
| 1358 } | 1540 } |
| 1359 | 1541 |
| 1360 void test_importPrefixes_withFirstLetterDifference() { | 1542 void test_importPrefixes_withFirstLetterDifference() { |
| 1361 Source source = addSource(EngineTestCase.createSource([ | 1543 Source source = addSource(r''' |
| 1362 "library L;", | 1544 library L; |
| 1363 "import 'lib1.dart' as math;", | 1545 import 'lib1.dart' as math; |
| 1364 "import 'lib2.dart' as path;", | 1546 import 'lib2.dart' as path; |
| 1365 "main() {", | 1547 main() { |
| 1366 " math.test1();", | 1548 math.test1(); |
| 1367 " path.test2();", | 1549 path.test2(); |
| 1368 "}"])); | 1550 }'''); |
| 1369 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;", "
test1() {}"])); | 1551 addNamedSource("/lib1.dart", r''' |
| 1370 addNamedSource("/lib2.dart", EngineTestCase.createSource(["library lib2;", "
test2() {}"])); | 1552 library lib1; |
| 1553 test1() {}'''); |
| 1554 addNamedSource("/lib2.dart", r''' |
| 1555 library lib2; |
| 1556 test2() {}'''); |
| 1371 resolve(source); | 1557 resolve(source); |
| 1372 assertNoErrors(source); | 1558 assertNoErrors(source); |
| 1373 verify([source]); | 1559 verify([source]); |
| 1374 } | 1560 } |
| 1375 | 1561 |
| 1376 void test_inconsistentCaseExpressionTypes() { | 1562 void test_inconsistentCaseExpressionTypes() { |
| 1377 Source source = addSource(EngineTestCase.createSource([ | 1563 Source source = addSource(r''' |
| 1378 "f(var p) {", | 1564 f(var p) { |
| 1379 " switch (p) {", | 1565 switch (p) { |
| 1380 " case 1:", | 1566 case 1: |
| 1381 " break;", | 1567 break; |
| 1382 " case 2:", | 1568 case 2: |
| 1383 " break;", | 1569 break; |
| 1384 " }", | 1570 } |
| 1385 "}"])); | 1571 }'''); |
| 1386 resolve(source); | 1572 resolve(source); |
| 1387 assertNoErrors(source); | 1573 assertNoErrors(source); |
| 1388 verify([source]); | 1574 verify([source]); |
| 1389 } | 1575 } |
| 1390 | 1576 |
| 1391 void test_inconsistentMethodInheritance_accessors_typeParameter2() { | 1577 void test_inconsistentMethodInheritance_accessors_typeParameter2() { |
| 1392 Source source = addSource(EngineTestCase.createSource([ | 1578 Source source = addSource(r''' |
| 1393 "abstract class A<E> {", | 1579 abstract class A<E> { |
| 1394 " E get x {return null;}", | 1580 E get x {return null;} |
| 1395 "}", | 1581 } |
| 1396 "class B<E> {", | 1582 class B<E> { |
| 1397 " E get x {return null;}", | 1583 E get x {return null;} |
| 1398 "}", | 1584 } |
| 1399 "class C<E> extends A<E> implements B<E> {}"])); | 1585 class C<E> extends A<E> implements B<E> {}'''); |
| 1400 resolve(source); | 1586 resolve(source); |
| 1401 assertNoErrors(source); | 1587 assertNoErrors(source); |
| 1402 verify([source]); | 1588 verify([source]); |
| 1403 } | 1589 } |
| 1404 | 1590 |
| 1405 void test_inconsistentMethodInheritance_accessors_typeParameters_diamond() { | 1591 void test_inconsistentMethodInheritance_accessors_typeParameters_diamond() { |
| 1406 Source source = addSource(EngineTestCase.createSource([ | 1592 Source source = addSource(r''' |
| 1407 "abstract class F<E> extends B<E> {}", | 1593 abstract class F<E> extends B<E> {} |
| 1408 "class D<E> extends F<E> {", | 1594 class D<E> extends F<E> { |
| 1409 " external E get g;", | 1595 external E get g; |
| 1410 "}", | 1596 } |
| 1411 "abstract class C<E> {", | 1597 abstract class C<E> { |
| 1412 " E get g;", | 1598 E get g; |
| 1413 "}", | 1599 } |
| 1414 "abstract class B<E> implements C<E> {", | 1600 abstract class B<E> implements C<E> { |
| 1415 " E get g { return null; }", | 1601 E get g { return null; } |
| 1416 "}", | 1602 } |
| 1417 "class A<E> extends B<E> implements D<E> {", | 1603 class A<E> extends B<E> implements D<E> { |
| 1418 "}"])); | 1604 }'''); |
| 1419 resolve(source); | 1605 resolve(source); |
| 1420 assertNoErrors(source); | 1606 assertNoErrors(source); |
| 1421 verify([source]); | 1607 verify([source]); |
| 1422 } | 1608 } |
| 1423 | 1609 |
| 1424 void test_inconsistentMethodInheritance_accessors_typeParameters1() { | 1610 void test_inconsistentMethodInheritance_accessors_typeParameters1() { |
| 1425 Source source = addSource(EngineTestCase.createSource([ | 1611 Source source = addSource(r''' |
| 1426 "abstract class A<E> {", | 1612 abstract class A<E> { |
| 1427 " E get x;", | 1613 E get x; |
| 1428 "}", | 1614 } |
| 1429 "abstract class B<E> {", | 1615 abstract class B<E> { |
| 1430 " E get x;", | 1616 E get x; |
| 1431 "}", | 1617 } |
| 1432 "class C<E> implements A<E>, B<E> {", | 1618 class C<E> implements A<E>, B<E> { |
| 1433 " E get x => null;", | 1619 E get x => null; |
| 1434 "}"])); | 1620 }'''); |
| 1435 resolve(source); | 1621 resolve(source); |
| 1436 assertNoErrors(source); | 1622 assertNoErrors(source); |
| 1437 verify([source]); | 1623 verify([source]); |
| 1438 } | 1624 } |
| 1439 | 1625 |
| 1440 void test_inconsistentMethodInheritance_methods_typeParameter2() { | 1626 void test_inconsistentMethodInheritance_methods_typeParameter2() { |
| 1441 Source source = addSource(EngineTestCase.createSource([ | 1627 Source source = addSource(r''' |
| 1442 "class A<E> {", | 1628 class A<E> { |
| 1443 " x(E e) {}", | 1629 x(E e) {} |
| 1444 "}", | 1630 } |
| 1445 "class B<E> {", | 1631 class B<E> { |
| 1446 " x(E e) {}", | 1632 x(E e) {} |
| 1447 "}", | 1633 } |
| 1448 "class C<E> extends A<E> implements B<E> {", | 1634 class C<E> extends A<E> implements B<E> { |
| 1449 " x(E e) {}", | 1635 x(E e) {} |
| 1450 "}"])); | 1636 }'''); |
| 1451 resolve(source); | 1637 resolve(source); |
| 1452 assertNoErrors(source); | 1638 assertNoErrors(source); |
| 1453 verify([source]); | 1639 verify([source]); |
| 1454 } | 1640 } |
| 1455 | 1641 |
| 1456 void test_inconsistentMethodInheritance_methods_typeParameters1() { | 1642 void test_inconsistentMethodInheritance_methods_typeParameters1() { |
| 1457 Source source = addSource(EngineTestCase.createSource([ | 1643 Source source = addSource(r''' |
| 1458 "class A<E> {", | 1644 class A<E> { |
| 1459 " x(E e) {}", | 1645 x(E e) {} |
| 1460 "}", | 1646 } |
| 1461 "class B<E> {", | 1647 class B<E> { |
| 1462 " x(E e) {}", | 1648 x(E e) {} |
| 1463 "}", | 1649 } |
| 1464 "class C<E> implements A<E>, B<E> {", | 1650 class C<E> implements A<E>, B<E> { |
| 1465 " x(E e) {}", | 1651 x(E e) {} |
| 1466 "}"])); | 1652 }'''); |
| 1467 resolve(source); | 1653 resolve(source); |
| 1468 assertNoErrors(source); | 1654 assertNoErrors(source); |
| 1469 verify([source]); | 1655 verify([source]); |
| 1470 } | 1656 } |
| 1471 | 1657 |
| 1472 void test_inconsistentMethodInheritance_overrideTrumpsInherits_getter() { | 1658 void test_inconsistentMethodInheritance_overrideTrumpsInherits_getter() { |
| 1473 // 16134 | 1659 // 16134 |
| 1474 Source source = addSource(EngineTestCase.createSource([ | 1660 Source source = addSource(r''' |
| 1475 "class B<S> {", | 1661 class B<S> { |
| 1476 " S get g => null;", | 1662 S get g => null; |
| 1477 "}", | 1663 } |
| 1478 "abstract class I<U> {", | 1664 abstract class I<U> { |
| 1479 " U get g => null;", | 1665 U get g => null; |
| 1480 "}", | 1666 } |
| 1481 "class C extends B<double> implements I<int> {", | 1667 class C extends B<double> implements I<int> { |
| 1482 " num get g => null;", | 1668 num get g => null; |
| 1483 "}"])); | 1669 }'''); |
| 1484 resolve(source); | 1670 resolve(source); |
| 1485 assertNoErrors(source); | 1671 assertNoErrors(source); |
| 1486 verify([source]); | 1672 verify([source]); |
| 1487 } | 1673 } |
| 1488 | 1674 |
| 1489 void test_inconsistentMethodInheritance_overrideTrumpsInherits_method() { | 1675 void test_inconsistentMethodInheritance_overrideTrumpsInherits_method() { |
| 1490 // 16134 | 1676 // 16134 |
| 1491 Source source = addSource(EngineTestCase.createSource([ | 1677 Source source = addSource(r''' |
| 1492 "class B<S> {", | 1678 class B<S> { |
| 1493 " m(S s) => null;", | 1679 m(S s) => null; |
| 1494 "}", | 1680 } |
| 1495 "abstract class I<U> {", | 1681 abstract class I<U> { |
| 1496 " m(U u) => null;", | 1682 m(U u) => null; |
| 1497 "}", | 1683 } |
| 1498 "class C extends B<double> implements I<int> {", | 1684 class C extends B<double> implements I<int> { |
| 1499 " m(num n) => null;", | 1685 m(num n) => null; |
| 1500 "}"])); | 1686 }'''); |
| 1501 resolve(source); | 1687 resolve(source); |
| 1502 assertNoErrors(source); | 1688 assertNoErrors(source); |
| 1503 verify([source]); | 1689 verify([source]); |
| 1504 } | 1690 } |
| 1505 | 1691 |
| 1506 void test_inconsistentMethodInheritance_overrideTrumpsInherits_setter() { | 1692 void test_inconsistentMethodInheritance_overrideTrumpsInherits_setter() { |
| 1507 // 16134 | 1693 // 16134 |
| 1508 Source source = addSource(EngineTestCase.createSource([ | 1694 Source source = addSource(r''' |
| 1509 "class B<S> {", | 1695 class B<S> { |
| 1510 " set t(S s) {}", | 1696 set t(S s) {} |
| 1511 "}", | 1697 } |
| 1512 "abstract class I<U> {", | 1698 abstract class I<U> { |
| 1513 " set t(U u) {}", | 1699 set t(U u) {} |
| 1514 "}", | 1700 } |
| 1515 "class C extends B<double> implements I<int> {", | 1701 class C extends B<double> implements I<int> { |
| 1516 " set t(num n) {}", | 1702 set t(num n) {} |
| 1517 "}"])); | 1703 }'''); |
| 1518 resolve(source); | 1704 resolve(source); |
| 1519 assertNoErrors(source); | 1705 assertNoErrors(source); |
| 1520 verify([source]); | 1706 verify([source]); |
| 1521 } | 1707 } |
| 1522 | 1708 |
| 1523 void test_inconsistentMethodInheritance_simple() { | 1709 void test_inconsistentMethodInheritance_simple() { |
| 1524 Source source = addSource(EngineTestCase.createSource([ | 1710 Source source = addSource(r''' |
| 1525 "abstract class A {", | 1711 abstract class A { |
| 1526 " x();", | 1712 x(); |
| 1527 "}", | 1713 } |
| 1528 "abstract class B {", | 1714 abstract class B { |
| 1529 " x();", | 1715 x(); |
| 1530 "}", | 1716 } |
| 1531 "class C implements A, B {", | 1717 class C implements A, B { |
| 1532 " x() {}", | 1718 x() {} |
| 1533 "}"])); | 1719 }'''); |
| 1534 resolve(source); | 1720 resolve(source); |
| 1535 assertNoErrors(source); | 1721 assertNoErrors(source); |
| 1536 verify([source]); | 1722 verify([source]); |
| 1537 } | 1723 } |
| 1538 | 1724 |
| 1539 void test_initializingFormalForNonExistentField() { | 1725 void test_initializingFormalForNonExistentField() { |
| 1540 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 1726 Source source = addSource(r''' |
| 1727 class A { |
| 1728 int x; |
| 1729 A(this.x) {} |
| 1730 }'''); |
| 1541 resolve(source); | 1731 resolve(source); |
| 1542 assertNoErrors(source); | 1732 assertNoErrors(source); |
| 1543 verify([source]); | 1733 verify([source]); |
| 1544 } | 1734 } |
| 1545 | 1735 |
| 1546 void test_instanceAccessToStaticMember_fromComment() { | 1736 void test_instanceAccessToStaticMember_fromComment() { |
| 1547 Source source = addSource(EngineTestCase.createSource([ | 1737 Source source = addSource(r''' |
| 1548 "class A {", | 1738 class A { |
| 1549 " static m() {}", | 1739 static m() {} |
| 1550 "}", | 1740 } |
| 1551 "/// [A.m]", | 1741 /// [A.m] |
| 1552 "main() {", | 1742 main() { |
| 1553 "}"])); | 1743 }'''); |
| 1554 resolve(source); | 1744 resolve(source); |
| 1555 assertNoErrors(source); | 1745 assertNoErrors(source); |
| 1556 verify([source]); | 1746 verify([source]); |
| 1557 } | 1747 } |
| 1558 | 1748 |
| 1559 void test_instanceAccessToStaticMember_topLevel() { | 1749 void test_instanceAccessToStaticMember_topLevel() { |
| 1560 Source source = addSource(EngineTestCase.createSource(["m() {}", "main() {",
" m();", "}"])); | 1750 Source source = addSource(r''' |
| 1751 m() {} |
| 1752 main() { |
| 1753 m(); |
| 1754 }'''); |
| 1561 resolve(source); | 1755 resolve(source); |
| 1562 assertNoErrors(source); | 1756 assertNoErrors(source); |
| 1563 verify([source]); | 1757 verify([source]); |
| 1564 } | 1758 } |
| 1565 | 1759 |
| 1566 void test_instanceMemberAccessFromStatic_fromComment() { | 1760 void test_instanceMemberAccessFromStatic_fromComment() { |
| 1567 Source source = addSource(EngineTestCase.createSource([ | 1761 Source source = addSource(r''' |
| 1568 "class A {", | 1762 class A { |
| 1569 " m() {}", | 1763 m() {} |
| 1570 " /// [m]", | 1764 /// [m] |
| 1571 " static foo() {", | 1765 static foo() { |
| 1572 " }", | 1766 } |
| 1573 "}"])); | 1767 }'''); |
| 1574 resolve(source); | 1768 resolve(source); |
| 1575 assertNoErrors(source); | 1769 assertNoErrors(source); |
| 1576 verify([source]); | 1770 verify([source]); |
| 1577 } | 1771 } |
| 1578 | 1772 |
| 1579 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { | 1773 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { |
| 1580 Source source = addSource(EngineTestCase.createSource([ | 1774 Source source = addSource(r''' |
| 1581 "import 'lib.dart';", | 1775 import 'lib.dart'; |
| 1582 "class B extends A {", | 1776 class B extends A { |
| 1583 " _m() {}", | 1777 _m() {} |
| 1584 "}"])); | 1778 }'''); |
| 1585 addNamedSource("/lib.dart", EngineTestCase.createSource(["library L;", "clas
s A {", " static var _m;", "}"])); | 1779 addNamedSource("/lib.dart", r''' |
| 1780 library L; |
| 1781 class A { |
| 1782 static var _m; |
| 1783 }'''); |
| 1586 resolve(source); | 1784 resolve(source); |
| 1587 assertNoErrors(source); | 1785 assertNoErrors(source); |
| 1588 verify([source]); | 1786 verify([source]); |
| 1589 } | 1787 } |
| 1590 | 1788 |
| 1591 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { | 1789 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { |
| 1592 Source source = addSource(EngineTestCase.createSource([ | 1790 Source source = addSource(r''' |
| 1593 "import 'lib.dart';", | 1791 import 'lib.dart'; |
| 1594 "class B extends A {", | 1792 class B extends A { |
| 1595 " _m() {}", | 1793 _m() {} |
| 1596 "}"])); | 1794 }'''); |
| 1597 addNamedSource("/lib.dart", EngineTestCase.createSource(["library L;", "clas
s A {", " static _m() {}", "}"])); | 1795 addNamedSource("/lib.dart", r''' |
| 1796 library L; |
| 1797 class A { |
| 1798 static _m() {} |
| 1799 }'''); |
| 1598 resolve(source); | 1800 resolve(source); |
| 1599 assertErrors(source, []); | 1801 assertErrors(source, []); |
| 1600 verify([source]); | 1802 verify([source]); |
| 1601 } | 1803 } |
| 1602 | 1804 |
| 1603 void test_invalidAnnotation_constantVariable_field() { | 1805 void test_invalidAnnotation_constantVariable_field() { |
| 1604 Source source = addSource(EngineTestCase.createSource(["@A.C", "class A {",
" static const C = 0;", "}"])); | 1806 Source source = addSource(r''' |
| 1807 @A.C |
| 1808 class A { |
| 1809 static const C = 0; |
| 1810 }'''); |
| 1605 resolve(source); | 1811 resolve(source); |
| 1606 assertNoErrors(source); | 1812 assertNoErrors(source); |
| 1607 verify([source]); | 1813 verify([source]); |
| 1608 } | 1814 } |
| 1609 | 1815 |
| 1610 void test_invalidAnnotation_constantVariable_field_importWithPrefix() { | 1816 void test_invalidAnnotation_constantVariable_field_importWithPrefix() { |
| 1611 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "cl
ass A {", " static const C = 0;", "}"])); | 1817 addNamedSource("/lib.dart", r''' |
| 1612 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.A.C", "main() {", "}"])); | 1818 library lib; |
| 1819 class A { |
| 1820 static const C = 0; |
| 1821 }'''); |
| 1822 Source source = addSource(r''' |
| 1823 import 'lib.dart' as p; |
| 1824 @p.A.C |
| 1825 main() { |
| 1826 }'''); |
| 1613 resolve(source); | 1827 resolve(source); |
| 1614 assertNoErrors(source); | 1828 assertNoErrors(source); |
| 1615 verify([source]); | 1829 verify([source]); |
| 1616 } | 1830 } |
| 1617 | 1831 |
| 1618 void test_invalidAnnotation_constantVariable_topLevel() { | 1832 void test_invalidAnnotation_constantVariable_topLevel() { |
| 1619 Source source = addSource(EngineTestCase.createSource(["const C = 0;", "@C",
"main() {", "}"])); | 1833 Source source = addSource(r''' |
| 1834 const C = 0; |
| 1835 @C |
| 1836 main() { |
| 1837 }'''); |
| 1620 resolve(source); | 1838 resolve(source); |
| 1621 assertNoErrors(source); | 1839 assertNoErrors(source); |
| 1622 verify([source]); | 1840 verify([source]); |
| 1623 } | 1841 } |
| 1624 | 1842 |
| 1625 void test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() { | 1843 void test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() { |
| 1626 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "co
nst C = 0;"])); | 1844 addNamedSource("/lib.dart", r''' |
| 1627 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.C", "main() {", "}"])); | 1845 library lib; |
| 1846 const C = 0;'''); |
| 1847 Source source = addSource(r''' |
| 1848 import 'lib.dart' as p; |
| 1849 @p.C |
| 1850 main() { |
| 1851 }'''); |
| 1628 resolve(source); | 1852 resolve(source); |
| 1629 assertNoErrors(source); | 1853 assertNoErrors(source); |
| 1630 verify([source]); | 1854 verify([source]); |
| 1631 } | 1855 } |
| 1632 | 1856 |
| 1633 void test_invalidAnnotation_constConstructor_importWithPrefix() { | 1857 void test_invalidAnnotation_constConstructor_importWithPrefix() { |
| 1634 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "cl
ass A {", " const A(int p);", "}"])); | 1858 addNamedSource("/lib.dart", r''' |
| 1635 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.A(42)", "main() {", "}"])); | 1859 library lib; |
| 1860 class A { |
| 1861 const A(int p); |
| 1862 }'''); |
| 1863 Source source = addSource(r''' |
| 1864 import 'lib.dart' as p; |
| 1865 @p.A(42) |
| 1866 main() { |
| 1867 }'''); |
| 1636 resolve(source); | 1868 resolve(source); |
| 1637 assertNoErrors(source); | 1869 assertNoErrors(source); |
| 1638 verify([source]); | 1870 verify([source]); |
| 1639 } | 1871 } |
| 1640 | 1872 |
| 1641 void test_invalidAnnotation_constConstructor_named_importWithPrefix() { | 1873 void test_invalidAnnotation_constConstructor_named_importWithPrefix() { |
| 1642 addNamedSource("/lib.dart", EngineTestCase.createSource([ | 1874 addNamedSource("/lib.dart", r''' |
| 1643 "library lib;", | 1875 library lib; |
| 1644 "class A {", | 1876 class A { |
| 1645 " const A.named(int p);", | 1877 const A.named(int p); |
| 1646 "}"])); | 1878 }'''); |
| 1647 Source source = addSource(EngineTestCase.createSource([ | 1879 Source source = addSource(r''' |
| 1648 "import 'lib.dart' as p;", | 1880 import 'lib.dart' as p; |
| 1649 "@p.A.named(42)", | 1881 @p.A.named(42) |
| 1650 "main() {", | 1882 main() { |
| 1651 "}"])); | 1883 }'''); |
| 1652 resolve(source); | 1884 resolve(source); |
| 1653 assertNoErrors(source); | 1885 assertNoErrors(source); |
| 1654 verify([source]); | 1886 verify([source]); |
| 1655 } | 1887 } |
| 1656 | 1888 |
| 1657 void test_invalidAssignment() { | 1889 void test_invalidAssignment() { |
| 1658 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;",
" var y;", " x = y;", "}"])); | 1890 Source source = addSource(r''' |
| 1891 f() { |
| 1892 var x; |
| 1893 var y; |
| 1894 x = y; |
| 1895 }'''); |
| 1659 resolve(source); | 1896 resolve(source); |
| 1660 assertNoErrors(source); | 1897 assertNoErrors(source); |
| 1661 verify([source]); | 1898 verify([source]); |
| 1662 } | 1899 } |
| 1663 | 1900 |
| 1664 void test_invalidAssignment_compoundAssignment() { | 1901 void test_invalidAssignment_compoundAssignment() { |
| 1665 Source source = addSource(EngineTestCase.createSource([ | 1902 Source source = addSource(r''' |
| 1666 "class byte {", | 1903 class byte { |
| 1667 " int _value;", | 1904 int _value; |
| 1668 " byte(this._value);", | 1905 byte(this._value); |
| 1669 " byte operator +(int val) { return this; }", | 1906 byte operator +(int val) { return this; } |
| 1670 "}", | 1907 } |
| 1671 "", | 1908 |
| 1672 "void main() {", | 1909 void main() { |
| 1673 " byte b = new byte(52);", | 1910 byte b = new byte(52); |
| 1674 " b += 3;", | 1911 b += 3; |
| 1675 "}"])); | 1912 }'''); |
| 1676 resolve(source); | 1913 resolve(source); |
| 1677 assertNoErrors(source); | 1914 assertNoErrors(source); |
| 1678 verify([source]); | 1915 verify([source]); |
| 1679 } | 1916 } |
| 1680 | 1917 |
| 1681 void test_invalidAssignment_defaultValue_named() { | 1918 void test_invalidAssignment_defaultValue_named() { |
| 1682 Source source = addSource(EngineTestCase.createSource(["f({String x: '0'}) {
", "}"])); | 1919 Source source = addSource(r''' |
| 1920 f({String x: '0'}) { |
| 1921 }'''); |
| 1683 resolve(source); | 1922 resolve(source); |
| 1684 assertNoErrors(source); | 1923 assertNoErrors(source); |
| 1685 verify([source]); | 1924 verify([source]); |
| 1686 } | 1925 } |
| 1687 | 1926 |
| 1688 void test_invalidAssignment_defaultValue_optional() { | 1927 void test_invalidAssignment_defaultValue_optional() { |
| 1689 Source source = addSource(EngineTestCase.createSource(["f([String x = '0'])
{", "}"])); | 1928 Source source = addSource(r''' |
| 1690 resolve(source); | 1929 f([String x = '0']) { |
| 1691 assertNoErrors(source); | 1930 }'''); |
| 1692 verify([source]); | 1931 resolve(source); |
| 1932 assertNoErrors(source); |
| 1933 verify([source]); |
| 1693 } | 1934 } |
| 1694 | 1935 |
| 1695 void test_invalidAssignment_implicitlyImplementFunctionViaCall_1() { | 1936 void test_invalidAssignment_implicitlyImplementFunctionViaCall_1() { |
| 1696 // 18341 | 1937 // 18341 |
| 1697 // | 1938 // |
| 1698 // This test and 'test_invalidAssignment_implicitlyImplementFunctionViaCall_
2()' | 1939 // This test and 'test_invalidAssignment_implicitlyImplementFunctionViaCall_
2()' |
| 1699 // are closely related: here we see that 'I' checks as a subtype of 'IntToIn
t'. | 1940 // are closely related: here we see that 'I' checks as a subtype of 'IntToIn
t'. |
| 1700 Source source = addSource(EngineTestCase.createSource([ | 1941 Source source = addSource(r''' |
| 1701 "class I {", | 1942 class I { |
| 1702 " int call(int x) => 0;", | 1943 int call(int x) => 0; |
| 1703 "}", | 1944 } |
| 1704 "class C implements I {", | 1945 class C implements I { |
| 1705 " noSuchMethod(_) => null;", | 1946 noSuchMethod(_) => null; |
| 1706 "}", | 1947 } |
| 1707 "typedef int IntToInt(int x);", | 1948 typedef int IntToInt(int x); |
| 1708 "IntToInt f = new I();"])); | 1949 IntToInt f = new I();'''); |
| 1709 resolve(source); | 1950 resolve(source); |
| 1710 assertNoErrors(source); | 1951 assertNoErrors(source); |
| 1711 verify([source]); | 1952 verify([source]); |
| 1712 } | 1953 } |
| 1713 | 1954 |
| 1714 void test_invalidAssignment_implicitlyImplementFunctionViaCall_2() { | 1955 void test_invalidAssignment_implicitlyImplementFunctionViaCall_2() { |
| 1715 // 18341 | 1956 // 18341 |
| 1716 // | 1957 // |
| 1717 // Here 'C' checks as a subtype of 'I', but 'C' does not | 1958 // Here 'C' checks as a subtype of 'I', but 'C' does not |
| 1718 // check as a subtype of 'IntToInt'. Together with | 1959 // check as a subtype of 'IntToInt'. Together with |
| 1719 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_1()' we see | 1960 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_1()' we see |
| 1720 // that subtyping is not transitive here. | 1961 // that subtyping is not transitive here. |
| 1721 Source source = addSource(EngineTestCase.createSource([ | 1962 Source source = addSource(r''' |
| 1722 "class I {", | 1963 class I { |
| 1723 " int call(int x) => 0;", | 1964 int call(int x) => 0; |
| 1724 "}", | 1965 } |
| 1725 "class C implements I {", | 1966 class C implements I { |
| 1726 " noSuchMethod(_) => null;", | 1967 noSuchMethod(_) => null; |
| 1727 "}", | 1968 } |
| 1728 "typedef int IntToInt(int x);", | 1969 typedef int IntToInt(int x); |
| 1729 "IntToInt f = new C();"])); | 1970 IntToInt f = new C();'''); |
| 1730 resolve(source); | 1971 resolve(source); |
| 1731 assertNoErrors(source); | 1972 assertNoErrors(source); |
| 1732 verify([source]); | 1973 verify([source]); |
| 1733 } | 1974 } |
| 1734 | 1975 |
| 1735 void test_invalidAssignment_implicitlyImplementFunctionViaCall_3() { | 1976 void test_invalidAssignment_implicitlyImplementFunctionViaCall_3() { |
| 1736 // 18341 | 1977 // 18341 |
| 1737 // | 1978 // |
| 1738 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()', | 1979 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()', |
| 1739 // but uses type 'Function' instead of more precise type 'IntToInt' for 'f'. | 1980 // but uses type 'Function' instead of more precise type 'IntToInt' for 'f'. |
| 1740 Source source = addSource(EngineTestCase.createSource([ | 1981 Source source = addSource(r''' |
| 1741 "class I {", | 1982 class I { |
| 1742 " int call(int x) => 0;", | 1983 int call(int x) => 0; |
| 1743 "}", | 1984 } |
| 1744 "class C implements I {", | 1985 class C implements I { |
| 1745 " noSuchMethod(_) => null;", | 1986 noSuchMethod(_) => null; |
| 1746 "}", | 1987 } |
| 1747 "typedef int IntToInt(int x);", | 1988 typedef int IntToInt(int x); |
| 1748 "Function f = new C();"])); | 1989 Function f = new C();'''); |
| 1749 resolve(source); | 1990 resolve(source); |
| 1750 assertNoErrors(source); | 1991 assertNoErrors(source); |
| 1751 verify([source]); | 1992 verify([source]); |
| 1752 } | 1993 } |
| 1753 | 1994 |
| 1754 void test_invalidAssignment_implicitlyImplementFunctionViaCall_4() { | 1995 void test_invalidAssignment_implicitlyImplementFunctionViaCall_4() { |
| 1755 // 18341 | 1996 // 18341 |
| 1756 // | 1997 // |
| 1757 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()', | 1998 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()', |
| 1758 // but uses type 'VoidToInt' instead of more precise type 'IntToInt' for 'f'
. | 1999 // but uses type 'VoidToInt' instead of more precise type 'IntToInt' for 'f'
. |
| 1759 // | 2000 // |
| 1760 // Here 'C <: IntToInt <: VoidToInt', but the spec gives no transitivity rul
e | 2001 // Here 'C <: IntToInt <: VoidToInt', but the spec gives no transitivity rul
e |
| 1761 // for '<:'. However, many of the :/tools/test.py tests assume this transiti
vity | 2002 // for '<:'. However, many of the :/tools/test.py tests assume this transiti
vity |
| 1762 // for 'JsBuilder' objects, assigning them to '(String) -> dynamic'. The dec
lared type of | 2003 // for 'JsBuilder' objects, assigning them to '(String) -> dynamic'. The dec
lared type of |
| 1763 // 'JsBuilder.call' is '(String, [dynamic]) -> Expression'. | 2004 // 'JsBuilder.call' is '(String, [dynamic]) -> Expression'. |
| 1764 Source source = addSource(EngineTestCase.createSource([ | 2005 Source source = addSource(r''' |
| 1765 "class I {", | 2006 class I { |
| 1766 " int call([int x]) => 0;", | 2007 int call([int x]) => 0; |
| 1767 "}", | 2008 } |
| 1768 "class C implements I {", | 2009 class C implements I { |
| 1769 " noSuchMethod(_) => null;", | 2010 noSuchMethod(_) => null; |
| 1770 "}", | 2011 } |
| 1771 "typedef int VoidToInt();", | 2012 typedef int VoidToInt(); |
| 1772 "VoidToInt f = new C();"])); | 2013 VoidToInt f = new C();'''); |
| 1773 resolve(source); | 2014 resolve(source); |
| 1774 assertNoErrors(source); | 2015 assertNoErrors(source); |
| 1775 verify([source]); | 2016 verify([source]); |
| 1776 } | 2017 } |
| 1777 | 2018 |
| 1778 void test_invalidAssignment_toDynamic() { | 2019 void test_invalidAssignment_toDynamic() { |
| 1779 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g = () => 0;", "}"])); | 2020 Source source = addSource(r''' |
| 2021 f() { |
| 2022 var g; |
| 2023 g = () => 0; |
| 2024 }'''); |
| 1780 resolve(source); | 2025 resolve(source); |
| 1781 assertNoErrors(source); | 2026 assertNoErrors(source); |
| 1782 verify([source]); | 2027 verify([source]); |
| 1783 } | 2028 } |
| 1784 | 2029 |
| 1785 void test_invalidFactoryNameNotAClass() { | 2030 void test_invalidFactoryNameNotAClass() { |
| 1786 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() {}", "}"])); | 2031 Source source = addSource(r''' |
| 2032 class A { |
| 2033 factory A() {} |
| 2034 }'''); |
| 1787 resolve(source); | 2035 resolve(source); |
| 1788 assertNoErrors(source); | 2036 assertNoErrors(source); |
| 1789 verify([source]); | 2037 verify([source]); |
| 1790 } | 2038 } |
| 1791 | 2039 |
| 1792 void test_invalidIdentifierInAsync() { | 2040 void test_invalidIdentifierInAsync() { |
| 1793 Source source = addSource(EngineTestCase.createSource([ | 2041 Source source = addSource(r''' |
| 1794 "class A {", | 2042 class A { |
| 1795 " m() {", | 2043 m() { |
| 1796 " int async;", | 2044 int async; |
| 1797 " int await;", | 2045 int await; |
| 1798 " int yield;", | 2046 int yield; |
| 1799 " }", | 2047 } |
| 1800 "}"])); | 2048 }'''); |
| 1801 resolve(source); | 2049 resolve(source); |
| 1802 assertNoErrors(source); | 2050 assertNoErrors(source); |
| 1803 verify([source]); | 2051 verify([source]); |
| 1804 } | 2052 } |
| 1805 | 2053 |
| 1806 void test_invalidMethodOverrideNamedParamType() { | 2054 void test_invalidMethodOverrideNamedParamType() { |
| 1807 Source source = addSource(EngineTestCase.createSource([ | 2055 Source source = addSource(r''' |
| 1808 "class A {", | 2056 class A { |
| 1809 " m({int a}) {}", | 2057 m({int a}) {} |
| 1810 "}", | 2058 } |
| 1811 "class B implements A {", | 2059 class B implements A { |
| 1812 " m({int a, int b}) {}", | 2060 m({int a, int b}) {} |
| 1813 "}"])); | 2061 }'''); |
| 1814 resolve(source); | 2062 resolve(source); |
| 1815 assertNoErrors(source); | 2063 assertNoErrors(source); |
| 1816 verify([source]); | 2064 verify([source]); |
| 1817 } | 2065 } |
| 1818 | 2066 |
| 1819 void test_invalidOverrideDifferentDefaultValues_named() { | 2067 void test_invalidOverrideDifferentDefaultValues_named() { |
| 1820 Source source = addSource(EngineTestCase.createSource([ | 2068 Source source = addSource(r''' |
| 1821 "class A {", | 2069 class A { |
| 1822 " m({int p : 0}) {}", | 2070 m({int p : 0}) {} |
| 1823 "}", | 2071 } |
| 1824 "class B extends A {", | 2072 class B extends A { |
| 1825 " m({int p : 0}) {}", | 2073 m({int p : 0}) {} |
| 1826 "}"])); | 2074 }'''); |
| 1827 resolve(source); | 2075 resolve(source); |
| 1828 assertNoErrors(source); | 2076 assertNoErrors(source); |
| 1829 verify([source]); | 2077 verify([source]); |
| 1830 } | 2078 } |
| 1831 | 2079 |
| 1832 void test_invalidOverrideDifferentDefaultValues_named_function() { | 2080 void test_invalidOverrideDifferentDefaultValues_named_function() { |
| 1833 Source source = addSource(EngineTestCase.createSource([ | 2081 Source source = addSource(r''' |
| 1834 "nothing() => 'nothing';", | 2082 nothing() => 'nothing'; |
| 1835 "class A {", | 2083 class A { |
| 1836 " thing(String a, {orElse : nothing}) {}", | 2084 thing(String a, {orElse : nothing}) {} |
| 1837 "}", | 2085 } |
| 1838 "class B extends A {", | 2086 class B extends A { |
| 1839 " thing(String a, {orElse : nothing}) {}", | 2087 thing(String a, {orElse : nothing}) {} |
| 1840 "}"])); | 2088 }'''); |
| 1841 resolve(source); | 2089 resolve(source); |
| 1842 assertNoErrors(source); | 2090 assertNoErrors(source); |
| 1843 verify([source]); | 2091 verify([source]); |
| 1844 } | 2092 } |
| 1845 | 2093 |
| 1846 void test_invalidOverrideDifferentDefaultValues_positional() { | 2094 void test_invalidOverrideDifferentDefaultValues_positional() { |
| 1847 Source source = addSource(EngineTestCase.createSource([ | 2095 Source source = addSource(r''' |
| 1848 "class A {", | 2096 class A { |
| 1849 " m([int p = 0]) {}", | 2097 m([int p = 0]) {} |
| 1850 "}", | 2098 } |
| 1851 "class B extends A {", | 2099 class B extends A { |
| 1852 " m([int p = 0]) {}", | 2100 m([int p = 0]) {} |
| 1853 "}"])); | 2101 }'''); |
| 1854 resolve(source); | 2102 resolve(source); |
| 1855 assertNoErrors(source); | 2103 assertNoErrors(source); |
| 1856 verify([source]); | 2104 verify([source]); |
| 1857 } | 2105 } |
| 1858 | 2106 |
| 1859 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() { | 2107 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() { |
| 1860 Source source = addSource(EngineTestCase.createSource([ | 2108 Source source = addSource(r''' |
| 1861 "class A {", | 2109 class A { |
| 1862 " m([int a = 0, String b = '0']) {}", | 2110 m([int a = 0, String b = '0']) {} |
| 1863 "}", | 2111 } |
| 1864 "class B extends A {", | 2112 class B extends A { |
| 1865 " m([int b = 0, String a = '0']) {}", | 2113 m([int b = 0, String a = '0']) {} |
| 1866 "}"])); | 2114 }'''); |
| 1867 resolve(source); | 2115 resolve(source); |
| 1868 assertNoErrors(source); | 2116 assertNoErrors(source); |
| 1869 verify([source]); | 2117 verify([source]); |
| 1870 } | 2118 } |
| 1871 | 2119 |
| 1872 void test_invalidOverrideDifferentDefaultValues_positional_function() { | 2120 void test_invalidOverrideDifferentDefaultValues_positional_function() { |
| 1873 Source source = addSource(EngineTestCase.createSource([ | 2121 Source source = addSource(r''' |
| 1874 "nothing() => 'nothing';", | 2122 nothing() => 'nothing'; |
| 1875 "class A {", | 2123 class A { |
| 1876 " thing(String a, [orElse = nothing]) {}", | 2124 thing(String a, [orElse = nothing]) {} |
| 1877 "}", | 2125 } |
| 1878 "class B extends A {", | 2126 class B extends A { |
| 1879 " thing(String a, [orElse = nothing]) {}", | 2127 thing(String a, [orElse = nothing]) {} |
| 1880 "}"])); | 2128 }'''); |
| 1881 resolve(source); | 2129 resolve(source); |
| 1882 assertNoErrors(source); | 2130 assertNoErrors(source); |
| 1883 verify([source]); | 2131 verify([source]); |
| 1884 } | 2132 } |
| 1885 | 2133 |
| 1886 void test_invalidOverrideNamed_unorderedNamedParameter() { | 2134 void test_invalidOverrideNamed_unorderedNamedParameter() { |
| 1887 Source source = addSource(EngineTestCase.createSource([ | 2135 Source source = addSource(r''' |
| 1888 "class A {", | 2136 class A { |
| 1889 " m({a, b}) {}", | 2137 m({a, b}) {} |
| 1890 "}", | 2138 } |
| 1891 "class B extends A {", | 2139 class B extends A { |
| 1892 " m({b, a}) {}", | 2140 m({b, a}) {} |
| 1893 "}"])); | 2141 }'''); |
| 1894 resolve(source); | 2142 resolve(source); |
| 1895 assertNoErrors(source); | 2143 assertNoErrors(source); |
| 1896 verify([source]); | 2144 verify([source]); |
| 1897 } | 2145 } |
| 1898 | 2146 |
| 1899 void test_invalidOverrideRequired_less() { | 2147 void test_invalidOverrideRequired_less() { |
| 1900 Source source = addSource(EngineTestCase.createSource([ | 2148 Source source = addSource(r''' |
| 1901 "class A {", | 2149 class A { |
| 1902 " m(a, b) {}", | 2150 m(a, b) {} |
| 1903 "}", | 2151 } |
| 1904 "class B extends A {", | 2152 class B extends A { |
| 1905 " m(a, [b]) {}", | 2153 m(a, [b]) {} |
| 1906 "}"])); | 2154 }'''); |
| 1907 resolve(source); | 2155 resolve(source); |
| 1908 assertNoErrors(source); | 2156 assertNoErrors(source); |
| 1909 verify([source]); | 2157 verify([source]); |
| 1910 } | 2158 } |
| 1911 | 2159 |
| 1912 void test_invalidOverrideRequired_same() { | 2160 void test_invalidOverrideRequired_same() { |
| 1913 Source source = addSource(EngineTestCase.createSource([ | 2161 Source source = addSource(r''' |
| 1914 "class A {", | 2162 class A { |
| 1915 " m(a) {}", | 2163 m(a) {} |
| 1916 "}", | 2164 } |
| 1917 "class B extends A {", | 2165 class B extends A { |
| 1918 " m(a) {}", | 2166 m(a) {} |
| 1919 "}"])); | 2167 }'''); |
| 1920 resolve(source); | 2168 resolve(source); |
| 1921 assertNoErrors(source); | 2169 assertNoErrors(source); |
| 1922 verify([source]); | 2170 verify([source]); |
| 1923 } | 2171 } |
| 1924 | 2172 |
| 1925 void test_invalidOverrideReturnType_returnType_interface() { | 2173 void test_invalidOverrideReturnType_returnType_interface() { |
| 1926 Source source = addNamedSource("/test.dart", EngineTestCase.createSource([ | 2174 Source source = addNamedSource("/test.dart", r''' |
| 1927 "abstract class A {", | 2175 abstract class A { |
| 1928 " num m();", | 2176 num m(); |
| 1929 "}", | 2177 } |
| 1930 "class B implements A {", | 2178 class B implements A { |
| 1931 " int m() { return 1; }", | 2179 int m() { return 1; } |
| 1932 "}"])); | 2180 }'''); |
| 1933 resolve(source); | 2181 resolve(source); |
| 1934 assertNoErrors(source); | 2182 assertNoErrors(source); |
| 1935 verify([source]); | 2183 verify([source]); |
| 1936 } | 2184 } |
| 1937 | 2185 |
| 1938 void test_invalidOverrideReturnType_returnType_interface2() { | 2186 void test_invalidOverrideReturnType_returnType_interface2() { |
| 1939 Source source = addNamedSource("/test.dart", EngineTestCase.createSource([ | 2187 Source source = addNamedSource("/test.dart", r''' |
| 1940 "abstract class A {", | 2188 abstract class A { |
| 1941 " num m();", | 2189 num m(); |
| 1942 "}", | 2190 } |
| 1943 "abstract class B implements A {", | 2191 abstract class B implements A { |
| 1944 "}", | 2192 } |
| 1945 "class C implements B {", | 2193 class C implements B { |
| 1946 " int m() { return 1; }", | 2194 int m() { return 1; } |
| 1947 "}"])); | 2195 }'''); |
| 1948 resolve(source); | 2196 resolve(source); |
| 1949 assertNoErrors(source); | 2197 assertNoErrors(source); |
| 1950 verify([source]); | 2198 verify([source]); |
| 1951 } | 2199 } |
| 1952 | 2200 |
| 1953 void test_invalidOverrideReturnType_returnType_mixin() { | 2201 void test_invalidOverrideReturnType_returnType_mixin() { |
| 1954 Source source = addNamedSource("/test.dart", EngineTestCase.createSource([ | 2202 Source source = addNamedSource("/test.dart", r''' |
| 1955 "class A {", | 2203 class A { |
| 1956 " num m() { return 0; }", | 2204 num m() { return 0; } |
| 1957 "}", | 2205 } |
| 1958 "class B extends Object with A {", | 2206 class B extends Object with A { |
| 1959 " int m() { return 1; }", | 2207 int m() { return 1; } |
| 1960 "}"])); | 2208 }'''); |
| 1961 resolve(source); | 2209 resolve(source); |
| 1962 assertNoErrors(source); | 2210 assertNoErrors(source); |
| 1963 verify([source]); | 2211 verify([source]); |
| 1964 } | 2212 } |
| 1965 | 2213 |
| 1966 void test_invalidOverrideReturnType_returnType_parameterizedTypes() { | 2214 void test_invalidOverrideReturnType_returnType_parameterizedTypes() { |
| 1967 Source source = addSource(EngineTestCase.createSource([ | 2215 Source source = addSource(r''' |
| 1968 "abstract class A<E> {", | 2216 abstract class A<E> { |
| 1969 " List<E> m();", | 2217 List<E> m(); |
| 1970 "}", | 2218 } |
| 1971 "class B extends A<dynamic> {", | 2219 class B extends A<dynamic> { |
| 1972 " List<dynamic> m() { return new List<dynamic>(); }", | 2220 List<dynamic> m() { return new List<dynamic>(); } |
| 1973 "}"])); | 2221 }'''); |
| 1974 resolve(source); | 2222 resolve(source); |
| 1975 assertNoErrors(source); | 2223 assertNoErrors(source); |
| 1976 verify([source]); | 2224 verify([source]); |
| 1977 } | 2225 } |
| 1978 | 2226 |
| 1979 void test_invalidOverrideReturnType_returnType_sameType() { | 2227 void test_invalidOverrideReturnType_returnType_sameType() { |
| 1980 Source source = addNamedSource("/test.dart", EngineTestCase.createSource([ | 2228 Source source = addNamedSource("/test.dart", r''' |
| 1981 "class A {", | 2229 class A { |
| 1982 " int m() { return 0; }", | 2230 int m() { return 0; } |
| 1983 "}", | 2231 } |
| 1984 "class B extends A {", | 2232 class B extends A { |
| 1985 " int m() { return 1; }", | 2233 int m() { return 1; } |
| 1986 "}"])); | 2234 }'''); |
| 1987 resolve(source); | 2235 resolve(source); |
| 1988 assertNoErrors(source); | 2236 assertNoErrors(source); |
| 1989 verify([source]); | 2237 verify([source]); |
| 1990 } | 2238 } |
| 1991 | 2239 |
| 1992 void test_invalidOverrideReturnType_returnType_superclass() { | 2240 void test_invalidOverrideReturnType_returnType_superclass() { |
| 1993 Source source = addNamedSource("/test.dart", EngineTestCase.createSource([ | 2241 Source source = addNamedSource("/test.dart", r''' |
| 1994 "class A {", | 2242 class A { |
| 1995 " num m() { return 0; }", | 2243 num m() { return 0; } |
| 1996 "}", | 2244 } |
| 1997 "class B extends A {", | 2245 class B extends A { |
| 1998 " int m() { return 1; }", | 2246 int m() { return 1; } |
| 1999 "}"])); | 2247 }'''); |
| 2000 resolve(source); | 2248 resolve(source); |
| 2001 assertNoErrors(source); | 2249 assertNoErrors(source); |
| 2002 verify([source]); | 2250 verify([source]); |
| 2003 } | 2251 } |
| 2004 | 2252 |
| 2005 void test_invalidOverrideReturnType_returnType_superclass2() { | 2253 void test_invalidOverrideReturnType_returnType_superclass2() { |
| 2006 Source source = addNamedSource("/test.dart", EngineTestCase.createSource([ | 2254 Source source = addNamedSource("/test.dart", r''' |
| 2007 "class A {", | 2255 class A { |
| 2008 " num m() { return 0; }", | 2256 num m() { return 0; } |
| 2009 "}", | 2257 } |
| 2010 "class B extends A {", | 2258 class B extends A { |
| 2011 "}", | 2259 } |
| 2012 "class C extends B {", | 2260 class C extends B { |
| 2013 " int m() { return 1; }", | 2261 int m() { return 1; } |
| 2014 "}"])); | 2262 }'''); |
| 2015 resolve(source); | 2263 resolve(source); |
| 2016 assertNoErrors(source); | 2264 assertNoErrors(source); |
| 2017 verify([source]); | 2265 verify([source]); |
| 2018 } | 2266 } |
| 2019 | 2267 |
| 2020 void test_invalidOverrideReturnType_returnType_void() { | 2268 void test_invalidOverrideReturnType_returnType_void() { |
| 2021 Source source = addSource(EngineTestCase.createSource([ | 2269 Source source = addSource(r''' |
| 2022 "class A {", | 2270 class A { |
| 2023 " void m() {}", | 2271 void m() {} |
| 2024 "}", | 2272 } |
| 2025 "class B extends A {", | 2273 class B extends A { |
| 2026 " int m() { return 0; }", | 2274 int m() { return 0; } |
| 2027 "}"])); | 2275 }'''); |
| 2028 resolve(source); | 2276 resolve(source); |
| 2029 assertNoErrors(source); | 2277 assertNoErrors(source); |
| 2030 verify([source]); | 2278 verify([source]); |
| 2031 } | 2279 } |
| 2032 | 2280 |
| 2033 void test_invalidReferenceToThis_constructor() { | 2281 void test_invalidReferenceToThis_constructor() { |
| 2034 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
", " var v = this;", " }", "}"])); | 2282 Source source = addSource(r''' |
| 2283 class A { |
| 2284 A() { |
| 2285 var v = this; |
| 2286 } |
| 2287 }'''); |
| 2035 resolve(source); | 2288 resolve(source); |
| 2036 assertNoErrors(source); | 2289 assertNoErrors(source); |
| 2037 verify([source]); | 2290 verify([source]); |
| 2038 } | 2291 } |
| 2039 | 2292 |
| 2040 void test_invalidReferenceToThis_instanceMethod() { | 2293 void test_invalidReferenceToThis_instanceMethod() { |
| 2041 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
", " var v = this;", " }", "}"])); | 2294 Source source = addSource(r''' |
| 2295 class A { |
| 2296 m() { |
| 2297 var v = this; |
| 2298 } |
| 2299 }'''); |
| 2042 resolve(source); | 2300 resolve(source); |
| 2043 assertNoErrors(source); | 2301 assertNoErrors(source); |
| 2044 verify([source]); | 2302 verify([source]); |
| 2045 } | 2303 } |
| 2046 | 2304 |
| 2047 void test_invalidTypeArgumentForKey() { | 2305 void test_invalidTypeArgumentForKey() { |
| 2048 Source source = addSource(EngineTestCase.createSource([ | 2306 Source source = addSource(r''' |
| 2049 "class A {", | 2307 class A { |
| 2050 " m() {", | 2308 m() { |
| 2051 " return const <int, int>{};", | 2309 return const <int, int>{}; |
| 2052 " }", | 2310 } |
| 2053 "}"])); | 2311 }'''); |
| 2054 resolve(source); | 2312 resolve(source); |
| 2055 assertNoErrors(source); | 2313 assertNoErrors(source); |
| 2056 verify([source]); | 2314 verify([source]); |
| 2057 } | 2315 } |
| 2058 | 2316 |
| 2059 void test_invalidTypeArgumentInConstList() { | 2317 void test_invalidTypeArgumentInConstList() { |
| 2060 Source source = addSource(EngineTestCase.createSource([ | 2318 Source source = addSource(r''' |
| 2061 "class A<E> {", | 2319 class A<E> { |
| 2062 " m() {", | 2320 m() { |
| 2063 " return <E>[];", | 2321 return <E>[]; |
| 2064 " }", | 2322 } |
| 2065 "}"])); | 2323 }'''); |
| 2066 resolve(source); | 2324 resolve(source); |
| 2067 assertNoErrors(source); | 2325 assertNoErrors(source); |
| 2068 verify([source]); | 2326 verify([source]); |
| 2069 } | 2327 } |
| 2070 | 2328 |
| 2071 void test_invalidTypeArgumentInConstMap() { | 2329 void test_invalidTypeArgumentInConstMap() { |
| 2072 Source source = addSource(EngineTestCase.createSource([ | 2330 Source source = addSource(r''' |
| 2073 "class A<E> {", | 2331 class A<E> { |
| 2074 " m() {", | 2332 m() { |
| 2075 " return <String, E>{};", | 2333 return <String, E>{}; |
| 2076 " }", | 2334 } |
| 2077 "}"])); | 2335 }'''); |
| 2078 resolve(source); | 2336 resolve(source); |
| 2079 assertNoErrors(source); | 2337 assertNoErrors(source); |
| 2080 verify([source]); | 2338 verify([source]); |
| 2081 } | 2339 } |
| 2082 | 2340 |
| 2083 void test_invocationOfNonFunction_dynamic() { | 2341 void test_invocationOfNonFunction_dynamic() { |
| 2084 Source source = addSource(EngineTestCase.createSource([ | 2342 Source source = addSource(r''' |
| 2085 "class A {", | 2343 class A { |
| 2086 " var f;", | 2344 var f; |
| 2087 "}", | 2345 } |
| 2088 "class B extends A {", | 2346 class B extends A { |
| 2089 " g() {", | 2347 g() { |
| 2090 " f();", | 2348 f(); |
| 2091 " }", | 2349 } |
| 2092 "}"])); | 2350 }'''); |
| 2093 resolve(source); | 2351 resolve(source); |
| 2094 assertNoErrors(source); | 2352 assertNoErrors(source); |
| 2095 verify([source]); | 2353 verify([source]); |
| 2096 } | 2354 } |
| 2097 | 2355 |
| 2098 void test_invocationOfNonFunction_getter() { | 2356 void test_invocationOfNonFunction_getter() { |
| 2099 Source source = addSource(EngineTestCase.createSource([ | 2357 Source source = addSource(r''' |
| 2100 "class A {", | 2358 class A { |
| 2101 " var g;", | 2359 var g; |
| 2102 "}", | 2360 } |
| 2103 "f() {", | 2361 f() { |
| 2104 " A a;", | 2362 A a; |
| 2105 " a.g();", | 2363 a.g(); |
| 2106 "}"])); | 2364 }'''); |
| 2107 resolve(source); | 2365 resolve(source); |
| 2108 assertNoErrors(source); | 2366 assertNoErrors(source); |
| 2109 verify([source]); | 2367 verify([source]); |
| 2110 } | 2368 } |
| 2111 | 2369 |
| 2112 void test_invocationOfNonFunction_localVariable() { | 2370 void test_invocationOfNonFunction_localVariable() { |
| 2113 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g();", "}"])); | 2371 Source source = addSource(r''' |
| 2372 f() { |
| 2373 var g; |
| 2374 g(); |
| 2375 }'''); |
| 2114 resolve(source); | 2376 resolve(source); |
| 2115 assertNoErrors(source); | 2377 assertNoErrors(source); |
| 2116 verify([source]); | 2378 verify([source]); |
| 2117 } | 2379 } |
| 2118 | 2380 |
| 2119 void test_invocationOfNonFunction_localVariable_dynamic() { | 2381 void test_invocationOfNonFunction_localVariable_dynamic() { |
| 2120 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" var v = f;", " v();", "}"])); | 2382 Source source = addSource(r''' |
| 2383 f() {} |
| 2384 main() { |
| 2385 var v = f; |
| 2386 v(); |
| 2387 }'''); |
| 2121 resolve(source); | 2388 resolve(source); |
| 2122 assertNoErrors(source); | 2389 assertNoErrors(source); |
| 2123 verify([source]); | 2390 verify([source]); |
| 2124 } | 2391 } |
| 2125 | 2392 |
| 2126 void test_invocationOfNonFunction_localVariable_dynamic2() { | 2393 void test_invocationOfNonFunction_localVariable_dynamic2() { |
| 2127 Source source = addSource(EngineTestCase.createSource([ | 2394 Source source = addSource(r''' |
| 2128 "f() {}", | 2395 f() {} |
| 2129 "main() {", | 2396 main() { |
| 2130 " var v = f;", | 2397 var v = f; |
| 2131 " v = 1;", | 2398 v = 1; |
| 2132 " v();", | 2399 v(); |
| 2133 "}"])); | 2400 }'''); |
| 2134 resolve(source); | 2401 resolve(source); |
| 2135 assertNoErrors(source); | 2402 assertNoErrors(source); |
| 2136 verify([source]); | 2403 verify([source]); |
| 2137 } | 2404 } |
| 2138 | 2405 |
| 2139 void test_invocationOfNonFunction_Object() { | 2406 void test_invocationOfNonFunction_Object() { |
| 2140 Source source = addSource(EngineTestCase.createSource(["main() {", " Object
v = null;", " v();", "}"])); | 2407 Source source = addSource(r''' |
| 2141 resolve(source); | 2408 main() { |
| 2142 assertNoErrors(source); | 2409 Object v = null; |
| 2143 verify([source]); | 2410 v(); |
| 2411 }'''); |
| 2412 resolve(source); |
| 2413 assertNoErrors(source); |
| 2414 verify([source]); |
| 2144 } | 2415 } |
| 2145 | 2416 |
| 2146 void test_invocationOfNonFunction_proxyOnFunctionClass() { | 2417 void test_invocationOfNonFunction_proxyOnFunctionClass() { |
| 2147 // 16078 | 2418 // 16078 |
| 2148 Source source = addSource(EngineTestCase.createSource([ | 2419 Source source = addSource(r''' |
| 2149 "@proxy", | 2420 @proxy |
| 2150 "class Functor implements Function {", | 2421 class Functor implements Function { |
| 2151 " noSuchMethod(inv) {", | 2422 noSuchMethod(inv) { |
| 2152 " return 42;", | 2423 return 42; |
| 2153 " }", | 2424 } |
| 2154 "}", | 2425 } |
| 2155 "main() {", | 2426 main() { |
| 2156 " Functor f = new Functor();", | 2427 Functor f = new Functor(); |
| 2157 " f();", | 2428 f(); |
| 2158 "}"])); | 2429 }'''); |
| 2159 resolve(source); | 2430 resolve(source); |
| 2160 assertErrors(source, []); | 2431 assertErrors(source, []); |
| 2161 verify([source]); | 2432 verify([source]); |
| 2162 } | 2433 } |
| 2163 | 2434 |
| 2164 void test_listElementTypeNotAssignable() { | 2435 void test_listElementTypeNotAssignable() { |
| 2165 Source source = addSource(EngineTestCase.createSource(["var v1 = <int> [42];
", "var v2 = const <int> [42];"])); | 2436 Source source = addSource(r''' |
| 2437 var v1 = <int> [42]; |
| 2438 var v2 = const <int> [42];'''); |
| 2166 resolve(source); | 2439 resolve(source); |
| 2167 assertNoErrors(source); | 2440 assertNoErrors(source); |
| 2168 verify([source]); | 2441 verify([source]); |
| 2169 } | 2442 } |
| 2170 | 2443 |
| 2171 void test_loadLibraryDefined() { | 2444 void test_loadLibraryDefined() { |
| 2172 resolveWithAndWithoutExperimental(<String> [ | 2445 resolveWithAndWithoutExperimental(<String> [ |
| 2173 EngineTestCase.createSource(["library lib1;", "foo() => 22;"]), | 2446 r''' |
| 2174 EngineTestCase.createSource([ | 2447 library lib1; |
| 2175 "import 'lib1.dart' deferred as other;", | 2448 foo() => 22;''', |
| 2176 "main() {", | 2449 r''' |
| 2177 " other.loadLibrary().then((_) => other.foo());", | 2450 import 'lib1.dart' deferred as other; |
| 2178 "}"])], <ErrorCode> [ | 2451 main() { |
| 2452 other.loadLibrary().then((_) => other.foo()); |
| 2453 }'''], <ErrorCode> [ |
| 2179 ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED, | 2454 ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED, |
| 2180 StaticTypeWarningCode.UNDEFINED_FUNCTION], <ErrorCode> []); | 2455 StaticTypeWarningCode.UNDEFINED_FUNCTION], <ErrorCode> []); |
| 2181 } | 2456 } |
| 2182 | 2457 |
| 2183 void test_mapKeyTypeNotAssignable() { | 2458 void test_mapKeyTypeNotAssignable() { |
| 2184 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {'a' : 1};"])); | 2459 Source source = addSource("var v = <String, int > {'a' : 1};"); |
| 2185 resolve(source); | 2460 resolve(source); |
| 2186 assertNoErrors(source); | 2461 assertNoErrors(source); |
| 2187 verify([source]); | 2462 verify([source]); |
| 2188 } | 2463 } |
| 2189 | 2464 |
| 2190 void test_memberWithClassName_setter() { | 2465 void test_memberWithClassName_setter() { |
| 2191 Source source = addSource(EngineTestCase.createSource(["class A {", " set A
(v) {}", "}"])); | 2466 Source source = addSource(r''' |
| 2467 class A { |
| 2468 set A(v) {} |
| 2469 }'''); |
| 2192 resolve(source); | 2470 resolve(source); |
| 2193 assertNoErrors(source); | 2471 assertNoErrors(source); |
| 2194 verify([source]); | 2472 verify([source]); |
| 2195 } | 2473 } |
| 2196 | 2474 |
| 2197 void test_methodDeclaration_scope_signature() { | 2475 void test_methodDeclaration_scope_signature() { |
| 2198 Source source = addSource(EngineTestCase.createSource([ | 2476 Source source = addSource(r''' |
| 2199 "const app = 0;", | 2477 const app = 0; |
| 2200 "class A {", | 2478 class A { |
| 2201 " foo(@app int app) {}", | 2479 foo(@app int app) {} |
| 2202 "}"])); | 2480 }'''); |
| 2203 resolve(source); | 2481 resolve(source); |
| 2204 assertNoErrors(source); | 2482 assertNoErrors(source); |
| 2205 verify([source]); | 2483 verify([source]); |
| 2206 } | 2484 } |
| 2207 | 2485 |
| 2208 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() { | 2486 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() { |
| 2209 Source source = addSource(EngineTestCase.createSource([ | 2487 Source source = addSource(r''' |
| 2210 "class C {", | 2488 class C { |
| 2211 " int get x => 0;", | 2489 int get x => 0; |
| 2212 " set x(int v) {}", | 2490 set x(int v) {} |
| 2213 "}"])); | 2491 }'''); |
| 2214 resolve(source); | 2492 resolve(source); |
| 2215 assertNoErrors(source); | 2493 assertNoErrors(source); |
| 2216 verify([source]); | 2494 verify([source]); |
| 2217 } | 2495 } |
| 2218 | 2496 |
| 2219 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() { | 2497 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() { |
| 2220 Source source = addSource(EngineTestCase.createSource(["class C {", " get x
=> 0;", " set x(String v) {}", "}"])); | 2498 Source source = addSource(r''' |
| 2499 class C { |
| 2500 get x => 0; |
| 2501 set x(String v) {} |
| 2502 }'''); |
| 2221 resolve(source); | 2503 resolve(source); |
| 2222 assertNoErrors(source); | 2504 assertNoErrors(source); |
| 2223 verify([source]); | 2505 verify([source]); |
| 2224 } | 2506 } |
| 2225 | 2507 |
| 2226 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() { | 2508 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() { |
| 2227 Source source = addSource(EngineTestCase.createSource(["class C {", " int g
et x => 0;", " set x(v) {}", "}"])); | 2509 Source source = addSource(r''' |
| 2510 class C { |
| 2511 int get x => 0; |
| 2512 set x(v) {} |
| 2513 }'''); |
| 2228 resolve(source); | 2514 resolve(source); |
| 2229 assertNoErrors(source); | 2515 assertNoErrors(source); |
| 2230 verify([source]); | 2516 verify([source]); |
| 2231 } | 2517 } |
| 2232 | 2518 |
| 2233 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() { | 2519 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() { |
| 2234 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(int v) {}"])); | 2520 Source source = addSource(r''' |
| 2521 int get x => 0; |
| 2522 set x(int v) {}'''); |
| 2235 resolve(source); | 2523 resolve(source); |
| 2236 assertNoErrors(source); | 2524 assertNoErrors(source); |
| 2237 verify([source]); | 2525 verify([source]); |
| 2238 } | 2526 } |
| 2239 | 2527 |
| 2240 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() { | 2528 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() { |
| 2241 Source source = addSource(EngineTestCase.createSource(["get x => 0;", "set x
(String v) {}"])); | 2529 Source source = addSource(r''' |
| 2530 get x => 0; |
| 2531 set x(String v) {}'''); |
| 2242 resolve(source); | 2532 resolve(source); |
| 2243 assertNoErrors(source); | 2533 assertNoErrors(source); |
| 2244 verify([source]); | 2534 verify([source]); |
| 2245 } | 2535 } |
| 2246 | 2536 |
| 2247 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() { | 2537 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() { |
| 2248 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(v) {}"])); | 2538 Source source = addSource(r''' |
| 2539 int get x => 0; |
| 2540 set x(v) {}'''); |
| 2249 resolve(source); | 2541 resolve(source); |
| 2250 assertNoErrors(source); | 2542 assertNoErrors(source); |
| 2251 verify([source]); | 2543 verify([source]); |
| 2252 } | 2544 } |
| 2253 | 2545 |
| 2254 void test_missingEnumConstantInSwitch_all() { | 2546 void test_missingEnumConstantInSwitch_all() { |
| 2255 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); | 2547 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); |
| 2256 analysisOptions.enableEnum = true; | 2548 analysisOptions.enableEnum = true; |
| 2257 resetWithOptions(analysisOptions); | 2549 resetWithOptions(analysisOptions); |
| 2258 Source source = addSource(EngineTestCase.createSource([ | 2550 Source source = addSource(r''' |
| 2259 "enum E { A, B, C }", | 2551 enum E { A, B, C } |
| 2260 "", | 2552 |
| 2261 "f(E e) {", | 2553 f(E e) { |
| 2262 " switch (e) {", | 2554 switch (e) { |
| 2263 " case E.A: break;", | 2555 case E.A: break; |
| 2264 " case E.B: break;", | 2556 case E.B: break; |
| 2265 " case E.C: break;", | 2557 case E.C: break; |
| 2266 " }", | 2558 } |
| 2267 "}"])); | 2559 }'''); |
| 2268 resolve(source); | 2560 resolve(source); |
| 2269 assertNoErrors(source); | 2561 assertNoErrors(source); |
| 2270 verify([source]); | 2562 verify([source]); |
| 2271 } | 2563 } |
| 2272 | 2564 |
| 2273 void test_missingEnumConstantInSwitch_default() { | 2565 void test_missingEnumConstantInSwitch_default() { |
| 2274 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); | 2566 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); |
| 2275 analysisOptions.enableEnum = true; | 2567 analysisOptions.enableEnum = true; |
| 2276 resetWithOptions(analysisOptions); | 2568 resetWithOptions(analysisOptions); |
| 2277 Source source = addSource(EngineTestCase.createSource([ | 2569 Source source = addSource(r''' |
| 2278 "enum E { A, B, C }", | 2570 enum E { A, B, C } |
| 2279 "", | 2571 |
| 2280 "f(E e) {", | 2572 f(E e) { |
| 2281 " switch (e) {", | 2573 switch (e) { |
| 2282 " case E.B: break;", | 2574 case E.B: break; |
| 2283 " default: break;", | 2575 default: break; |
| 2284 " }", | 2576 } |
| 2285 "}"])); | 2577 }'''); |
| 2286 resolve(source); | 2578 resolve(source); |
| 2287 assertNoErrors(source); | 2579 assertNoErrors(source); |
| 2288 verify([source]); | 2580 verify([source]); |
| 2289 } | 2581 } |
| 2290 | 2582 |
| 2291 void test_mixedReturnTypes_differentScopes() { | 2583 void test_mixedReturnTypes_differentScopes() { |
| 2292 Source source = addSource(EngineTestCase.createSource([ | 2584 Source source = addSource(r''' |
| 2293 "class C {", | 2585 class C { |
| 2294 " m(int x) {", | 2586 m(int x) { |
| 2295 " f(int y) {", | 2587 f(int y) { |
| 2296 " return;", | 2588 return; |
| 2297 " }", | 2589 } |
| 2298 " f(x);", | 2590 f(x); |
| 2299 " return 0;", | 2591 return 0; |
| 2300 " }", | 2592 } |
| 2301 "}"])); | 2593 }'''); |
| 2302 resolve(source); | 2594 resolve(source); |
| 2303 assertNoErrors(source); | 2595 assertNoErrors(source); |
| 2304 verify([source]); | 2596 verify([source]); |
| 2305 } | 2597 } |
| 2306 | 2598 |
| 2307 void test_mixedReturnTypes_ignoreImplicit() { | 2599 void test_mixedReturnTypes_ignoreImplicit() { |
| 2308 Source source = addSource(EngineTestCase.createSource([ | 2600 Source source = addSource(r''' |
| 2309 "f(bool p) {", | 2601 f(bool p) { |
| 2310 " if (p) return 42;", | 2602 if (p) return 42; |
| 2311 " // implicit 'return;' is ignored", | 2603 // implicit 'return;' is ignored |
| 2312 "}"])); | 2604 }'''); |
| 2313 resolve(source); | 2605 resolve(source); |
| 2314 assertNoErrors(source); | 2606 assertNoErrors(source); |
| 2315 verify([source]); | 2607 verify([source]); |
| 2316 } | 2608 } |
| 2317 | 2609 |
| 2318 void test_mixedReturnTypes_ignoreImplicit2() { | 2610 void test_mixedReturnTypes_ignoreImplicit2() { |
| 2319 Source source = addSource(EngineTestCase.createSource([ | 2611 Source source = addSource(r''' |
| 2320 "f(bool p) {", | 2612 f(bool p) { |
| 2321 " if (p) {", | 2613 if (p) { |
| 2322 " return 42;", | 2614 return 42; |
| 2323 " } else {", | 2615 } else { |
| 2324 " return 42;", | 2616 return 42; |
| 2325 " }", | 2617 } |
| 2326 " // implicit 'return;' is ignored", | 2618 // implicit 'return;' is ignored |
| 2327 "}"])); | 2619 }'''); |
| 2328 resolve(source); | 2620 resolve(source); |
| 2329 assertNoErrors(source); | 2621 assertNoErrors(source); |
| 2330 verify([source]); | 2622 verify([source]); |
| 2331 } | 2623 } |
| 2332 | 2624 |
| 2333 void test_mixedReturnTypes_sameKind() { | 2625 void test_mixedReturnTypes_sameKind() { |
| 2334 Source source = addSource(EngineTestCase.createSource([ | 2626 Source source = addSource(r''' |
| 2335 "class C {", | 2627 class C { |
| 2336 " m(int x) {", | 2628 m(int x) { |
| 2337 " if (x < 0) {", | 2629 if (x < 0) { |
| 2338 " return 1;", | 2630 return 1; |
| 2339 " }", | 2631 } |
| 2340 " return 0;", | 2632 return 0; |
| 2341 " }", | 2633 } |
| 2342 "}"])); | 2634 }'''); |
| 2343 resolve(source); | 2635 resolve(source); |
| 2344 assertNoErrors(source); | 2636 assertNoErrors(source); |
| 2345 verify([source]); | 2637 verify([source]); |
| 2346 } | 2638 } |
| 2347 | 2639 |
| 2348 void test_mixinDeclaresConstructor() { | 2640 void test_mixinDeclaresConstructor() { |
| 2349 Source source = addSource(EngineTestCase.createSource([ | 2641 Source source = addSource(r''' |
| 2350 "class A {", | 2642 class A { |
| 2351 " m() {}", | 2643 m() {} |
| 2352 "}", | 2644 } |
| 2353 "class B extends Object with A {}"])); | 2645 class B extends Object with A {}'''); |
| 2354 resolve(source); | 2646 resolve(source); |
| 2355 assertNoErrors(source); | 2647 assertNoErrors(source); |
| 2356 verify([source]); | 2648 verify([source]); |
| 2357 } | 2649 } |
| 2358 | 2650 |
| 2359 void test_mixinDeclaresConstructor_factory() { | 2651 void test_mixinDeclaresConstructor_factory() { |
| 2360 Source source = addSource(EngineTestCase.createSource([ | 2652 Source source = addSource(r''' |
| 2361 "class A {", | 2653 class A { |
| 2362 " factory A() {}", | 2654 factory A() {} |
| 2363 "}", | 2655 } |
| 2364 "class B extends Object with A {}"])); | 2656 class B extends Object with A {}'''); |
| 2365 resolve(source); | 2657 resolve(source); |
| 2366 assertNoErrors(source); | 2658 assertNoErrors(source); |
| 2367 verify([source]); | 2659 verify([source]); |
| 2368 } | 2660 } |
| 2369 | 2661 |
| 2370 void test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() { | 2662 void test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() { |
| 2371 Source source = addSource(EngineTestCase.createSource([ | 2663 Source source = addSource(r''' |
| 2372 "class A {}", | 2664 class A {} |
| 2373 "class B = Object with A;", | 2665 class B = Object with A; |
| 2374 "class C extends Object with B {}"])); | 2666 class C extends Object with B {}'''); |
| 2375 resolve(source); | 2667 resolve(source); |
| 2376 assertNoErrors(source); | 2668 assertNoErrors(source); |
| 2377 verify([source]); | 2669 verify([source]); |
| 2378 } | 2670 } |
| 2379 | 2671 |
| 2380 void test_mixinInheritsFromNotObject_typedef_mixTypeAlias() { | 2672 void test_mixinInheritsFromNotObject_typedef_mixTypeAlias() { |
| 2381 Source source = addSource(EngineTestCase.createSource([ | 2673 Source source = addSource(r''' |
| 2382 "class A {}", | 2674 class A {} |
| 2383 "class B = Object with A;", | 2675 class B = Object with A; |
| 2384 "class C = Object with B;"])); | 2676 class C = Object with B;'''); |
| 2385 resolve(source); | 2677 resolve(source); |
| 2386 assertNoErrors(source); | 2678 assertNoErrors(source); |
| 2387 verify([source]); | 2679 verify([source]); |
| 2388 } | 2680 } |
| 2389 | 2681 |
| 2390 void test_multipleSuperInitializers_no() { | 2682 void test_multipleSuperInitializers_no() { |
| 2391 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A {", " B() {}", "}"])); | 2683 Source source = addSource(r''' |
| 2684 class A {} |
| 2685 class B extends A { |
| 2686 B() {} |
| 2687 }'''); |
| 2392 resolve(source); | 2688 resolve(source); |
| 2393 assertNoErrors(source); | 2689 assertNoErrors(source); |
| 2394 verify([source]); | 2690 verify([source]); |
| 2395 } | 2691 } |
| 2396 | 2692 |
| 2397 void test_multipleSuperInitializers_single() { | 2693 void test_multipleSuperInitializers_single() { |
| 2398 Source source = addSource(EngineTestCase.createSource([ | 2694 Source source = addSource(r''' |
| 2399 "class A {}", | 2695 class A {} |
| 2400 "class B extends A {", | 2696 class B extends A { |
| 2401 " B() : super() {}", | 2697 B() : super() {} |
| 2402 "}"])); | 2698 }'''); |
| 2403 resolve(source); | 2699 resolve(source); |
| 2404 assertNoErrors(source); | 2700 assertNoErrors(source); |
| 2405 verify([source]); | 2701 verify([source]); |
| 2406 } | 2702 } |
| 2407 | 2703 |
| 2408 void test_nativeFunctionBodyInNonSDKCode_function() { | 2704 void test_nativeFunctionBodyInNonSDKCode_function() { |
| 2409 Source source = addSource(EngineTestCase.createSource(["import 'dart-ext:x';
", "int m(a) native 'string';"])); | 2705 Source source = addSource(r''' |
| 2706 import 'dart-ext:x'; |
| 2707 int m(a) native 'string';'''); |
| 2410 resolve(source); | 2708 resolve(source); |
| 2411 assertNoErrors(source); | 2709 assertNoErrors(source); |
| 2412 // Cannot verify the AST because the import's URI cannot be resolved. | 2710 // Cannot verify the AST because the import's URI cannot be resolved. |
| 2413 } | 2711 } |
| 2414 | 2712 |
| 2415 void test_newWithAbstractClass_factory() { | 2713 void test_newWithAbstractClass_factory() { |
| 2416 Source source = addSource(EngineTestCase.createSource([ | 2714 Source source = addSource(r''' |
| 2417 "abstract class A {", | 2715 abstract class A { |
| 2418 " factory A() { return new B(); }", | 2716 factory A() { return new B(); } |
| 2419 "}", | 2717 } |
| 2420 "class B implements A {", | 2718 class B implements A { |
| 2421 " B() {}", | 2719 B() {} |
| 2422 "}", | 2720 } |
| 2423 "A f() {", | 2721 A f() { |
| 2424 " return new A();", | 2722 return new A(); |
| 2425 "}"])); | 2723 }'''); |
| 2426 resolve(source); | 2724 resolve(source); |
| 2427 assertNoErrors(source); | 2725 assertNoErrors(source); |
| 2428 verify([source]); | 2726 verify([source]); |
| 2429 } | 2727 } |
| 2430 | 2728 |
| 2431 void test_newWithUndefinedConstructor() { | 2729 void test_newWithUndefinedConstructor() { |
| 2432 Source source = addSource(EngineTestCase.createSource([ | 2730 Source source = addSource(r''' |
| 2433 "class A {", | 2731 class A { |
| 2434 " A.name() {}", | 2732 A.name() {} |
| 2435 "}", | 2733 } |
| 2436 "f() {", | 2734 f() { |
| 2437 " new A.name();", | 2735 new A.name(); |
| 2438 "}"])); | 2736 }'''); |
| 2439 resolve(source); | 2737 resolve(source); |
| 2440 assertNoErrors(source); | 2738 assertNoErrors(source); |
| 2441 verify([source]); | 2739 verify([source]); |
| 2442 } | 2740 } |
| 2443 | 2741 |
| 2444 void test_newWithUndefinedConstructorDefault() { | 2742 void test_newWithUndefinedConstructorDefault() { |
| 2445 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "f() {", " new A();", "}"])); | 2743 Source source = addSource(r''' |
| 2744 class A { |
| 2745 A() {} |
| 2746 } |
| 2747 f() { |
| 2748 new A(); |
| 2749 }'''); |
| 2446 resolve(source); | 2750 resolve(source); |
| 2447 assertNoErrors(source); | 2751 assertNoErrors(source); |
| 2448 verify([source]); | 2752 verify([source]); |
| 2449 } | 2753 } |
| 2450 | 2754 |
| 2451 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr
etes_getter() { | 2755 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr
etes_getter() { |
| 2452 Source source = addSource(EngineTestCase.createSource([ | 2756 Source source = addSource(r''' |
| 2453 "class A {", | 2757 class A { |
| 2454 " int get g => 0;", | 2758 int get g => 0; |
| 2455 "}", | 2759 } |
| 2456 "abstract class B extends A {", | 2760 abstract class B extends A { |
| 2457 " int get g;", | 2761 int get g; |
| 2458 "}", | 2762 } |
| 2459 "class C extends B {}"])); | 2763 class C extends B {}'''); |
| 2460 resolve(source); | 2764 resolve(source); |
| 2461 assertNoErrors(source); | 2765 assertNoErrors(source); |
| 2462 verify([source]); | 2766 verify([source]); |
| 2463 } | 2767 } |
| 2464 | 2768 |
| 2465 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr
etes_method() { | 2769 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr
etes_method() { |
| 2466 Source source = addSource(EngineTestCase.createSource([ | 2770 Source source = addSource(r''' |
| 2467 "class A {", | 2771 class A { |
| 2468 " m(p) {}", | 2772 m(p) {} |
| 2469 "}", | 2773 } |
| 2470 "abstract class B extends A {", | 2774 abstract class B extends A { |
| 2471 " m(p);", | 2775 m(p); |
| 2472 "}", | 2776 } |
| 2473 "class C extends B {}"])); | 2777 class C extends B {}'''); |
| 2474 resolve(source); | 2778 resolve(source); |
| 2475 assertNoErrors(source); | 2779 assertNoErrors(source); |
| 2476 verify([source]); | 2780 verify([source]); |
| 2477 } | 2781 } |
| 2478 | 2782 |
| 2479 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr
etes_setter() { | 2783 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr
etes_setter() { |
| 2480 Source source = addSource(EngineTestCase.createSource([ | 2784 Source source = addSource(r''' |
| 2481 "class A {", | 2785 class A { |
| 2482 " set s(v) {}", | 2786 set s(v) {} |
| 2483 "}", | 2787 } |
| 2484 "abstract class B extends A {", | 2788 abstract class B extends A { |
| 2485 " set s(v);", | 2789 set s(v); |
| 2486 "}", | 2790 } |
| 2487 "class C extends B {}"])); | 2791 class C extends B {}'''); |
| 2488 resolve(source); | 2792 resolve(source); |
| 2489 assertNoErrors(source); | 2793 assertNoErrors(source); |
| 2490 verify([source]); | 2794 verify([source]); |
| 2491 } | 2795 } |
| 2492 | 2796 |
| 2493 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface()
{ | 2797 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface()
{ |
| 2494 // 15979 | 2798 // 15979 |
| 2495 Source source = addSource(EngineTestCase.createSource([ | 2799 Source source = addSource(r''' |
| 2496 "abstract class M {}", | 2800 abstract class M {} |
| 2497 "abstract class A {}", | 2801 abstract class A {} |
| 2498 "abstract class I {", | 2802 abstract class I { |
| 2499 " m();", | 2803 m(); |
| 2500 "}", | 2804 } |
| 2501 "abstract class B = A with M implements I;"])); | 2805 abstract class B = A with M implements I;'''); |
| 2502 resolve(source); | 2806 resolve(source); |
| 2503 assertNoErrors(source); | 2807 assertNoErrors(source); |
| 2504 verify([source]); | 2808 verify([source]); |
| 2505 } | 2809 } |
| 2506 | 2810 |
| 2507 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() { | 2811 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() { |
| 2508 // 15979 | 2812 // 15979 |
| 2509 Source source = addSource(EngineTestCase.createSource([ | 2813 Source source = addSource(r''' |
| 2510 "abstract class M {", | 2814 abstract class M { |
| 2511 " m();", | 2815 m(); |
| 2512 "}", | 2816 } |
| 2513 "abstract class A {}", | 2817 abstract class A {} |
| 2514 "abstract class B = A with M;"])); | 2818 abstract class B = A with M;'''); |
| 2515 resolve(source); | 2819 resolve(source); |
| 2516 assertNoErrors(source); | 2820 assertNoErrors(source); |
| 2517 verify([source]); | 2821 verify([source]); |
| 2518 } | 2822 } |
| 2519 | 2823 |
| 2520 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass(
) { | 2824 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass(
) { |
| 2521 // 15979 | 2825 // 15979 |
| 2522 Source source = addSource(EngineTestCase.createSource([ | 2826 Source source = addSource(r''' |
| 2523 "class M {}", | 2827 class M {} |
| 2524 "abstract class A {", | 2828 abstract class A { |
| 2525 " m();", | 2829 m(); |
| 2526 "}", | 2830 } |
| 2527 "abstract class B = A with M;"])); | 2831 abstract class B = A with M;'''); |
| 2528 resolve(source); | 2832 resolve(source); |
| 2529 assertNoErrors(source); | 2833 assertNoErrors(source); |
| 2530 verify([source]); | 2834 verify([source]); |
| 2531 } | 2835 } |
| 2532 | 2836 |
| 2533 void test_nonAbstractClassInheritsAbstractMemberOne_mixin_getter() { | 2837 void test_nonAbstractClassInheritsAbstractMemberOne_mixin_getter() { |
| 2534 // 17034 | 2838 // 17034 |
| 2535 Source source = addSource(EngineTestCase.createSource([ | 2839 Source source = addSource(r''' |
| 2536 "class A {", | 2840 class A { |
| 2537 " var a;", | 2841 var a; |
| 2538 "}", | 2842 } |
| 2539 "abstract class M {", | 2843 abstract class M { |
| 2540 " get a;", | 2844 get a; |
| 2541 "}", | 2845 } |
| 2542 "class B extends A with M {}", | 2846 class B extends A with M {} |
| 2543 "class C extends B {}"])); | 2847 class C extends B {}'''); |
| 2544 resolve(source); | 2848 resolve(source); |
| 2545 assertNoErrors(source); | 2849 assertNoErrors(source); |
| 2546 verify([source]); | 2850 verify([source]); |
| 2547 } | 2851 } |
| 2548 | 2852 |
| 2549 void test_nonAbstractClassInheritsAbstractMemberOne_mixin_method() { | 2853 void test_nonAbstractClassInheritsAbstractMemberOne_mixin_method() { |
| 2550 Source source = addSource(EngineTestCase.createSource([ | 2854 Source source = addSource(r''' |
| 2551 "class A {", | 2855 class A { |
| 2552 " m() {}", | 2856 m() {} |
| 2553 "}", | 2857 } |
| 2554 "abstract class M {", | 2858 abstract class M { |
| 2555 " m();", | 2859 m(); |
| 2556 "}", | 2860 } |
| 2557 "class B extends A with M {}", | 2861 class B extends A with M {} |
| 2558 "class C extends B {}"])); | 2862 class C extends B {}'''); |
| 2559 resolve(source); | 2863 resolve(source); |
| 2560 assertNoErrors(source); | 2864 assertNoErrors(source); |
| 2561 verify([source]); | 2865 verify([source]); |
| 2562 } | 2866 } |
| 2563 | 2867 |
| 2564 void test_nonAbstractClassInheritsAbstractMemberOne_mixin_setter() { | 2868 void test_nonAbstractClassInheritsAbstractMemberOne_mixin_setter() { |
| 2565 Source source = addSource(EngineTestCase.createSource([ | 2869 Source source = addSource(r''' |
| 2566 "class A {", | 2870 class A { |
| 2567 " var a;", | 2871 var a; |
| 2568 "}", | 2872 } |
| 2569 "abstract class M {", | 2873 abstract class M { |
| 2570 " set a(dynamic v);", | 2874 set a(dynamic v); |
| 2571 "}", | 2875 } |
| 2572 "class B extends A with M {}", | 2876 class B extends A with M {} |
| 2573 "class C extends B {}"])); | 2877 class C extends B {}'''); |
| 2574 resolve(source); | 2878 resolve(source); |
| 2575 assertNoErrors(source); | 2879 assertNoErrors(source); |
| 2576 verify([source]); | 2880 verify([source]); |
| 2577 } | 2881 } |
| 2578 | 2882 |
| 2579 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() { | 2883 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() { |
| 2580 Source source = addSource(EngineTestCase.createSource([ | 2884 Source source = addSource(r''' |
| 2581 "abstract class A {", | 2885 abstract class A { |
| 2582 " int get g;", | 2886 int get g; |
| 2583 "}", | 2887 } |
| 2584 "class B extends A {", | 2888 class B extends A { |
| 2585 " noSuchMethod(v) => '';", | 2889 noSuchMethod(v) => ''; |
| 2586 "}"])); | 2890 }'''); |
| 2587 resolve(source); | 2891 resolve(source); |
| 2588 assertNoErrors(source); | 2892 assertNoErrors(source); |
| 2589 verify([source]); | 2893 verify([source]); |
| 2590 } | 2894 } |
| 2591 | 2895 |
| 2592 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() { | 2896 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() { |
| 2593 Source source = addSource(EngineTestCase.createSource([ | 2897 Source source = addSource(r''' |
| 2594 "abstract class A {", | 2898 abstract class A { |
| 2595 " m(p);", | 2899 m(p); |
| 2596 "}", | 2900 } |
| 2597 "class B extends A {", | 2901 class B extends A { |
| 2598 " noSuchMethod(v) => '';", | 2902 noSuchMethod(v) => ''; |
| 2599 "}"])); | 2903 }'''); |
| 2600 resolve(source); | 2904 resolve(source); |
| 2601 assertNoErrors(source); | 2905 assertNoErrors(source); |
| 2602 verify([source]); | 2906 verify([source]); |
| 2603 } | 2907 } |
| 2604 | 2908 |
| 2605 void test_nonBoolExpression_functionType() { | 2909 void test_nonBoolExpression_functionType() { |
| 2606 Source source = addSource(EngineTestCase.createSource([ | 2910 Source source = addSource(r''' |
| 2607 "bool makeAssertion() => true;", | 2911 bool makeAssertion() => true; |
| 2608 "f() {", | 2912 f() { |
| 2609 " assert(makeAssertion);", | 2913 assert(makeAssertion); |
| 2610 "}"])); | 2914 }'''); |
| 2611 resolve(source); | 2915 resolve(source); |
| 2612 assertNoErrors(source); | 2916 assertNoErrors(source); |
| 2613 verify([source]); | 2917 verify([source]); |
| 2614 } | 2918 } |
| 2615 | 2919 |
| 2616 void test_nonBoolExpression_interfaceType() { | 2920 void test_nonBoolExpression_interfaceType() { |
| 2617 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr
ue);", "}"])); | 2921 Source source = addSource(r''' |
| 2922 f() { |
| 2923 assert(true); |
| 2924 }'''); |
| 2618 resolve(source); | 2925 resolve(source); |
| 2619 assertNoErrors(source); | 2926 assertNoErrors(source); |
| 2620 verify([source]); | 2927 verify([source]); |
| 2621 } | 2928 } |
| 2622 | 2929 |
| 2623 void test_nonBoolNegationExpression() { | 2930 void test_nonBoolNegationExpression() { |
| 2624 Source source = addSource(EngineTestCase.createSource([ | 2931 Source source = addSource(r''' |
| 2625 "f(bool pb, pd) {", | 2932 f(bool pb, pd) { |
| 2626 " !true;", | 2933 !true; |
| 2627 " !false;", | 2934 !false; |
| 2628 " !pb;", | 2935 !pb; |
| 2629 " !pd;", | 2936 !pd; |
| 2630 "}"])); | 2937 }'''); |
| 2631 resolve(source); | 2938 resolve(source); |
| 2632 assertNoErrors(source); | 2939 assertNoErrors(source); |
| 2633 verify([source]); | 2940 verify([source]); |
| 2634 } | 2941 } |
| 2635 | 2942 |
| 2636 void test_nonBoolOperand_and_bool() { | 2943 void test_nonBoolOperand_and_bool() { |
| 2637 Source source = addSource(EngineTestCase.createSource([ | 2944 Source source = addSource(r''' |
| 2638 "bool f(bool left, bool right) {", | 2945 bool f(bool left, bool right) { |
| 2639 " return left && right;", | 2946 return left && right; |
| 2640 "}"])); | 2947 }'''); |
| 2641 resolve(source); | 2948 resolve(source); |
| 2642 assertNoErrors(source); | 2949 assertNoErrors(source); |
| 2643 verify([source]); | 2950 verify([source]); |
| 2644 } | 2951 } |
| 2645 | 2952 |
| 2646 void test_nonBoolOperand_and_dynamic() { | 2953 void test_nonBoolOperand_and_dynamic() { |
| 2647 Source source = addSource(EngineTestCase.createSource([ | 2954 Source source = addSource(r''' |
| 2648 "bool f(left, dynamic right) {", | 2955 bool f(left, dynamic right) { |
| 2649 " return left && right;", | 2956 return left && right; |
| 2650 "}"])); | 2957 }'''); |
| 2651 resolve(source); | 2958 resolve(source); |
| 2652 assertNoErrors(source); | 2959 assertNoErrors(source); |
| 2653 verify([source]); | 2960 verify([source]); |
| 2654 } | 2961 } |
| 2655 | 2962 |
| 2656 void test_nonBoolOperand_or_bool() { | 2963 void test_nonBoolOperand_or_bool() { |
| 2657 Source source = addSource(EngineTestCase.createSource([ | 2964 Source source = addSource(r''' |
| 2658 "bool f(bool left, bool right) {", | 2965 bool f(bool left, bool right) { |
| 2659 " return left || right;", | 2966 return left || right; |
| 2660 "}"])); | 2967 }'''); |
| 2661 resolve(source); | 2968 resolve(source); |
| 2662 assertNoErrors(source); | 2969 assertNoErrors(source); |
| 2663 verify([source]); | 2970 verify([source]); |
| 2664 } | 2971 } |
| 2665 | 2972 |
| 2666 void test_nonBoolOperand_or_dynamic() { | 2973 void test_nonBoolOperand_or_dynamic() { |
| 2667 Source source = addSource(EngineTestCase.createSource([ | 2974 Source source = addSource(r''' |
| 2668 "bool f(dynamic left, right) {", | 2975 bool f(dynamic left, right) { |
| 2669 " return left || right;", | 2976 return left || right; |
| 2670 "}"])); | 2977 }'''); |
| 2671 resolve(source); | 2978 resolve(source); |
| 2672 assertNoErrors(source); | 2979 assertNoErrors(source); |
| 2673 verify([source]); | 2980 verify([source]); |
| 2674 } | 2981 } |
| 2675 | 2982 |
| 2676 void test_nonConstantDefaultValue_function_named() { | 2983 void test_nonConstantDefaultValue_function_named() { |
| 2677 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"])
); | 2984 Source source = addSource("f({x : 2 + 3}) {}"); |
| 2678 resolve(source); | 2985 resolve(source); |
| 2679 assertNoErrors(source); | 2986 assertNoErrors(source); |
| 2680 verify([source]); | 2987 verify([source]); |
| 2681 } | 2988 } |
| 2682 | 2989 |
| 2683 void test_nonConstantDefaultValue_function_positional() { | 2990 void test_nonConstantDefaultValue_function_positional() { |
| 2684 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"])
); | 2991 Source source = addSource("f([x = 2 + 3]) {}"); |
| 2685 resolve(source); | 2992 resolve(source); |
| 2686 assertNoErrors(source); | 2993 assertNoErrors(source); |
| 2687 verify([source]); | 2994 verify([source]); |
| 2688 } | 2995 } |
| 2689 | 2996 |
| 2690 void test_nonConstantDefaultValue_inConstructor_named() { | 2997 void test_nonConstantDefaultValue_inConstructor_named() { |
| 2691 Source source = addSource(EngineTestCase.createSource(["class A {", " A({x
: 2 + 3}) {}", "}"])); | 2998 Source source = addSource(r''' |
| 2999 class A { |
| 3000 A({x : 2 + 3}) {} |
| 3001 }'''); |
| 2692 resolve(source); | 3002 resolve(source); |
| 2693 assertNoErrors(source); | 3003 assertNoErrors(source); |
| 2694 verify([source]); | 3004 verify([source]); |
| 2695 } | 3005 } |
| 2696 | 3006 |
| 2697 void test_nonConstantDefaultValue_inConstructor_positional() { | 3007 void test_nonConstantDefaultValue_inConstructor_positional() { |
| 2698 Source source = addSource(EngineTestCase.createSource(["class A {", " A([x
= 2 + 3]) {}", "}"])); | 3008 Source source = addSource(r''' |
| 3009 class A { |
| 3010 A([x = 2 + 3]) {} |
| 3011 }'''); |
| 2699 resolve(source); | 3012 resolve(source); |
| 2700 assertNoErrors(source); | 3013 assertNoErrors(source); |
| 2701 verify([source]); | 3014 verify([source]); |
| 2702 } | 3015 } |
| 2703 | 3016 |
| 2704 void test_nonConstantDefaultValue_method_named() { | 3017 void test_nonConstantDefaultValue_method_named() { |
| 2705 Source source = addSource(EngineTestCase.createSource(["class A {", " m({x
: 2 + 3}) {}", "}"])); | 3018 Source source = addSource(r''' |
| 3019 class A { |
| 3020 m({x : 2 + 3}) {} |
| 3021 }'''); |
| 2706 resolve(source); | 3022 resolve(source); |
| 2707 assertNoErrors(source); | 3023 assertNoErrors(source); |
| 2708 verify([source]); | 3024 verify([source]); |
| 2709 } | 3025 } |
| 2710 | 3026 |
| 2711 void test_nonConstantDefaultValue_method_positional() { | 3027 void test_nonConstantDefaultValue_method_positional() { |
| 2712 Source source = addSource(EngineTestCase.createSource(["class A {", " m([x
= 2 + 3]) {}", "}"])); | 3028 Source source = addSource(r''' |
| 3029 class A { |
| 3030 m([x = 2 + 3]) {} |
| 3031 }'''); |
| 2713 resolve(source); | 3032 resolve(source); |
| 2714 assertNoErrors(source); | 3033 assertNoErrors(source); |
| 2715 verify([source]); | 3034 verify([source]); |
| 2716 } | 3035 } |
| 2717 | 3036 |
| 2718 void test_nonConstantValueInInitializer_namedArgument() { | 3037 void test_nonConstantValueInInitializer_namedArgument() { |
| 2719 Source source = addSource(EngineTestCase.createSource([ | 3038 Source source = addSource(r''' |
| 2720 "class A {", | 3039 class A { |
| 2721 " final a;", | 3040 final a; |
| 2722 " const A({this.a});", | 3041 const A({this.a}); |
| 2723 "}", | 3042 } |
| 2724 "class B extends A {", | 3043 class B extends A { |
| 2725 " const B({b}) : super(a: b);", | 3044 const B({b}) : super(a: b); |
| 2726 "}"])); | 3045 }'''); |
| 2727 resolve(source); | 3046 resolve(source); |
| 2728 assertNoErrors(source); | 3047 assertNoErrors(source); |
| 2729 verify([source]); | 3048 verify([source]); |
| 2730 } | 3049 } |
| 2731 | 3050 |
| 2732 void test_nonConstCaseExpression() { | 3051 void test_nonConstCaseExpression() { |
| 2733 Source source = addSource(EngineTestCase.createSource([ | 3052 Source source = addSource(r''' |
| 2734 "f(Type t) {", | 3053 f(Type t) { |
| 2735 " switch (t) {", | 3054 switch (t) { |
| 2736 " case bool:", | 3055 case bool: |
| 2737 " case int:", | 3056 case int: |
| 2738 " return true;", | 3057 return true; |
| 2739 " default:", | 3058 default: |
| 2740 " return false;", | 3059 return false; |
| 2741 " }", | 3060 } |
| 2742 "}"])); | 3061 }'''); |
| 2743 resolve(source); | 3062 resolve(source); |
| 2744 assertNoErrors(source); | 3063 assertNoErrors(source); |
| 2745 verify([source]); | 3064 verify([source]); |
| 2746 } | 3065 } |
| 2747 | 3066 |
| 2748 void test_nonConstMapAsExpressionStatement_const() { | 3067 void test_nonConstMapAsExpressionStatement_const() { |
| 2749 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a
' : 0, 'b' : 1};", "}"])); | 3068 Source source = addSource(r''' |
| 3069 f() { |
| 3070 const {'a' : 0, 'b' : 1}; |
| 3071 }'''); |
| 2750 resolve(source); | 3072 resolve(source); |
| 2751 assertNoErrors(source); | 3073 assertNoErrors(source); |
| 2752 verify([source]); | 3074 verify([source]); |
| 2753 } | 3075 } |
| 2754 | 3076 |
| 2755 void test_nonConstMapAsExpressionStatement_notExpressionStatement() { | 3077 void test_nonConstMapAsExpressionStatement_notExpressionStatement() { |
| 2756 Source source = addSource(EngineTestCase.createSource(["f() {", " var m = {
'a' : 0, 'b' : 1};", "}"])); | 3078 Source source = addSource(r''' |
| 3079 f() { |
| 3080 var m = {'a' : 0, 'b' : 1}; |
| 3081 }'''); |
| 2757 resolve(source); | 3082 resolve(source); |
| 2758 assertNoErrors(source); | 3083 assertNoErrors(source); |
| 2759 verify([source]); | 3084 verify([source]); |
| 2760 } | 3085 } |
| 2761 | 3086 |
| 2762 void test_nonConstMapAsExpressionStatement_typeArguments() { | 3087 void test_nonConstMapAsExpressionStatement_typeArguments() { |
| 2763 Source source = addSource(EngineTestCase.createSource(["f() {", " <String,
int> {'a' : 0, 'b' : 1};", "}"])); | 3088 Source source = addSource(r''' |
| 3089 f() { |
| 3090 <String, int> {'a' : 0, 'b' : 1}; |
| 3091 }'''); |
| 2764 resolve(source); | 3092 resolve(source); |
| 2765 assertNoErrors(source); | 3093 assertNoErrors(source); |
| 2766 verify([source]); | 3094 verify([source]); |
| 2767 } | 3095 } |
| 2768 | 3096 |
| 2769 void test_nonConstValueInInitializer_binary_bool() { | 3097 void test_nonConstValueInInitializer_binary_bool() { |
| 2770 Source source = addSource(EngineTestCase.createSource([ | 3098 Source source = addSource(r''' |
| 2771 "class A {", | 3099 class A { |
| 2772 " final v;", | 3100 final v; |
| 2773 " const A.a1(bool p) : v = p && true;", | 3101 const A.a1(bool p) : v = p && true; |
| 2774 " const A.a2(bool p) : v = true && p;", | 3102 const A.a2(bool p) : v = true && p; |
| 2775 " const A.b1(bool p) : v = p || true;", | 3103 const A.b1(bool p) : v = p || true; |
| 2776 " const A.b2(bool p) : v = true || p;", | 3104 const A.b2(bool p) : v = true || p; |
| 2777 "}"])); | 3105 }'''); |
| 2778 resolve(source); | 3106 resolve(source); |
| 2779 assertErrors(source, [HintCode.DEAD_CODE]); | 3107 assertErrors(source, [HintCode.DEAD_CODE]); |
| 2780 verify([source]); | 3108 verify([source]); |
| 2781 } | 3109 } |
| 2782 | 3110 |
| 2783 void test_nonConstValueInInitializer_binary_dynamic() { | 3111 void test_nonConstValueInInitializer_binary_dynamic() { |
| 2784 Source source = addSource(EngineTestCase.createSource([ | 3112 Source source = addSource(r''' |
| 2785 "class A {", | 3113 class A { |
| 2786 " final v;", | 3114 final v; |
| 2787 " const A.a1(p) : v = p + 5;", | 3115 const A.a1(p) : v = p + 5; |
| 2788 " const A.a2(p) : v = 5 + p;", | 3116 const A.a2(p) : v = 5 + p; |
| 2789 " const A.b1(p) : v = p - 5;", | 3117 const A.b1(p) : v = p - 5; |
| 2790 " const A.b2(p) : v = 5 - p;", | 3118 const A.b2(p) : v = 5 - p; |
| 2791 " const A.c1(p) : v = p * 5;", | 3119 const A.c1(p) : v = p * 5; |
| 2792 " const A.c2(p) : v = 5 * p;", | 3120 const A.c2(p) : v = 5 * p; |
| 2793 " const A.d1(p) : v = p / 5;", | 3121 const A.d1(p) : v = p / 5; |
| 2794 " const A.d2(p) : v = 5 / p;", | 3122 const A.d2(p) : v = 5 / p; |
| 2795 " const A.e1(p) : v = p ~/ 5;", | 3123 const A.e1(p) : v = p ~/ 5; |
| 2796 " const A.e2(p) : v = 5 ~/ p;", | 3124 const A.e2(p) : v = 5 ~/ p; |
| 2797 " const A.f1(p) : v = p > 5;", | 3125 const A.f1(p) : v = p > 5; |
| 2798 " const A.f2(p) : v = 5 > p;", | 3126 const A.f2(p) : v = 5 > p; |
| 2799 " const A.g1(p) : v = p < 5;", | 3127 const A.g1(p) : v = p < 5; |
| 2800 " const A.g2(p) : v = 5 < p;", | 3128 const A.g2(p) : v = 5 < p; |
| 2801 " const A.h1(p) : v = p >= 5;", | 3129 const A.h1(p) : v = p >= 5; |
| 2802 " const A.h2(p) : v = 5 >= p;", | 3130 const A.h2(p) : v = 5 >= p; |
| 2803 " const A.i1(p) : v = p <= 5;", | 3131 const A.i1(p) : v = p <= 5; |
| 2804 " const A.i2(p) : v = 5 <= p;", | 3132 const A.i2(p) : v = 5 <= p; |
| 2805 " const A.j1(p) : v = p % 5;", | 3133 const A.j1(p) : v = p % 5; |
| 2806 " const A.j2(p) : v = 5 % p;", | 3134 const A.j2(p) : v = 5 % p; |
| 2807 "}"])); | 3135 }'''); |
| 2808 resolve(source); | 3136 resolve(source); |
| 2809 assertNoErrors(source); | 3137 assertNoErrors(source); |
| 2810 // operations on "p" are not resolved | 3138 // operations on "p" are not resolved |
| 2811 } | 3139 } |
| 2812 | 3140 |
| 2813 void test_nonConstValueInInitializer_binary_int() { | 3141 void test_nonConstValueInInitializer_binary_int() { |
| 2814 Source source = addSource(EngineTestCase.createSource([ | 3142 Source source = addSource(r''' |
| 2815 "class A {", | 3143 class A { |
| 2816 " final v;", | 3144 final v; |
| 2817 " const A.a1(int p) : v = p ^ 5;", | 3145 const A.a1(int p) : v = p ^ 5; |
| 2818 " const A.a2(int p) : v = 5 ^ p;", | 3146 const A.a2(int p) : v = 5 ^ p; |
| 2819 " const A.b1(int p) : v = p & 5;", | 3147 const A.b1(int p) : v = p & 5; |
| 2820 " const A.b2(int p) : v = 5 & p;", | 3148 const A.b2(int p) : v = 5 & p; |
| 2821 " const A.c1(int p) : v = p | 5;", | 3149 const A.c1(int p) : v = p | 5; |
| 2822 " const A.c2(int p) : v = 5 | p;", | 3150 const A.c2(int p) : v = 5 | p; |
| 2823 " const A.d1(int p) : v = p >> 5;", | 3151 const A.d1(int p) : v = p >> 5; |
| 2824 " const A.d2(int p) : v = 5 >> p;", | 3152 const A.d2(int p) : v = 5 >> p; |
| 2825 " const A.e1(int p) : v = p << 5;", | 3153 const A.e1(int p) : v = p << 5; |
| 2826 " const A.e2(int p) : v = 5 << p;", | 3154 const A.e2(int p) : v = 5 << p; |
| 2827 "}"])); | 3155 }'''); |
| 2828 resolve(source); | 3156 resolve(source); |
| 2829 assertNoErrors(source); | 3157 assertNoErrors(source); |
| 2830 verify([source]); | 3158 verify([source]); |
| 2831 } | 3159 } |
| 2832 | 3160 |
| 2833 void test_nonConstValueInInitializer_binary_num() { | 3161 void test_nonConstValueInInitializer_binary_num() { |
| 2834 Source source = addSource(EngineTestCase.createSource([ | 3162 Source source = addSource(r''' |
| 2835 "class A {", | 3163 class A { |
| 2836 " final v;", | 3164 final v; |
| 2837 " const A.a1(num p) : v = p + 5;", | 3165 const A.a1(num p) : v = p + 5; |
| 2838 " const A.a2(num p) : v = 5 + p;", | 3166 const A.a2(num p) : v = 5 + p; |
| 2839 " const A.b1(num p) : v = p - 5;", | 3167 const A.b1(num p) : v = p - 5; |
| 2840 " const A.b2(num p) : v = 5 - p;", | 3168 const A.b2(num p) : v = 5 - p; |
| 2841 " const A.c1(num p) : v = p * 5;", | 3169 const A.c1(num p) : v = p * 5; |
| 2842 " const A.c2(num p) : v = 5 * p;", | 3170 const A.c2(num p) : v = 5 * p; |
| 2843 " const A.d1(num p) : v = p / 5;", | 3171 const A.d1(num p) : v = p / 5; |
| 2844 " const A.d2(num p) : v = 5 / p;", | 3172 const A.d2(num p) : v = 5 / p; |
| 2845 " const A.e1(num p) : v = p ~/ 5;", | 3173 const A.e1(num p) : v = p ~/ 5; |
| 2846 " const A.e2(num p) : v = 5 ~/ p;", | 3174 const A.e2(num p) : v = 5 ~/ p; |
| 2847 " const A.f1(num p) : v = p > 5;", | 3175 const A.f1(num p) : v = p > 5; |
| 2848 " const A.f2(num p) : v = 5 > p;", | 3176 const A.f2(num p) : v = 5 > p; |
| 2849 " const A.g1(num p) : v = p < 5;", | 3177 const A.g1(num p) : v = p < 5; |
| 2850 " const A.g2(num p) : v = 5 < p;", | 3178 const A.g2(num p) : v = 5 < p; |
| 2851 " const A.h1(num p) : v = p >= 5;", | 3179 const A.h1(num p) : v = p >= 5; |
| 2852 " const A.h2(num p) : v = 5 >= p;", | 3180 const A.h2(num p) : v = 5 >= p; |
| 2853 " const A.i1(num p) : v = p <= 5;", | 3181 const A.i1(num p) : v = p <= 5; |
| 2854 " const A.i2(num p) : v = 5 <= p;", | 3182 const A.i2(num p) : v = 5 <= p; |
| 2855 " const A.j1(num p) : v = p % 5;", | 3183 const A.j1(num p) : v = p % 5; |
| 2856 " const A.j2(num p) : v = 5 % p;", | 3184 const A.j2(num p) : v = 5 % p; |
| 2857 "}"])); | 3185 }'''); |
| 2858 resolve(source); | 3186 resolve(source); |
| 2859 assertNoErrors(source); | 3187 assertNoErrors(source); |
| 2860 verify([source]); | 3188 verify([source]); |
| 2861 } | 3189 } |
| 2862 | 3190 |
| 2863 void test_nonConstValueInInitializer_field() { | 3191 void test_nonConstValueInInitializer_field() { |
| 2864 Source source = addSource(EngineTestCase.createSource([ | 3192 Source source = addSource(r''' |
| 2865 "class A {", | 3193 class A { |
| 2866 " final int a;", | 3194 final int a; |
| 2867 " const A() : a = 5;", | 3195 const A() : a = 5; |
| 2868 "}"])); | 3196 }'''); |
| 2869 resolve(source); | 3197 resolve(source); |
| 2870 assertNoErrors(source); | 3198 assertNoErrors(source); |
| 2871 verify([source]); | 3199 verify([source]); |
| 2872 } | 3200 } |
| 2873 | 3201 |
| 2874 void test_nonConstValueInInitializer_redirecting() { | 3202 void test_nonConstValueInInitializer_redirecting() { |
| 2875 Source source = addSource(EngineTestCase.createSource([ | 3203 Source source = addSource(r''' |
| 2876 "class A {", | 3204 class A { |
| 2877 " const A.named(p);", | 3205 const A.named(p); |
| 2878 " const A() : this.named(42);", | 3206 const A() : this.named(42); |
| 2879 "}"])); | 3207 }'''); |
| 2880 resolve(source); | 3208 resolve(source); |
| 2881 assertNoErrors(source); | 3209 assertNoErrors(source); |
| 2882 verify([source]); | 3210 verify([source]); |
| 2883 } | 3211 } |
| 2884 | 3212 |
| 2885 void test_nonConstValueInInitializer_super() { | 3213 void test_nonConstValueInInitializer_super() { |
| 2886 Source source = addSource(EngineTestCase.createSource([ | 3214 Source source = addSource(r''' |
| 2887 "class A {", | 3215 class A { |
| 2888 " const A(p);", | 3216 const A(p); |
| 2889 "}", | 3217 } |
| 2890 "class B extends A {", | 3218 class B extends A { |
| 2891 " const B() : super(42);", | 3219 const B() : super(42); |
| 2892 "}"])); | 3220 }'''); |
| 2893 resolve(source); | 3221 resolve(source); |
| 2894 assertNoErrors(source); | 3222 assertNoErrors(source); |
| 2895 verify([source]); | 3223 verify([source]); |
| 2896 } | 3224 } |
| 2897 | 3225 |
| 2898 void test_nonConstValueInInitializer_unary() { | 3226 void test_nonConstValueInInitializer_unary() { |
| 2899 Source source = addSource(EngineTestCase.createSource([ | 3227 Source source = addSource(r''' |
| 2900 "class A {", | 3228 class A { |
| 2901 " final v;", | 3229 final v; |
| 2902 " const A.a(bool p) : v = !p;", | 3230 const A.a(bool p) : v = !p; |
| 2903 " const A.b(int p) : v = ~p;", | 3231 const A.b(int p) : v = ~p; |
| 2904 " const A.c(num p) : v = -p;", | 3232 const A.c(num p) : v = -p; |
| 2905 "}"])); | 3233 }'''); |
| 2906 resolve(source); | 3234 resolve(source); |
| 2907 assertNoErrors(source); | 3235 assertNoErrors(source); |
| 2908 verify([source]); | 3236 verify([source]); |
| 2909 } | 3237 } |
| 2910 | 3238 |
| 2911 void test_nonGenerativeConstructor() { | 3239 void test_nonGenerativeConstructor() { |
| 2912 Source source = addSource(EngineTestCase.createSource([ | 3240 Source source = addSource(r''' |
| 2913 "class A {", | 3241 class A { |
| 2914 " A.named() {}", | 3242 A.named() {} |
| 2915 " factory A() {}", | 3243 factory A() {} |
| 2916 "}", | 3244 } |
| 2917 "class B extends A {", | 3245 class B extends A { |
| 2918 " B() : super.named();", | 3246 B() : super.named(); |
| 2919 "}"])); | 3247 }'''); |
| 2920 resolve(source); | 3248 resolve(source); |
| 2921 assertNoErrors(source); | 3249 assertNoErrors(source); |
| 2922 verify([source]); | 3250 verify([source]); |
| 2923 } | 3251 } |
| 2924 | 3252 |
| 2925 void test_nonTypeInCatchClause_isClass() { | 3253 void test_nonTypeInCatchClause_isClass() { |
| 2926 Source source = addSource(EngineTestCase.createSource([ | 3254 Source source = addSource(r''' |
| 2927 "f() {", | 3255 f() { |
| 2928 " try {", | 3256 try { |
| 2929 " } on String catch (e) {", | 3257 } on String catch (e) { |
| 2930 " }", | 3258 } |
| 2931 "}"])); | 3259 }'''); |
| 2932 resolve(source); | 3260 resolve(source); |
| 2933 assertNoErrors(source); | 3261 assertNoErrors(source); |
| 2934 verify([source]); | 3262 verify([source]); |
| 2935 } | 3263 } |
| 2936 | 3264 |
| 2937 void test_nonTypeInCatchClause_isFunctionTypeAlias() { | 3265 void test_nonTypeInCatchClause_isFunctionTypeAlias() { |
| 2938 Source source = addSource(EngineTestCase.createSource([ | 3266 Source source = addSource(r''' |
| 2939 "typedef F();", | 3267 typedef F(); |
| 2940 "f() {", | 3268 f() { |
| 2941 " try {", | 3269 try { |
| 2942 " } on F catch (e) {", | 3270 } on F catch (e) { |
| 2943 " }", | 3271 } |
| 2944 "}"])); | 3272 }'''); |
| 2945 resolve(source); | 3273 resolve(source); |
| 2946 assertNoErrors(source); | 3274 assertNoErrors(source); |
| 2947 verify([source]); | 3275 verify([source]); |
| 2948 } | 3276 } |
| 2949 | 3277 |
| 2950 void test_nonTypeInCatchClause_isTypeParameter() { | 3278 void test_nonTypeInCatchClause_isTypeParameter() { |
| 2951 Source source = addSource(EngineTestCase.createSource([ | 3279 Source source = addSource(r''' |
| 2952 "class A<T> {", | 3280 class A<T> { |
| 2953 " f() {", | 3281 f() { |
| 2954 " try {", | 3282 try { |
| 2955 " } on T catch (e) {", | 3283 } on T catch (e) { |
| 2956 " }", | 3284 } |
| 2957 " }", | 3285 } |
| 2958 "}"])); | 3286 }'''); |
| 2959 resolve(source); | 3287 resolve(source); |
| 2960 assertNoErrors(source); | 3288 assertNoErrors(source); |
| 2961 verify([source]); | 3289 verify([source]); |
| 2962 } | 3290 } |
| 2963 | 3291 |
| 2964 void test_nonTypeInCatchClause_noType() { | 3292 void test_nonTypeInCatchClause_noType() { |
| 2965 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} catch (e) {", " }", "}"])); | 3293 Source source = addSource(r''' |
| 3294 f() { |
| 3295 try { |
| 3296 } catch (e) { |
| 3297 } |
| 3298 }'''); |
| 2966 resolve(source); | 3299 resolve(source); |
| 2967 assertNoErrors(source); | 3300 assertNoErrors(source); |
| 2968 verify([source]); | 3301 verify([source]); |
| 2969 } | 3302 } |
| 2970 | 3303 |
| 2971 void test_nonVoidReturnForOperator_no() { | 3304 void test_nonVoidReturnForOperator_no() { |
| 2972 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); | 3305 Source source = addSource(r''' |
| 3306 class A { |
| 3307 operator []=(a, b) {} |
| 3308 }'''); |
| 2973 resolve(source); | 3309 resolve(source); |
| 2974 assertNoErrors(source); | 3310 assertNoErrors(source); |
| 2975 verify([source]); | 3311 verify([source]); |
| 2976 } | 3312 } |
| 2977 | 3313 |
| 2978 void test_nonVoidReturnForOperator_void() { | 3314 void test_nonVoidReturnForOperator_void() { |
| 2979 Source source = addSource(EngineTestCase.createSource(["class A {", " void
operator []=(a, b) {}", "}"])); | 3315 Source source = addSource(r''' |
| 2980 resolve(source); | 3316 class A { |
| 2981 assertNoErrors(source); | 3317 void operator []=(a, b) {} |
| 2982 verify([source]); | 3318 }'''); |
| 3319 resolve(source); |
| 3320 assertNoErrors(source); |
| 3321 verify([source]); |
| 2983 } | 3322 } |
| 2984 | 3323 |
| 2985 void test_nonVoidReturnForSetter_function_no() { | 3324 void test_nonVoidReturnForSetter_function_no() { |
| 2986 Source source = addSource("set x(v) {}"); | 3325 Source source = addSource("set x(v) {}"); |
| 2987 resolve(source); | 3326 resolve(source); |
| 2988 assertNoErrors(source); | 3327 assertNoErrors(source); |
| 2989 verify([source]); | 3328 verify([source]); |
| 2990 } | 3329 } |
| 2991 | 3330 |
| 2992 void test_nonVoidReturnForSetter_function_void() { | 3331 void test_nonVoidReturnForSetter_function_void() { |
| 2993 Source source = addSource("void set x(v) {}"); | 3332 Source source = addSource("void set x(v) {}"); |
| 2994 resolve(source); | 3333 resolve(source); |
| 2995 assertNoErrors(source); | 3334 assertNoErrors(source); |
| 2996 verify([source]); | 3335 verify([source]); |
| 2997 } | 3336 } |
| 2998 | 3337 |
| 2999 void test_nonVoidReturnForSetter_method_no() { | 3338 void test_nonVoidReturnForSetter_method_no() { |
| 3000 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(v) {}", "}"])); | 3339 Source source = addSource(r''' |
| 3340 class A { |
| 3341 set x(v) {} |
| 3342 }'''); |
| 3001 resolve(source); | 3343 resolve(source); |
| 3002 assertNoErrors(source); | 3344 assertNoErrors(source); |
| 3003 verify([source]); | 3345 verify([source]); |
| 3004 } | 3346 } |
| 3005 | 3347 |
| 3006 void test_nonVoidReturnForSetter_method_void() { | 3348 void test_nonVoidReturnForSetter_method_void() { |
| 3007 Source source = addSource(EngineTestCase.createSource(["class A {", " void
set x(v) {}", "}"])); | 3349 Source source = addSource(r''' |
| 3350 class A { |
| 3351 void set x(v) {} |
| 3352 }'''); |
| 3008 resolve(source); | 3353 resolve(source); |
| 3009 assertNoErrors(source); | 3354 assertNoErrors(source); |
| 3010 verify([source]); | 3355 verify([source]); |
| 3011 } | 3356 } |
| 3012 | 3357 |
| 3013 void test_null_callMethod() { | 3358 void test_null_callMethod() { |
| 3014 Source source = addSource(EngineTestCase.createSource(["main() {", " null.m
();", "}"])); | 3359 Source source = addSource(r''' |
| 3360 main() { |
| 3361 null.m(); |
| 3362 }'''); |
| 3015 resolve(source); | 3363 resolve(source); |
| 3016 assertNoErrors(source); | 3364 assertNoErrors(source); |
| 3017 } | 3365 } |
| 3018 | 3366 |
| 3019 void test_null_callOperator() { | 3367 void test_null_callOperator() { |
| 3020 Source source = addSource(EngineTestCase.createSource([ | 3368 Source source = addSource(r''' |
| 3021 "main() {", | 3369 main() { |
| 3022 " null + 5;", | 3370 null + 5; |
| 3023 " null == 5;", | 3371 null == 5; |
| 3024 " null[0];", | 3372 null[0]; |
| 3025 "}"])); | 3373 }'''); |
| 3026 resolve(source); | 3374 resolve(source); |
| 3027 assertNoErrors(source); | 3375 assertNoErrors(source); |
| 3028 } | 3376 } |
| 3029 | 3377 |
| 3030 void test_optionalParameterInOperator_required() { | 3378 void test_optionalParameterInOperator_required() { |
| 3031 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +(p) {}", "}"])); | 3379 Source source = addSource(r''' |
| 3380 class A { |
| 3381 operator +(p) {} |
| 3382 }'''); |
| 3032 resolve(source); | 3383 resolve(source); |
| 3033 assertNoErrors(source); | 3384 assertNoErrors(source); |
| 3034 verify([source]); | 3385 verify([source]); |
| 3035 } | 3386 } |
| 3036 | 3387 |
| 3037 void test_prefixCollidesWithTopLevelMembers() { | 3388 void test_prefixCollidesWithTopLevelMembers() { |
| 3038 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "cl
ass A {}"])); | 3389 addNamedSource("/lib.dart", r''' |
| 3039 Source source = addSource(EngineTestCase.createSource([ | 3390 library lib; |
| 3040 "import 'lib.dart' as p;", | 3391 class A {}'''); |
| 3041 "typedef P();", | 3392 Source source = addSource(r''' |
| 3042 "p2() {}", | 3393 import 'lib.dart' as p; |
| 3043 "var p3;", | 3394 typedef P(); |
| 3044 "class p4 {}", | 3395 p2() {} |
| 3045 "p.A a;"])); | 3396 var p3; |
| 3397 class p4 {} |
| 3398 p.A a;'''); |
| 3046 resolve(source); | 3399 resolve(source); |
| 3047 assertNoErrors(source); | 3400 assertNoErrors(source); |
| 3048 verify([source]); | 3401 verify([source]); |
| 3049 } | 3402 } |
| 3050 | 3403 |
| 3051 void test_propagateTypeArgs_intoBounds() { | 3404 void test_propagateTypeArgs_intoBounds() { |
| 3052 Source source = addSource(EngineTestCase.createSource([ | 3405 Source source = addSource(r''' |
| 3053 "abstract class A<E> {}", | 3406 abstract class A<E> {} |
| 3054 "abstract class B<F> implements A<F>{}", | 3407 abstract class B<F> implements A<F>{} |
| 3055 "abstract class C<G, H extends A<G>> {}", | 3408 abstract class C<G, H extends A<G>> {} |
| 3056 "class D<I> extends C<I, B<I>> {}"])); | 3409 class D<I> extends C<I, B<I>> {}'''); |
| 3057 resolve(source); | 3410 resolve(source); |
| 3058 assertNoErrors(source); | 3411 assertNoErrors(source); |
| 3059 verify([source]); | 3412 verify([source]); |
| 3060 } | 3413 } |
| 3061 | 3414 |
| 3062 void test_propagateTypeArgs_intoSupertype() { | 3415 void test_propagateTypeArgs_intoSupertype() { |
| 3063 Source source = addSource(EngineTestCase.createSource([ | 3416 Source source = addSource(r''' |
| 3064 "class A<T> {", | 3417 class A<T> { |
| 3065 " A(T p);", | 3418 A(T p); |
| 3066 " A.named(T p);", | 3419 A.named(T p); |
| 3067 "}", | 3420 } |
| 3068 "class B<S> extends A<S> {", | 3421 class B<S> extends A<S> { |
| 3069 " B(S p) : super(p);", | 3422 B(S p) : super(p); |
| 3070 " B.named(S p) : super.named(p);", | 3423 B.named(S p) : super.named(p); |
| 3071 "}"])); | 3424 }'''); |
| 3072 resolve(source); | 3425 resolve(source); |
| 3073 assertNoErrors(source); | 3426 assertNoErrors(source); |
| 3074 verify([source]); | 3427 verify([source]); |
| 3075 } | 3428 } |
| 3076 | 3429 |
| 3077 void test_proxy_annotation_prefixed() { | 3430 void test_proxy_annotation_prefixed() { |
| 3078 Source source = addSource(EngineTestCase.createSource([ | 3431 Source source = addSource(r''' |
| 3079 "library L;", | 3432 library L; |
| 3080 "@proxy", | 3433 @proxy |
| 3081 "class A {}", | 3434 class A {} |
| 3082 "f(A a) {", | 3435 f(A a) { |
| 3083 " a.m();", | 3436 a.m(); |
| 3084 " var x = a.g;", | 3437 var x = a.g; |
| 3085 " a.s = 1;", | 3438 a.s = 1; |
| 3086 " var y = a + a;", | 3439 var y = a + a; |
| 3087 " a++;", | 3440 a++; |
| 3088 " ++a;", | 3441 ++a; |
| 3089 "}"])); | 3442 }'''); |
| 3090 resolve(source); | 3443 resolve(source); |
| 3091 assertNoErrors(source); | 3444 assertNoErrors(source); |
| 3092 } | 3445 } |
| 3093 | 3446 |
| 3094 void test_proxy_annotation_prefixed2() { | 3447 void test_proxy_annotation_prefixed2() { |
| 3095 Source source = addSource(EngineTestCase.createSource([ | 3448 Source source = addSource(r''' |
| 3096 "library L;", | 3449 library L; |
| 3097 "@proxy", | 3450 @proxy |
| 3098 "class A {}", | 3451 class A {} |
| 3099 "class B {", | 3452 class B { |
| 3100 " f(A a) {", | 3453 f(A a) { |
| 3101 " a.m();", | 3454 a.m(); |
| 3102 " var x = a.g;", | 3455 var x = a.g; |
| 3103 " a.s = 1;", | 3456 a.s = 1; |
| 3104 " var y = a + a;", | 3457 var y = a + a; |
| 3105 " a++;", | 3458 a++; |
| 3106 " ++a;", | 3459 ++a; |
| 3107 " }", | 3460 } |
| 3108 "}"])); | 3461 }'''); |
| 3109 resolve(source); | 3462 resolve(source); |
| 3110 assertNoErrors(source); | 3463 assertNoErrors(source); |
| 3111 } | 3464 } |
| 3112 | 3465 |
| 3113 void test_proxy_annotation_prefixed3() { | 3466 void test_proxy_annotation_prefixed3() { |
| 3114 Source source = addSource(EngineTestCase.createSource([ | 3467 Source source = addSource(r''' |
| 3115 "library L;", | 3468 library L; |
| 3116 "class B {", | 3469 class B { |
| 3117 " f(A a) {", | 3470 f(A a) { |
| 3118 " a.m();", | 3471 a.m(); |
| 3119 " var x = a.g;", | 3472 var x = a.g; |
| 3120 " a.s = 1;", | 3473 a.s = 1; |
| 3121 " var y = a + a;", | 3474 var y = a + a; |
| 3122 " a++;", | 3475 a++; |
| 3123 " ++a;", | 3476 ++a; |
| 3124 " }", | 3477 } |
| 3125 "}", | 3478 } |
| 3126 "@proxy", | 3479 @proxy |
| 3127 "class A {}"])); | 3480 class A {}'''); |
| 3128 resolve(source); | 3481 resolve(source); |
| 3129 assertNoErrors(source); | 3482 assertNoErrors(source); |
| 3130 } | 3483 } |
| 3131 | 3484 |
| 3132 void test_proxy_annotation_proxyHasPrefixedIdentifier() { | 3485 void test_proxy_annotation_proxyHasPrefixedIdentifier() { |
| 3133 Source source = addSource(EngineTestCase.createSource([ | 3486 Source source = addSource(r''' |
| 3134 "library L;", | 3487 library L; |
| 3135 "import 'dart:core' as core;", | 3488 import 'dart:core' as core; |
| 3136 "@core.proxy class PrefixProxy {}", | 3489 @core.proxy class PrefixProxy {} |
| 3137 "main() {", | 3490 main() { |
| 3138 " new PrefixProxy().foo;", | 3491 new PrefixProxy().foo; |
| 3139 " new PrefixProxy().foo();", | 3492 new PrefixProxy().foo(); |
| 3140 "}"])); | 3493 }'''); |
| 3141 resolve(source); | 3494 resolve(source); |
| 3142 assertNoErrors(source); | 3495 assertNoErrors(source); |
| 3143 } | 3496 } |
| 3144 | 3497 |
| 3145 void test_proxy_annotation_simple() { | 3498 void test_proxy_annotation_simple() { |
| 3146 Source source = addSource(EngineTestCase.createSource([ | 3499 Source source = addSource(r''' |
| 3147 "library L;", | 3500 library L; |
| 3148 "@proxy", | 3501 @proxy |
| 3149 "class B {", | 3502 class B { |
| 3150 " m() {", | 3503 m() { |
| 3151 " n();", | 3504 n(); |
| 3152 " var x = g;", | 3505 var x = g; |
| 3153 " s = 1;", | 3506 s = 1; |
| 3154 " var y = this + this;", | 3507 var y = this + this; |
| 3155 " }", | 3508 } |
| 3156 "}"])); | 3509 }'''); |
| 3157 resolve(source); | 3510 resolve(source); |
| 3158 assertNoErrors(source); | 3511 assertNoErrors(source); |
| 3159 } | 3512 } |
| 3160 | 3513 |
| 3161 void test_proxy_annotation_superclass() { | 3514 void test_proxy_annotation_superclass() { |
| 3162 Source source = addSource(EngineTestCase.createSource([ | 3515 Source source = addSource(r''' |
| 3163 "library L;", | 3516 library L; |
| 3164 "class B extends A {", | 3517 class B extends A { |
| 3165 " m() {", | 3518 m() { |
| 3166 " n();", | 3519 n(); |
| 3167 " var x = g;", | 3520 var x = g; |
| 3168 " s = 1;", | 3521 s = 1; |
| 3169 " var y = this + this;", | 3522 var y = this + this; |
| 3170 " }", | 3523 } |
| 3171 "}", | 3524 } |
| 3172 "@proxy", | 3525 @proxy |
| 3173 "class A {}"])); | 3526 class A {}'''); |
| 3174 resolve(source); | 3527 resolve(source); |
| 3175 assertNoErrors(source); | 3528 assertNoErrors(source); |
| 3176 } | 3529 } |
| 3177 | 3530 |
| 3178 void test_proxy_annotation_superclass_mixin() { | 3531 void test_proxy_annotation_superclass_mixin() { |
| 3179 Source source = addSource(EngineTestCase.createSource([ | 3532 Source source = addSource(r''' |
| 3180 "library L;", | 3533 library L; |
| 3181 "class B extends Object with A {", | 3534 class B extends Object with A { |
| 3182 " m() {", | 3535 m() { |
| 3183 " n();", | 3536 n(); |
| 3184 " var x = g;", | 3537 var x = g; |
| 3185 " s = 1;", | 3538 s = 1; |
| 3186 " var y = this + this;", | 3539 var y = this + this; |
| 3187 " }", | 3540 } |
| 3188 "}", | 3541 } |
| 3189 "@proxy", | 3542 @proxy |
| 3190 "class A {}"])); | 3543 class A {}'''); |
| 3191 resolve(source); | 3544 resolve(source); |
| 3192 assertNoErrors(source); | 3545 assertNoErrors(source); |
| 3193 } | 3546 } |
| 3194 | 3547 |
| 3195 void test_proxy_annotation_superinterface() { | 3548 void test_proxy_annotation_superinterface() { |
| 3196 Source source = addSource(EngineTestCase.createSource([ | 3549 Source source = addSource(r''' |
| 3197 "library L;", | 3550 library L; |
| 3198 "class B implements A {", | 3551 class B implements A { |
| 3199 " m() {", | 3552 m() { |
| 3200 " n();", | 3553 n(); |
| 3201 " var x = g;", | 3554 var x = g; |
| 3202 " s = 1;", | 3555 s = 1; |
| 3203 " var y = this + this;", | 3556 var y = this + this; |
| 3204 " }", | 3557 } |
| 3205 "}", | 3558 } |
| 3206 "@proxy", | 3559 @proxy |
| 3207 "class A {}"])); | 3560 class A {}'''); |
| 3208 resolve(source); | 3561 resolve(source); |
| 3209 assertNoErrors(source); | 3562 assertNoErrors(source); |
| 3210 } | 3563 } |
| 3211 | 3564 |
| 3212 void test_proxy_annotation_superinterface_infiniteLoop() { | 3565 void test_proxy_annotation_superinterface_infiniteLoop() { |
| 3213 Source source = addSource(EngineTestCase.createSource([ | 3566 Source source = addSource(r''' |
| 3214 "library L;", | 3567 library L; |
| 3215 "class C implements A {", | 3568 class C implements A { |
| 3216 " m() {", | 3569 m() { |
| 3217 " n();", | 3570 n(); |
| 3218 " var x = g;", | 3571 var x = g; |
| 3219 " s = 1;", | 3572 s = 1; |
| 3220 " var y = this + this;", | 3573 var y = this + this; |
| 3221 " }", | 3574 } |
| 3222 "}", | 3575 } |
| 3223 "class B implements A{}", | 3576 class B implements A{} |
| 3224 "class A implements B{}"])); | 3577 class A implements B{}'''); |
| 3225 resolve(source); | 3578 resolve(source); |
| 3226 // Test is that a stack overflow isn't reached in resolution (previous line)
, no need to assert | 3579 // Test is that a stack overflow isn't reached in resolution (previous line)
, no need to assert |
| 3227 // error set. | 3580 // error set. |
| 3228 } | 3581 } |
| 3229 | 3582 |
| 3230 void test_recursiveConstructorRedirect() { | 3583 void test_recursiveConstructorRedirect() { |
| 3231 Source source = addSource(EngineTestCase.createSource([ | 3584 Source source = addSource(r''' |
| 3232 "class A {", | 3585 class A { |
| 3233 " A.a() : this.b();", | 3586 A.a() : this.b(); |
| 3234 " A.b() : this.c();", | 3587 A.b() : this.c(); |
| 3235 " A.c() {}", | 3588 A.c() {} |
| 3236 "}"])); | 3589 }'''); |
| 3237 resolve(source); | 3590 resolve(source); |
| 3238 assertNoErrors(source); | 3591 assertNoErrors(source); |
| 3239 verify([source]); | 3592 verify([source]); |
| 3240 } | 3593 } |
| 3241 | 3594 |
| 3242 void test_recursiveFactoryRedirect() { | 3595 void test_recursiveFactoryRedirect() { |
| 3243 Source source = addSource(EngineTestCase.createSource([ | 3596 Source source = addSource(r''' |
| 3244 "class A {", | 3597 class A { |
| 3245 " factory A() = B;", | 3598 factory A() = B; |
| 3246 "}", | 3599 } |
| 3247 "class B implements A {", | 3600 class B implements A { |
| 3248 " factory B() = C;", | 3601 factory B() = C; |
| 3249 "}", | 3602 } |
| 3250 "class C implements B {", | 3603 class C implements B { |
| 3251 " factory C() {}", | 3604 factory C() {} |
| 3252 "}"])); | 3605 }'''); |
| 3253 resolve(source); | 3606 resolve(source); |
| 3254 assertNoErrors(source); | 3607 assertNoErrors(source); |
| 3255 verify([source]); | 3608 verify([source]); |
| 3256 } | 3609 } |
| 3257 | 3610 |
| 3258 void test_redirectToInvalidFunctionType() { | 3611 void test_redirectToInvalidFunctionType() { |
| 3259 Source source = addSource(EngineTestCase.createSource([ | 3612 Source source = addSource(r''' |
| 3260 "class A implements B {", | 3613 class A implements B { |
| 3261 " A(int p) {}", | 3614 A(int p) {} |
| 3262 "}", | 3615 } |
| 3263 "class B {", | 3616 class B { |
| 3264 " factory B(int p) = A;", | 3617 factory B(int p) = A; |
| 3265 "}"])); | 3618 }'''); |
| 3266 resolve(source); | 3619 resolve(source); |
| 3267 assertNoErrors(source); | 3620 assertNoErrors(source); |
| 3268 verify([source]); | 3621 verify([source]); |
| 3269 } | 3622 } |
| 3270 | 3623 |
| 3271 void test_redirectToInvalidReturnType() { | 3624 void test_redirectToInvalidReturnType() { |
| 3272 Source source = addSource(EngineTestCase.createSource([ | 3625 Source source = addSource(r''' |
| 3273 "class A {", | 3626 class A { |
| 3274 " A() {}", | 3627 A() {} |
| 3275 "}", | 3628 } |
| 3276 "class B extends A {", | 3629 class B extends A { |
| 3277 " factory B() = A;", | 3630 factory B() = A; |
| 3278 "}"])); | 3631 }'''); |
| 3279 resolve(source); | 3632 resolve(source); |
| 3280 assertNoErrors(source); | 3633 assertNoErrors(source); |
| 3281 verify([source]); | 3634 verify([source]); |
| 3282 } | 3635 } |
| 3283 | 3636 |
| 3284 void test_redirectToNonConstConstructor() { | 3637 void test_redirectToNonConstConstructor() { |
| 3285 Source source = addSource(EngineTestCase.createSource([ | 3638 Source source = addSource(r''' |
| 3286 "class A {", | 3639 class A { |
| 3287 " const A.a();", | 3640 const A.a(); |
| 3288 " const factory A.b() = A.a;", | 3641 const factory A.b() = A.a; |
| 3289 "}"])); | 3642 }'''); |
| 3290 resolve(source); | 3643 resolve(source); |
| 3291 assertNoErrors(source); | 3644 assertNoErrors(source); |
| 3292 verify([source]); | 3645 verify([source]); |
| 3293 } | 3646 } |
| 3294 | 3647 |
| 3295 void test_referenceToDeclaredVariableInInitializer_constructorName() { | 3648 void test_referenceToDeclaredVariableInInitializer_constructorName() { |
| 3296 Source source = addSource(EngineTestCase.createSource([ | 3649 Source source = addSource(r''' |
| 3297 "class A {", | 3650 class A { |
| 3298 " A.x() {}", | 3651 A.x() {} |
| 3299 "}", | 3652 } |
| 3300 "f() {", | 3653 f() { |
| 3301 " var x = new A.x();", | 3654 var x = new A.x(); |
| 3302 "}"])); | 3655 }'''); |
| 3303 resolve(source); | 3656 resolve(source); |
| 3304 assertNoErrors(source); | 3657 assertNoErrors(source); |
| 3305 verify([source]); | 3658 verify([source]); |
| 3306 } | 3659 } |
| 3307 | 3660 |
| 3308 void test_referenceToDeclaredVariableInInitializer_methodName() { | 3661 void test_referenceToDeclaredVariableInInitializer_methodName() { |
| 3309 Source source = addSource(EngineTestCase.createSource([ | 3662 Source source = addSource(r''' |
| 3310 "class A {", | 3663 class A { |
| 3311 " x() {}", | 3664 x() {} |
| 3312 "}", | 3665 } |
| 3313 "f(A a) {", | 3666 f(A a) { |
| 3314 " var x = a.x();", | 3667 var x = a.x(); |
| 3315 "}"])); | 3668 }'''); |
| 3316 resolve(source); | 3669 resolve(source); |
| 3317 assertNoErrors(source); | 3670 assertNoErrors(source); |
| 3318 verify([source]); | 3671 verify([source]); |
| 3319 } | 3672 } |
| 3320 | 3673 |
| 3321 void test_referenceToDeclaredVariableInInitializer_propertyName() { | 3674 void test_referenceToDeclaredVariableInInitializer_propertyName() { |
| 3322 Source source = addSource(EngineTestCase.createSource([ | 3675 Source source = addSource(r''' |
| 3323 "class A {", | 3676 class A { |
| 3324 " var x;", | 3677 var x; |
| 3325 "}", | 3678 } |
| 3326 "f(A a) {", | 3679 f(A a) { |
| 3327 " var x = a.x;", | 3680 var x = a.x; |
| 3328 "}"])); | 3681 }'''); |
| 3329 resolve(source); | 3682 resolve(source); |
| 3330 assertNoErrors(source); | 3683 assertNoErrors(source); |
| 3331 verify([source]); | 3684 verify([source]); |
| 3332 } | 3685 } |
| 3333 | 3686 |
| 3334 void test_rethrowOutsideCatch() { | 3687 void test_rethrowOutsideCatch() { |
| 3335 Source source = addSource(EngineTestCase.createSource([ | 3688 Source source = addSource(r''' |
| 3336 "class A {", | 3689 class A { |
| 3337 " void m() {", | 3690 void m() { |
| 3338 " try {} catch (e) {rethrow;}", | 3691 try {} catch (e) {rethrow;} |
| 3339 " }", | 3692 } |
| 3340 "}"])); | 3693 }'''); |
| 3341 resolve(source); | 3694 resolve(source); |
| 3342 assertNoErrors(source); | 3695 assertNoErrors(source); |
| 3343 verify([source]); | 3696 verify([source]); |
| 3344 } | 3697 } |
| 3345 | 3698 |
| 3346 void test_returnInGenerativeConstructor() { | 3699 void test_returnInGenerativeConstructor() { |
| 3347 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return; }", "}"])); | 3700 Source source = addSource(r''' |
| 3348 resolve(source); | 3701 class A { |
| 3349 assertNoErrors(source); | 3702 A() { return; } |
| 3350 verify([source]); | 3703 }'''); |
| 3704 resolve(source); |
| 3705 assertNoErrors(source); |
| 3706 verify([source]); |
| 3351 } | 3707 } |
| 3352 | 3708 |
| 3353 void test_returnInGenerator_async() { | 3709 void test_returnInGenerator_async() { |
| 3354 resetWithAsync(); | 3710 resetWithAsync(); |
| 3355 Source source = addSource(EngineTestCase.createSource(["f() async {", " ret
urn 0;", "}"])); | 3711 Source source = addSource(r''' |
| 3712 f() async { |
| 3713 return 0; |
| 3714 }'''); |
| 3356 resolve(source); | 3715 resolve(source); |
| 3357 assertNoErrors(source); | 3716 assertNoErrors(source); |
| 3358 verify([source]); | 3717 verify([source]); |
| 3359 } | 3718 } |
| 3360 | 3719 |
| 3361 void test_returnInGenerator_sync() { | 3720 void test_returnInGenerator_sync() { |
| 3362 Source source = addSource(EngineTestCase.createSource(["f() {", " return 0;
", "}"])); | 3721 Source source = addSource(r''' |
| 3722 f() { |
| 3723 return 0; |
| 3724 }'''); |
| 3363 resolve(source); | 3725 resolve(source); |
| 3364 assertNoErrors(source); | 3726 assertNoErrors(source); |
| 3365 verify([source]); | 3727 verify([source]); |
| 3366 } | 3728 } |
| 3367 | 3729 |
| 3368 void test_returnOfInvalidType_async() { | 3730 void test_returnOfInvalidType_async() { |
| 3369 AnalysisOptionsImpl options = new AnalysisOptionsImpl.con1(analysisContext2.
analysisOptions); | 3731 AnalysisOptionsImpl options = new AnalysisOptionsImpl.con1(analysisContext2.
analysisOptions); |
| 3370 options.enableAsync = true; | 3732 options.enableAsync = true; |
| 3371 resetWithOptions(options); | 3733 resetWithOptions(options); |
| 3372 Source source = addSource(EngineTestCase.createSource([ | 3734 Source source = addSource(r''' |
| 3373 "import 'dart:async';", | 3735 import 'dart:async'; |
| 3374 "class A {", | 3736 class A { |
| 3375 " Future<int> m() async {", | 3737 Future<int> m() async { |
| 3376 " return 0;", | 3738 return 0; |
| 3377 " }", | 3739 } |
| 3378 "}"])); | 3740 }'''); |
| 3379 resolve(source); | 3741 resolve(source); |
| 3380 assertNoErrors(source); | 3742 assertNoErrors(source); |
| 3381 verify([source]); | 3743 verify([source]); |
| 3382 } | 3744 } |
| 3383 | 3745 |
| 3384 void test_returnOfInvalidType_dynamic() { | 3746 void test_returnOfInvalidType_dynamic() { |
| 3385 Source source = addSource(EngineTestCase.createSource([ | 3747 Source source = addSource(r''' |
| 3386 "class TypeError {}", | 3748 class TypeError {} |
| 3387 "class A {", | 3749 class A { |
| 3388 " static void testLogicalOp() {", | 3750 static void testLogicalOp() { |
| 3389 " testOr(a, b, onTypeError) {", | 3751 testOr(a, b, onTypeError) { |
| 3390 " try {", | 3752 try { |
| 3391 " return a || b;", | 3753 return a || b; |
| 3392 " } on TypeError catch (t) {", | 3754 } on TypeError catch (t) { |
| 3393 " return onTypeError;", | 3755 return onTypeError; |
| 3394 " }", | 3756 } |
| 3395 " }", | 3757 } |
| 3396 " }", | 3758 } |
| 3397 "}"])); | 3759 }'''); |
| 3398 resolve(source); | 3760 resolve(source); |
| 3399 assertNoErrors(source); | 3761 assertNoErrors(source); |
| 3400 verify([source]); | 3762 verify([source]); |
| 3401 } | 3763 } |
| 3402 | 3764 |
| 3403 void test_returnOfInvalidType_dynamicAsTypeArgument() { | 3765 void test_returnOfInvalidType_dynamicAsTypeArgument() { |
| 3404 Source source = addSource(EngineTestCase.createSource([ | 3766 Source source = addSource(r''' |
| 3405 "class I<T> {", | 3767 class I<T> { |
| 3406 " factory I() => new A<T>();", | 3768 factory I() => new A<T>(); |
| 3407 "}", | 3769 } |
| 3408 "class A<T> implements I {", | 3770 class A<T> implements I { |
| 3409 "}"])); | 3771 }'''); |
| 3410 resolve(source); | 3772 resolve(source); |
| 3411 assertNoErrors(source); | 3773 assertNoErrors(source); |
| 3412 verify([source]); | 3774 verify([source]); |
| 3413 } | 3775 } |
| 3414 | 3776 |
| 3415 void test_returnOfInvalidType_subtype() { | 3777 void test_returnOfInvalidType_subtype() { |
| 3416 Source source = addSource(EngineTestCase.createSource([ | 3778 Source source = addSource(r''' |
| 3417 "class A {}", | 3779 class A {} |
| 3418 "class B extends A {}", | 3780 class B extends A {} |
| 3419 "A f(B b) { return b; }"])); | 3781 A f(B b) { return b; }'''); |
| 3420 resolve(source); | 3782 resolve(source); |
| 3421 assertNoErrors(source); | 3783 assertNoErrors(source); |
| 3422 verify([source]); | 3784 verify([source]); |
| 3423 } | 3785 } |
| 3424 | 3786 |
| 3425 void test_returnOfInvalidType_supertype() { | 3787 void test_returnOfInvalidType_supertype() { |
| 3426 Source source = addSource(EngineTestCase.createSource([ | 3788 Source source = addSource(r''' |
| 3427 "class A {}", | 3789 class A {} |
| 3428 "class B extends A {}", | 3790 class B extends A {} |
| 3429 "B f(A a) { return a; }"])); | 3791 B f(A a) { return a; }'''); |
| 3430 resolve(source); | 3792 resolve(source); |
| 3431 assertNoErrors(source); | 3793 assertNoErrors(source); |
| 3432 verify([source]); | 3794 verify([source]); |
| 3433 } | 3795 } |
| 3434 | 3796 |
| 3435 void test_returnOfInvalidType_typeParameter_18468() { | 3797 void test_returnOfInvalidType_typeParameter_18468() { |
| 3436 // https://code.google.com/p/dart/issues/detail?id=18468 | 3798 // https://code.google.com/p/dart/issues/detail?id=18468 |
| 3437 // | 3799 // |
| 3438 // This test verifies that the type of T is more specific than Type, | 3800 // This test verifies that the type of T is more specific than Type, |
| 3439 // where T is a type parameter and Type is the type Type from | 3801 // where T is a type parameter and Type is the type Type from |
| 3440 // core, this particular test case comes from issue 18468. | 3802 // core, this particular test case comes from issue 18468. |
| 3441 // | 3803 // |
| 3442 // A test cannot be added to TypeParameterTypeImplTest since the types retur
ned out of the | 3804 // A test cannot be added to TypeParameterTypeImplTest since the types retur
ned out of the |
| 3443 // TestTypeProvider don't have a mock 'dart.core' enclosing library element. | 3805 // TestTypeProvider don't have a mock 'dart.core' enclosing library element. |
| 3444 // See TypeParameterTypeImpl.isMoreSpecificThan(). | 3806 // See TypeParameterTypeImpl.isMoreSpecificThan(). |
| 3445 Source source = addSource(EngineTestCase.createSource(["class Foo<T> {", "
Type get t => T;", "}"])); | 3807 Source source = addSource(r''' |
| 3808 class Foo<T> { |
| 3809 Type get t => T; |
| 3810 }'''); |
| 3446 resolve(source); | 3811 resolve(source); |
| 3447 assertErrors(source, []); | 3812 assertErrors(source, []); |
| 3448 verify([source]); | 3813 verify([source]); |
| 3449 } | 3814 } |
| 3450 | 3815 |
| 3451 void test_returnOfInvalidType_void() { | 3816 void test_returnOfInvalidType_void() { |
| 3452 Source source = addSource(EngineTestCase.createSource([ | 3817 Source source = addSource(r''' |
| 3453 "void f1() {}", | 3818 void f1() {} |
| 3454 "void f2() { return; }", | 3819 void f2() { return; } |
| 3455 "void f3() { return null; }", | 3820 void f3() { return null; } |
| 3456 "void f4() { return g1(); }", | 3821 void f4() { return g1(); } |
| 3457 "void f5() { return g2(); }", | 3822 void f5() { return g2(); } |
| 3458 "g1() {}", | 3823 g1() {} |
| 3459 "void g2() {}", | 3824 void g2() {} |
| 3460 ""])); | 3825 '''); |
| 3461 resolve(source); | 3826 resolve(source); |
| 3462 assertNoErrors(source); | 3827 assertNoErrors(source); |
| 3463 verify([source]); | 3828 verify([source]); |
| 3464 } | 3829 } |
| 3465 | 3830 |
| 3466 void test_returnWithoutValue_noReturnType() { | 3831 void test_returnWithoutValue_noReturnType() { |
| 3467 Source source = addSource(EngineTestCase.createSource(["f() { return; }"])); | 3832 Source source = addSource("f() { return; }"); |
| 3468 resolve(source); | 3833 resolve(source); |
| 3469 assertNoErrors(source); | 3834 assertNoErrors(source); |
| 3470 verify([source]); | 3835 verify([source]); |
| 3471 } | 3836 } |
| 3472 | 3837 |
| 3473 void test_returnWithoutValue_void() { | 3838 void test_returnWithoutValue_void() { |
| 3474 Source source = addSource(EngineTestCase.createSource(["void f() { return; }
"])); | 3839 Source source = addSource("void f() { return; }"); |
| 3475 resolve(source); | 3840 resolve(source); |
| 3476 assertNoErrors(source); | 3841 assertNoErrors(source); |
| 3477 verify([source]); | 3842 verify([source]); |
| 3478 } | 3843 } |
| 3479 | 3844 |
| 3480 void test_reversedTypeArguments() { | 3845 void test_reversedTypeArguments() { |
| 3481 Source source = addSource(EngineTestCase.createSource([ | 3846 Source source = addSource(r''' |
| 3482 "class Codec<S1, T1> {", | 3847 class Codec<S1, T1> { |
| 3483 " Codec<T1, S1> get inverted => new _InvertedCodec<T1, S1>(this);", | 3848 Codec<T1, S1> get inverted => new _InvertedCodec<T1, S1>(this); |
| 3484 "}", | 3849 } |
| 3485 "class _InvertedCodec<T2, S2> extends Codec<T2, S2> {", | 3850 class _InvertedCodec<T2, S2> extends Codec<T2, S2> { |
| 3486 " _InvertedCodec(Codec<S2, T2> codec);", | 3851 _InvertedCodec(Codec<S2, T2> codec); |
| 3487 "}"])); | 3852 }'''); |
| 3488 resolve(source); | 3853 resolve(source); |
| 3489 assertNoErrors(source); | 3854 assertNoErrors(source); |
| 3490 verify([source]); | 3855 verify([source]); |
| 3491 } | 3856 } |
| 3492 | 3857 |
| 3493 void test_sharedDeferredPrefix() { | 3858 void test_sharedDeferredPrefix() { |
| 3494 resolveWithAndWithoutExperimental(<String> [ | 3859 resolveWithAndWithoutExperimental(<String> [ |
| 3495 EngineTestCase.createSource(["library lib1;", "f1() {}"]), | 3860 r''' |
| 3496 EngineTestCase.createSource(["library lib2;", "f2() {}"]), | 3861 library lib1; |
| 3497 EngineTestCase.createSource(["library lib3;", "f3() {}"]), | 3862 f1() {}''', |
| 3498 EngineTestCase.createSource([ | 3863 r''' |
| 3499 "library root;", | 3864 library lib2; |
| 3500 "import 'lib1.dart' deferred as lib1;", | 3865 f2() {}''', |
| 3501 "import 'lib2.dart' as lib;", | 3866 r''' |
| 3502 "import 'lib3.dart' as lib;", | 3867 library lib3; |
| 3503 "main() { lib1.f1(); lib.f2(); lib.f3(); }"])], <ErrorCode> [ParserError
Code.DEFERRED_IMPORTS_NOT_SUPPORTED], <ErrorCode> []); | 3868 f3() {}''', |
| 3869 r''' |
| 3870 library root; |
| 3871 import 'lib1.dart' deferred as lib1; |
| 3872 import 'lib2.dart' as lib; |
| 3873 import 'lib3.dart' as lib; |
| 3874 main() { lib1.f1(); lib.f2(); lib.f3(); }'''], <ErrorCode> [ParserErrorCode.DEFE
RRED_IMPORTS_NOT_SUPPORTED], <ErrorCode> []); |
| 3504 } | 3875 } |
| 3505 | 3876 |
| 3506 void test_staticAccessToInstanceMember_annotation() { | 3877 void test_staticAccessToInstanceMember_annotation() { |
| 3507 Source source = addSource(EngineTestCase.createSource([ | 3878 Source source = addSource(r''' |
| 3508 "class A {", | 3879 class A { |
| 3509 " const A.name();", | 3880 const A.name(); |
| 3510 "}", | 3881 } |
| 3511 "@A.name()", | 3882 @A.name() |
| 3512 "main() {", | 3883 main() { |
| 3513 "}"])); | 3884 }'''); |
| 3514 resolve(source); | 3885 resolve(source); |
| 3515 assertNoErrors(source); | 3886 assertNoErrors(source); |
| 3516 verify([source]); | 3887 verify([source]); |
| 3517 } | 3888 } |
| 3518 | 3889 |
| 3519 void test_staticAccessToInstanceMember_method() { | 3890 void test_staticAccessToInstanceMember_method() { |
| 3520 Source source = addSource(EngineTestCase.createSource([ | 3891 Source source = addSource(r''' |
| 3521 "class A {", | 3892 class A { |
| 3522 " static m() {}", | 3893 static m() {} |
| 3523 "}", | 3894 } |
| 3524 "main() {", | 3895 main() { |
| 3525 " A.m;", | 3896 A.m; |
| 3526 " A.m();", | 3897 A.m(); |
| 3527 "}"])); | 3898 }'''); |
| 3528 resolve(source); | 3899 resolve(source); |
| 3529 assertNoErrors(source); | 3900 assertNoErrors(source); |
| 3530 verify([source]); | 3901 verify([source]); |
| 3531 } | 3902 } |
| 3532 | 3903 |
| 3533 void test_staticAccessToInstanceMember_propertyAccess_field() { | 3904 void test_staticAccessToInstanceMember_propertyAccess_field() { |
| 3534 Source source = addSource(EngineTestCase.createSource([ | 3905 Source source = addSource(r''' |
| 3535 "class A {", | 3906 class A { |
| 3536 " static var f;", | 3907 static var f; |
| 3537 "}", | 3908 } |
| 3538 "main() {", | 3909 main() { |
| 3539 " A.f;", | 3910 A.f; |
| 3540 " A.f = 1;", | 3911 A.f = 1; |
| 3541 "}"])); | 3912 }'''); |
| 3542 resolve(source); | 3913 resolve(source); |
| 3543 assertNoErrors(source); | 3914 assertNoErrors(source); |
| 3544 verify([source]); | 3915 verify([source]); |
| 3545 } | 3916 } |
| 3546 | 3917 |
| 3547 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() { | 3918 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() { |
| 3548 Source source = addSource(EngineTestCase.createSource([ | 3919 Source source = addSource(r''' |
| 3549 "class A {", | 3920 class A { |
| 3550 " static get f => 42;", | 3921 static get f => 42; |
| 3551 " static set f(x) {}", | 3922 static set f(x) {} |
| 3552 "}", | 3923 } |
| 3553 "main() {", | 3924 main() { |
| 3554 " A.f;", | 3925 A.f; |
| 3555 " A.f = 1;", | 3926 A.f = 1; |
| 3556 "}"])); | 3927 }'''); |
| 3557 resolve(source); | 3928 resolve(source); |
| 3558 assertNoErrors(source); | 3929 assertNoErrors(source); |
| 3559 verify([source]); | 3930 verify([source]); |
| 3560 } | 3931 } |
| 3561 | 3932 |
| 3562 void test_superInInvalidContext() { | 3933 void test_superInInvalidContext() { |
| 3563 Source source = addSource(EngineTestCase.createSource([ | 3934 Source source = addSource(r''' |
| 3564 "class A {", | 3935 class A { |
| 3565 " m() {}", | 3936 m() {} |
| 3566 "}", | 3937 } |
| 3567 "class B extends A {", | 3938 class B extends A { |
| 3568 " B() {", | 3939 B() { |
| 3569 " var v = super.m();", | 3940 var v = super.m(); |
| 3570 " }", | 3941 } |
| 3571 " n() {", | 3942 n() { |
| 3572 " var v = super.m();", | 3943 var v = super.m(); |
| 3573 " }", | 3944 } |
| 3574 "}"])); | 3945 }'''); |
| 3575 resolve(source); | 3946 resolve(source); |
| 3576 assertNoErrors(source); | 3947 assertNoErrors(source); |
| 3577 verify([source]); | 3948 verify([source]); |
| 3578 } | 3949 } |
| 3579 | 3950 |
| 3580 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { | 3951 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { |
| 3581 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "cl
ass B {", " A a;", "}"])); | 3952 Source source = addSource(r''' |
| 3953 typedef B A(); |
| 3954 class B { |
| 3955 A a; |
| 3956 }'''); |
| 3582 resolve(source); | 3957 resolve(source); |
| 3583 assertNoErrors(source); | 3958 assertNoErrors(source); |
| 3584 verify([source]); | 3959 verify([source]); |
| 3585 } | 3960 } |
| 3586 | 3961 |
| 3587 void test_typeArgumentNotMatchingBounds_const() { | 3962 void test_typeArgumentNotMatchingBounds_const() { |
| 3588 Source source = addSource(EngineTestCase.createSource([ | 3963 Source source = addSource(r''' |
| 3589 "class A {}", | 3964 class A {} |
| 3590 "class B extends A {}", | 3965 class B extends A {} |
| 3591 "class G<E extends A> {", | 3966 class G<E extends A> { |
| 3592 " const G();", | 3967 const G(); |
| 3593 "}", | 3968 } |
| 3594 "f() { return const G<B>(); }"])); | 3969 f() { return const G<B>(); }'''); |
| 3595 resolve(source); | 3970 resolve(source); |
| 3596 assertNoErrors(source); | 3971 assertNoErrors(source); |
| 3597 verify([source]); | 3972 verify([source]); |
| 3598 } | 3973 } |
| 3599 | 3974 |
| 3600 void test_typeArgumentNotMatchingBounds_new() { | 3975 void test_typeArgumentNotMatchingBounds_new() { |
| 3601 Source source = addSource(EngineTestCase.createSource([ | 3976 Source source = addSource(r''' |
| 3602 "class A {}", | 3977 class A {} |
| 3603 "class B extends A {}", | 3978 class B extends A {} |
| 3604 "class G<E extends A> {}", | 3979 class G<E extends A> {} |
| 3605 "f() { return new G<B>(); }"])); | 3980 f() { return new G<B>(); }'''); |
| 3606 resolve(source); | 3981 resolve(source); |
| 3607 assertNoErrors(source); | 3982 assertNoErrors(source); |
| 3608 verify([source]); | 3983 verify([source]); |
| 3609 } | 3984 } |
| 3610 | 3985 |
| 3611 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() { | 3986 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() { |
| 3612 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A>{}"])); | 3987 Source source = addSource("abstract class A<T extends A>{}"); |
| 3613 resolve(source); | 3988 resolve(source); |
| 3614 assertNoErrors(source); | 3989 assertNoErrors(source); |
| 3615 verify([source]); | 3990 verify([source]); |
| 3616 } | 3991 } |
| 3617 | 3992 |
| 3618 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() { | 3993 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() { |
| 3619 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A>>{}"])); | 3994 Source source = addSource("abstract class A<T extends A<A>>{}"); |
| 3620 resolve(source); | 3995 resolve(source); |
| 3621 assertNoErrors(source); | 3996 assertNoErrors(source); |
| 3622 verify([source]); | 3997 verify([source]); |
| 3623 } | 3998 } |
| 3624 | 3999 |
| 3625 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() { | 4000 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() { |
| 3626 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>>>>>>>>>>>>>>>>>>>>{}"])); | 4001 Source source = addSource("abstract class A<T extends A<A<A<A<A<A<A<A<A<A<A<
A<A<A<A<A<A<A<A<A<A>>>>>>>>>>>>>>>>>>>>>{}"); |
| 3627 resolve(source); | 4002 resolve(source); |
| 3628 assertNoErrors(source); | 4003 assertNoErrors(source); |
| 3629 verify([source]); | 4004 verify([source]); |
| 3630 } | 4005 } |
| 3631 | 4006 |
| 3632 void test_typePromotion_booleanAnd_useInRight() { | 4007 void test_typePromotion_booleanAnd_useInRight() { |
| 3633 Source source = addSource(EngineTestCase.createSource([ | 4008 Source source = addSource(r''' |
| 3634 "main(Object p) {", | 4009 main(Object p) { |
| 3635 " p is String && p.length != 0;", | 4010 p is String && p.length != 0; |
| 3636 "}"])); | 4011 }'''); |
| 3637 resolve(source); | 4012 resolve(source); |
| 3638 assertNoErrors(source); | 4013 assertNoErrors(source); |
| 3639 verify([source]); | 4014 verify([source]); |
| 3640 } | 4015 } |
| 3641 | 4016 |
| 3642 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignm
ent() { | 4017 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignm
ent() { |
| 3643 Source source = addSource(EngineTestCase.createSource([ | 4018 Source source = addSource(r''' |
| 3644 "callMe(f()) { f(); }", | 4019 callMe(f()) { f(); } |
| 3645 "main(Object p) {", | 4020 main(Object p) { |
| 3646 " (p is String) && callMe(() { p.length; });", | 4021 (p is String) && callMe(() { p.length; }); |
| 3647 "}"])); | 4022 }'''); |
| 3648 resolve(source); | 4023 resolve(source); |
| 3649 assertNoErrors(source); | 4024 assertNoErrors(source); |
| 3650 verify([source]); | 4025 verify([source]); |
| 3651 } | 4026 } |
| 3652 | 4027 |
| 3653 void test_typePromotion_conditional_issue14655() { | 4028 void test_typePromotion_conditional_issue14655() { |
| 3654 Source source = addSource(EngineTestCase.createSource([ | 4029 Source source = addSource(r''' |
| 3655 "class A {}", | 4030 class A {} |
| 3656 "class B extends A {}", | 4031 class B extends A {} |
| 3657 "class C extends B {", | 4032 class C extends B { |
| 3658 " mc() {}", | 4033 mc() {} |
| 3659 "}", | 4034 } |
| 3660 "print(_) {}", | 4035 print(_) {} |
| 3661 "main(A p) {", | 4036 main(A p) { |
| 3662 " (p is C) && (print(() => p) && (p is B)) ? p.mc() : p = null;", | 4037 (p is C) && (print(() => p) && (p is B)) ? p.mc() : p = null; |
| 3663 "}"])); | 4038 }'''); |
| 3664 resolve(source); | 4039 resolve(source); |
| 3665 assertNoErrors(source); | 4040 assertNoErrors(source); |
| 3666 verify([source]); | 4041 verify([source]); |
| 3667 } | 4042 } |
| 3668 | 4043 |
| 3669 void test_typePromotion_conditional_useInThen() { | 4044 void test_typePromotion_conditional_useInThen() { |
| 3670 Source source = addSource(EngineTestCase.createSource(["main(Object p) {", "
p is String ? p.length : 0;", "}"])); | 4045 Source source = addSource(r''' |
| 4046 main(Object p) { |
| 4047 p is String ? p.length : 0; |
| 4048 }'''); |
| 3671 resolve(source); | 4049 resolve(source); |
| 3672 assertNoErrors(source); | 4050 assertNoErrors(source); |
| 3673 verify([source]); | 4051 verify([source]); |
| 3674 } | 4052 } |
| 3675 | 4053 |
| 3676 void test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment()
{ | 4054 void test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment()
{ |
| 3677 Source source = addSource(EngineTestCase.createSource([ | 4055 Source source = addSource(r''' |
| 3678 "callMe(f()) { f(); }", | 4056 callMe(f()) { f(); } |
| 3679 "main(Object p) {", | 4057 main(Object p) { |
| 3680 " p is String ? callMe(() { p.length; }) : 0;", | 4058 p is String ? callMe(() { p.length; }) : 0; |
| 3681 "}"])); | 4059 }'''); |
| 3682 resolve(source); | 4060 resolve(source); |
| 3683 assertNoErrors(source); | 4061 assertNoErrors(source); |
| 3684 verify([source]); | 4062 verify([source]); |
| 3685 } | 4063 } |
| 3686 | 4064 |
| 3687 void test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() { | 4065 void test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() { |
| 3688 Source source = addSource(EngineTestCase.createSource([ | 4066 Source source = addSource(r''' |
| 3689 "typedef FuncB(B b);", | 4067 typedef FuncB(B b); |
| 3690 "typedef FuncA(A a);", | 4068 typedef FuncA(A a); |
| 3691 "class A {}", | 4069 class A {} |
| 3692 "class B {}", | 4070 class B {} |
| 3693 "main(FuncA f) {", | 4071 main(FuncA f) { |
| 3694 " if (f is FuncB) {", | 4072 if (f is FuncB) { |
| 3695 " f(new A());", | 4073 f(new A()); |
| 3696 " }", | 4074 } |
| 3697 "}"])); | 4075 }'''); |
| 3698 resolve(source); | 4076 resolve(source); |
| 3699 assertNoErrors(source); | 4077 assertNoErrors(source); |
| 3700 verify([source]); | 4078 verify([source]); |
| 3701 } | 4079 } |
| 3702 | 4080 |
| 3703 void test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() { | 4081 void test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() { |
| 3704 Source source = addSource(EngineTestCase.createSource([ | 4082 Source source = addSource(r''' |
| 3705 "class A {}", | 4083 class A {} |
| 3706 "typedef FuncAtoDyn(A a);", | 4084 typedef FuncAtoDyn(A a); |
| 3707 "typedef FuncDynToDyn(x);", | 4085 typedef FuncDynToDyn(x); |
| 3708 "main(FuncAtoDyn f) {", | 4086 main(FuncAtoDyn f) { |
| 3709 " if (f is FuncDynToDyn) {", | 4087 if (f is FuncDynToDyn) { |
| 3710 " A a = f(new A());", | 4088 A a = f(new A()); |
| 3711 " }", | 4089 } |
| 3712 "}"])); | 4090 }'''); |
| 3713 resolve(source); | 4091 resolve(source); |
| 3714 assertNoErrors(source); | 4092 assertNoErrors(source); |
| 3715 verify([source]); | 4093 verify([source]); |
| 3716 } | 4094 } |
| 3717 | 4095 |
| 3718 void test_typePromotion_functionType_return_voidToDynamic() { | 4096 void test_typePromotion_functionType_return_voidToDynamic() { |
| 3719 Source source = addSource(EngineTestCase.createSource([ | 4097 Source source = addSource(r''' |
| 3720 "typedef FuncDynToDyn(x);", | 4098 typedef FuncDynToDyn(x); |
| 3721 "typedef void FuncDynToVoid(x);", | 4099 typedef void FuncDynToVoid(x); |
| 3722 "class A {}", | 4100 class A {} |
| 3723 "main(FuncDynToVoid f) {", | 4101 main(FuncDynToVoid f) { |
| 3724 " if (f is FuncDynToDyn) {", | 4102 if (f is FuncDynToDyn) { |
| 3725 " A a = f(null);", | 4103 A a = f(null); |
| 3726 " }", | 4104 } |
| 3727 "}"])); | 4105 }'''); |
| 3728 resolve(source); | 4106 resolve(source); |
| 3729 assertNoErrors(source); | 4107 assertNoErrors(source); |
| 3730 verify([source]); | 4108 verify([source]); |
| 3731 } | 4109 } |
| 3732 | 4110 |
| 3733 void test_typePromotion_if_accessedInClosure_noAssignment() { | 4111 void test_typePromotion_if_accessedInClosure_noAssignment() { |
| 3734 Source source = addSource(EngineTestCase.createSource([ | 4112 Source source = addSource(r''' |
| 3735 "callMe(f()) { f(); }", | 4113 callMe(f()) { f(); } |
| 3736 "main(Object p) {", | 4114 main(Object p) { |
| 3737 " if (p is String) {", | 4115 if (p is String) { |
| 3738 " callMe(() {", | 4116 callMe(() { |
| 3739 " p.length;", | 4117 p.length; |
| 3740 " });", | 4118 }); |
| 3741 " }", | 4119 } |
| 3742 "}"])); | 4120 }'''); |
| 3743 resolve(source); | 4121 resolve(source); |
| 3744 assertNoErrors(source); | 4122 assertNoErrors(source); |
| 3745 verify([source]); | 4123 verify([source]); |
| 3746 } | 4124 } |
| 3747 | 4125 |
| 3748 void test_typePromotion_if_extends_moreSpecific() { | 4126 void test_typePromotion_if_extends_moreSpecific() { |
| 3749 Source source = addSource(EngineTestCase.createSource([ | 4127 Source source = addSource(r''' |
| 3750 "class V {}", | 4128 class V {} |
| 3751 "class VP extends V {}", | 4129 class VP extends V {} |
| 3752 "class A<T> {}", | 4130 class A<T> {} |
| 3753 "class B<S> extends A<S> {", | 4131 class B<S> extends A<S> { |
| 3754 " var b;", | 4132 var b; |
| 3755 "}", | 4133 } |
| 3756 "", | 4134 |
| 3757 "main(A<V> p) {", | 4135 main(A<V> p) { |
| 3758 " if (p is B<VP>) {", | 4136 if (p is B<VP>) { |
| 3759 " p.b;", | 4137 p.b; |
| 3760 " }", | 4138 } |
| 3761 "}"])); | 4139 }'''); |
| 3762 resolve(source); | 4140 resolve(source); |
| 3763 assertNoErrors(source); | 4141 assertNoErrors(source); |
| 3764 verify([source]); | 4142 verify([source]); |
| 3765 } | 4143 } |
| 3766 | 4144 |
| 3767 void test_typePromotion_if_hasAssignment_outsideAfter() { | 4145 void test_typePromotion_if_hasAssignment_outsideAfter() { |
| 3768 Source source = addSource(EngineTestCase.createSource([ | 4146 Source source = addSource(r''' |
| 3769 "main(Object p) {", | 4147 main(Object p) { |
| 3770 " if (p is String) {", | 4148 if (p is String) { |
| 3771 " p.length;", | 4149 p.length; |
| 3772 " }", | 4150 } |
| 3773 " p = 0;", | 4151 p = 0; |
| 3774 "}"])); | 4152 }'''); |
| 3775 resolve(source); | 4153 resolve(source); |
| 3776 assertNoErrors(source); | 4154 assertNoErrors(source); |
| 3777 verify([source]); | 4155 verify([source]); |
| 3778 } | 4156 } |
| 3779 | 4157 |
| 3780 void test_typePromotion_if_hasAssignment_outsideBefore() { | 4158 void test_typePromotion_if_hasAssignment_outsideBefore() { |
| 3781 Source source = addSource(EngineTestCase.createSource([ | 4159 Source source = addSource(r''' |
| 3782 "main(Object p, Object p2) {", | 4160 main(Object p, Object p2) { |
| 3783 " p = p2;", | 4161 p = p2; |
| 3784 " if (p is String) {", | 4162 if (p is String) { |
| 3785 " p.length;", | 4163 p.length; |
| 3786 " }", | 4164 } |
| 3787 "}"])); | 4165 }'''); |
| 3788 resolve(source); | 4166 resolve(source); |
| 3789 assertNoErrors(source); | 4167 assertNoErrors(source); |
| 3790 verify([source]); | 4168 verify([source]); |
| 3791 } | 4169 } |
| 3792 | 4170 |
| 3793 void test_typePromotion_if_implements_moreSpecific() { | 4171 void test_typePromotion_if_implements_moreSpecific() { |
| 3794 Source source = addSource(EngineTestCase.createSource([ | 4172 Source source = addSource(r''' |
| 3795 "class V {}", | 4173 class V {} |
| 3796 "class VP extends V {}", | 4174 class VP extends V {} |
| 3797 "class A<T> {}", | 4175 class A<T> {} |
| 3798 "class B<S> implements A<S> {", | 4176 class B<S> implements A<S> { |
| 3799 " var b;", | 4177 var b; |
| 3800 "}", | 4178 } |
| 3801 "", | 4179 |
| 3802 "main(A<V> p) {", | 4180 main(A<V> p) { |
| 3803 " if (p is B<VP>) {", | 4181 if (p is B<VP>) { |
| 3804 " p.b;", | 4182 p.b; |
| 3805 " }", | 4183 } |
| 3806 "}"])); | 4184 }'''); |
| 3807 resolve(source); | 4185 resolve(source); |
| 3808 assertNoErrors(source); | 4186 assertNoErrors(source); |
| 3809 verify([source]); | 4187 verify([source]); |
| 3810 } | 4188 } |
| 3811 | 4189 |
| 3812 void test_typePromotion_if_inClosure_assignedAfter_inSameFunction() { | 4190 void test_typePromotion_if_inClosure_assignedAfter_inSameFunction() { |
| 3813 Source source = addSource(EngineTestCase.createSource([ | 4191 Source source = addSource(r''' |
| 3814 "main() {", | 4192 main() { |
| 3815 " f(Object p) {", | 4193 f(Object p) { |
| 3816 " if (p is String) {", | 4194 if (p is String) { |
| 3817 " p.length;", | 4195 p.length; |
| 3818 " }", | 4196 } |
| 3819 " p = 0;", | 4197 p = 0; |
| 3820 " };", | 4198 }; |
| 3821 "}"])); | 4199 }'''); |
| 3822 resolve(source); | 4200 resolve(source); |
| 3823 assertNoErrors(source); | 4201 assertNoErrors(source); |
| 3824 verify([source]); | 4202 verify([source]); |
| 3825 } | 4203 } |
| 3826 | 4204 |
| 3827 void test_typePromotion_if_is_and_left() { | 4205 void test_typePromotion_if_is_and_left() { |
| 3828 Source source = addSource(EngineTestCase.createSource([ | 4206 Source source = addSource(r''' |
| 3829 "bool tt() => true;", | 4207 bool tt() => true; |
| 3830 "main(Object p) {", | 4208 main(Object p) { |
| 3831 " if (p is String && tt()) {", | 4209 if (p is String && tt()) { |
| 3832 " p.length;", | 4210 p.length; |
| 3833 " }", | 4211 } |
| 3834 "}"])); | 4212 }'''); |
| 3835 resolve(source); | 4213 resolve(source); |
| 3836 assertNoErrors(source); | 4214 assertNoErrors(source); |
| 3837 verify([source]); | 4215 verify([source]); |
| 3838 } | 4216 } |
| 3839 | 4217 |
| 3840 void test_typePromotion_if_is_and_right() { | 4218 void test_typePromotion_if_is_and_right() { |
| 3841 Source source = addSource(EngineTestCase.createSource([ | 4219 Source source = addSource(r''' |
| 3842 "bool tt() => true;", | 4220 bool tt() => true; |
| 3843 "main(Object p) {", | 4221 main(Object p) { |
| 3844 " if (tt() && p is String) {", | 4222 if (tt() && p is String) { |
| 3845 " p.length;", | 4223 p.length; |
| 3846 " }", | 4224 } |
| 3847 "}"])); | 4225 }'''); |
| 3848 resolve(source); | 4226 resolve(source); |
| 3849 assertNoErrors(source); | 4227 assertNoErrors(source); |
| 3850 verify([source]); | 4228 verify([source]); |
| 3851 } | 4229 } |
| 3852 | 4230 |
| 3853 void test_typePromotion_if_is_and_subThenSuper() { | 4231 void test_typePromotion_if_is_and_subThenSuper() { |
| 3854 Source source = addSource(EngineTestCase.createSource([ | 4232 Source source = addSource(r''' |
| 3855 "class A {", | 4233 class A { |
| 3856 " var a;", | 4234 var a; |
| 3857 "}", | 4235 } |
| 3858 "class B extends A {", | 4236 class B extends A { |
| 3859 " var b;", | 4237 var b; |
| 3860 "}", | 4238 } |
| 3861 "main(Object p) {", | 4239 main(Object p) { |
| 3862 " if (p is B && p is A) {", | 4240 if (p is B && p is A) { |
| 3863 " p.a;", | 4241 p.a; |
| 3864 " p.b;", | 4242 p.b; |
| 3865 " }", | 4243 } |
| 3866 "}"])); | 4244 }'''); |
| 3867 resolve(source); | 4245 resolve(source); |
| 3868 assertNoErrors(source); | 4246 assertNoErrors(source); |
| 3869 verify([source]); | 4247 verify([source]); |
| 3870 } | 4248 } |
| 3871 | 4249 |
| 3872 void test_typePromotion_if_is_parenthesized() { | 4250 void test_typePromotion_if_is_parenthesized() { |
| 3873 Source source = addSource(EngineTestCase.createSource([ | 4251 Source source = addSource(r''' |
| 3874 "main(Object p) {", | 4252 main(Object p) { |
| 3875 " if ((p is String)) {", | 4253 if ((p is String)) { |
| 3876 " p.length;", | 4254 p.length; |
| 3877 " }", | 4255 } |
| 3878 "}"])); | 4256 }'''); |
| 3879 resolve(source); | 4257 resolve(source); |
| 3880 assertNoErrors(source); | 4258 assertNoErrors(source); |
| 3881 verify([source]); | 4259 verify([source]); |
| 3882 } | 4260 } |
| 3883 | 4261 |
| 3884 void test_typePromotion_if_is_single() { | 4262 void test_typePromotion_if_is_single() { |
| 3885 Source source = addSource(EngineTestCase.createSource([ | 4263 Source source = addSource(r''' |
| 3886 "main(Object p) {", | 4264 main(Object p) { |
| 3887 " if (p is String) {", | 4265 if (p is String) { |
| 3888 " p.length;", | 4266 p.length; |
| 3889 " }", | 4267 } |
| 3890 "}"])); | 4268 }'''); |
| 3891 resolve(source); | 4269 resolve(source); |
| 3892 assertNoErrors(source); | 4270 assertNoErrors(source); |
| 3893 verify([source]); | 4271 verify([source]); |
| 3894 } | 4272 } |
| 3895 | 4273 |
| 3896 void test_typePromotion_parentheses() { | 4274 void test_typePromotion_parentheses() { |
| 3897 Source source = addSource(EngineTestCase.createSource([ | 4275 Source source = addSource(r''' |
| 3898 "main(Object p) {", | 4276 main(Object p) { |
| 3899 " (p is String) ? p.length : 0;", | 4277 (p is String) ? p.length : 0; |
| 3900 " (p) is String ? p.length : 0;", | 4278 (p) is String ? p.length : 0; |
| 3901 " ((p)) is String ? p.length : 0;", | 4279 ((p)) is String ? p.length : 0; |
| 3902 " ((p) is String) ? p.length : 0;", | 4280 ((p) is String) ? p.length : 0; |
| 3903 "}"])); | 4281 }'''); |
| 3904 resolve(source); | 4282 resolve(source); |
| 3905 assertNoErrors(source); | 4283 assertNoErrors(source); |
| 3906 verify([source]); | 4284 verify([source]); |
| 3907 } | 4285 } |
| 3908 | 4286 |
| 3909 void test_typeType_class() { | 4287 void test_typeType_class() { |
| 3910 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(Type
t) {}", "main() {", " f(C);", "}"])); | 4288 Source source = addSource(r''' |
| 4289 class C {} |
| 4290 f(Type t) {} |
| 4291 main() { |
| 4292 f(C); |
| 4293 }'''); |
| 3911 resolve(source); | 4294 resolve(source); |
| 3912 assertNoErrors(source); | 4295 assertNoErrors(source); |
| 3913 verify([source]); | 4296 verify([source]); |
| 3914 } | 4297 } |
| 3915 | 4298 |
| 3916 void test_typeType_class_prefixed() { | 4299 void test_typeType_class_prefixed() { |
| 3917 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "cl
ass C {}"])); | 4300 addNamedSource("/lib.dart", r''' |
| 3918 Source source = addSource(EngineTestCase.createSource([ | 4301 library lib; |
| 3919 "import 'lib.dart' as p;", | 4302 class C {}'''); |
| 3920 "f(Type t) {}", | 4303 Source source = addSource(r''' |
| 3921 "main() {", | 4304 import 'lib.dart' as p; |
| 3922 " f(p.C);", | 4305 f(Type t) {} |
| 3923 "}"])); | 4306 main() { |
| 4307 f(p.C); |
| 4308 }'''); |
| 3924 resolve(source); | 4309 resolve(source); |
| 3925 assertNoErrors(source); | 4310 assertNoErrors(source); |
| 3926 verify([source]); | 4311 verify([source]); |
| 3927 } | 4312 } |
| 3928 | 4313 |
| 3929 void test_typeType_functionTypeAlias() { | 4314 void test_typeType_functionTypeAlias() { |
| 3930 Source source = addSource(EngineTestCase.createSource([ | 4315 Source source = addSource(r''' |
| 3931 "typedef F();", | 4316 typedef F(); |
| 3932 "f(Type t) {}", | 4317 f(Type t) {} |
| 3933 "main() {", | 4318 main() { |
| 3934 " f(F);", | 4319 f(F); |
| 3935 "}"])); | 4320 }'''); |
| 3936 resolve(source); | 4321 resolve(source); |
| 3937 assertNoErrors(source); | 4322 assertNoErrors(source); |
| 3938 verify([source]); | 4323 verify([source]); |
| 3939 } | 4324 } |
| 3940 | 4325 |
| 3941 void test_typeType_functionTypeAlias_prefixed() { | 4326 void test_typeType_functionTypeAlias_prefixed() { |
| 3942 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "ty
pedef F();"])); | 4327 addNamedSource("/lib.dart", r''' |
| 3943 Source source = addSource(EngineTestCase.createSource([ | 4328 library lib; |
| 3944 "import 'lib.dart' as p;", | 4329 typedef F();'''); |
| 3945 "f(Type t) {}", | 4330 Source source = addSource(r''' |
| 3946 "main() {", | 4331 import 'lib.dart' as p; |
| 3947 " f(p.F);", | 4332 f(Type t) {} |
| 3948 "}"])); | 4333 main() { |
| 4334 f(p.F); |
| 4335 }'''); |
| 3949 resolve(source); | 4336 resolve(source); |
| 3950 assertNoErrors(source); | 4337 assertNoErrors(source); |
| 3951 verify([source]); | 4338 verify([source]); |
| 3952 } | 4339 } |
| 3953 | 4340 |
| 3954 void test_undefinedConstructorInInitializer_explicit_named() { | 4341 void test_undefinedConstructorInInitializer_explicit_named() { |
| 3955 Source source = addSource(EngineTestCase.createSource([ | 4342 Source source = addSource(r''' |
| 3956 "class A {", | 4343 class A { |
| 3957 " A.named() {}", | 4344 A.named() {} |
| 3958 "}", | 4345 } |
| 3959 "class B extends A {", | 4346 class B extends A { |
| 3960 " B() : super.named();", | 4347 B() : super.named(); |
| 3961 "}"])); | 4348 }'''); |
| 3962 resolve(source); | 4349 resolve(source); |
| 3963 assertNoErrors(source); | 4350 assertNoErrors(source); |
| 3964 verify([source]); | 4351 verify([source]); |
| 3965 } | 4352 } |
| 3966 | 4353 |
| 3967 void test_undefinedConstructorInInitializer_explicit_unnamed() { | 4354 void test_undefinedConstructorInInitializer_explicit_unnamed() { |
| 3968 Source source = addSource(EngineTestCase.createSource([ | 4355 Source source = addSource(r''' |
| 3969 "class A {", | 4356 class A { |
| 3970 " A() {}", | 4357 A() {} |
| 3971 "}", | 4358 } |
| 3972 "class B extends A {", | 4359 class B extends A { |
| 3973 " B() : super();", | 4360 B() : super(); |
| 3974 "}"])); | 4361 }'''); |
| 3975 resolve(source); | 4362 resolve(source); |
| 3976 assertNoErrors(source); | 4363 assertNoErrors(source); |
| 3977 verify([source]); | 4364 verify([source]); |
| 3978 } | 4365 } |
| 3979 | 4366 |
| 3980 void test_undefinedConstructorInInitializer_hasOptionalParameters() { | 4367 void test_undefinedConstructorInInitializer_hasOptionalParameters() { |
| 3981 Source source = addSource(EngineTestCase.createSource([ | 4368 Source source = addSource(r''' |
| 3982 "class A {", | 4369 class A { |
| 3983 " A([p]) {}", | 4370 A([p]) {} |
| 3984 "}", | 4371 } |
| 3985 "class B extends A {", | 4372 class B extends A { |
| 3986 " B();", | 4373 B(); |
| 3987 "}"])); | 4374 }'''); |
| 3988 resolve(source); | 4375 resolve(source); |
| 3989 assertNoErrors(source); | 4376 assertNoErrors(source); |
| 3990 verify([source]); | 4377 verify([source]); |
| 3991 } | 4378 } |
| 3992 | 4379 |
| 3993 void test_undefinedConstructorInInitializer_implicit() { | 4380 void test_undefinedConstructorInInitializer_implicit() { |
| 3994 Source source = addSource(EngineTestCase.createSource([ | 4381 Source source = addSource(r''' |
| 3995 "class A {", | 4382 class A { |
| 3996 " A() {}", | 4383 A() {} |
| 3997 "}", | 4384 } |
| 3998 "class B extends A {", | 4385 class B extends A { |
| 3999 " B();", | 4386 B(); |
| 4000 "}"])); | 4387 }'''); |
| 4001 resolve(source); | 4388 resolve(source); |
| 4002 assertNoErrors(source); | 4389 assertNoErrors(source); |
| 4003 verify([source]); | 4390 verify([source]); |
| 4004 } | 4391 } |
| 4005 | 4392 |
| 4006 void test_undefinedConstructorInInitializer_implicit_typeAlias() { | 4393 void test_undefinedConstructorInInitializer_implicit_typeAlias() { |
| 4007 Source source = addSource(EngineTestCase.createSource([ | 4394 Source source = addSource(r''' |
| 4008 "class M {}", | 4395 class M {} |
| 4009 "class A = Object with M;", | 4396 class A = Object with M; |
| 4010 "class B extends A {", | 4397 class B extends A { |
| 4011 " B();", | 4398 B(); |
| 4012 "}"])); | 4399 }'''); |
| 4013 resolve(source); | 4400 resolve(source); |
| 4014 assertNoErrors(source); | 4401 assertNoErrors(source); |
| 4015 verify([source]); | 4402 verify([source]); |
| 4016 } | 4403 } |
| 4017 | 4404 |
| 4018 void test_undefinedConstructorInInitializer_redirecting() { | 4405 void test_undefinedConstructorInInitializer_redirecting() { |
| 4019 Source source = addSource(EngineTestCase.createSource([ | 4406 Source source = addSource(r''' |
| 4020 "class Foo {", | 4407 class Foo { |
| 4021 " Foo.ctor();", | 4408 Foo.ctor(); |
| 4022 "}", | 4409 } |
| 4023 "class Bar extends Foo {", | 4410 class Bar extends Foo { |
| 4024 " Bar() : this.ctor();", | 4411 Bar() : this.ctor(); |
| 4025 " Bar.ctor() : super.ctor();", | 4412 Bar.ctor() : super.ctor(); |
| 4026 "}"])); | 4413 }'''); |
| 4027 resolve(source); | 4414 resolve(source); |
| 4028 assertNoErrors(source); | 4415 assertNoErrors(source); |
| 4029 verify([source]); | 4416 verify([source]); |
| 4030 } | 4417 } |
| 4031 | 4418 |
| 4032 void test_undefinedGetter_typeSubstitution() { | 4419 void test_undefinedGetter_typeSubstitution() { |
| 4033 Source source = addSource(EngineTestCase.createSource([ | 4420 Source source = addSource(r''' |
| 4034 "class A<E> {", | 4421 class A<E> { |
| 4035 " E element;", | 4422 E element; |
| 4036 "}", | 4423 } |
| 4037 "class B extends A<List> {", | 4424 class B extends A<List> { |
| 4038 " m() {", | 4425 m() { |
| 4039 " element.last;", | 4426 element.last; |
| 4040 " }", | 4427 } |
| 4041 "}"])); | 4428 }'''); |
| 4042 resolve(source); | 4429 resolve(source); |
| 4043 assertNoErrors(source); | 4430 assertNoErrors(source); |
| 4044 verify([source]); | 4431 verify([source]); |
| 4045 } | 4432 } |
| 4046 | 4433 |
| 4047 void test_undefinedIdentifier_hide() { | 4434 void test_undefinedIdentifier_hide() { |
| 4048 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' hide a;"])); | 4435 Source source = addSource(r''' |
| 4049 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;"]))
; | 4436 library L; |
| 4437 export 'lib1.dart' hide a;'''); |
| 4438 addNamedSource("/lib1.dart", "library lib1;"); |
| 4050 resolve(source); | 4439 resolve(source); |
| 4051 assertNoErrors(source); | 4440 assertNoErrors(source); |
| 4052 verify([source]); | 4441 verify([source]); |
| 4053 } | 4442 } |
| 4054 | 4443 |
| 4055 void test_undefinedIdentifier_show() { | 4444 void test_undefinedIdentifier_show() { |
| 4056 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' show a;"])); | 4445 Source source = addSource(r''' |
| 4057 addNamedSource("/lib1.dart", EngineTestCase.createSource(["library lib1;"]))
; | 4446 library L; |
| 4447 export 'lib1.dart' show a;'''); |
| 4448 addNamedSource("/lib1.dart", "library lib1;"); |
| 4058 resolve(source); | 4449 resolve(source); |
| 4059 assertNoErrors(source); | 4450 assertNoErrors(source); |
| 4060 verify([source]); | 4451 verify([source]); |
| 4061 } | 4452 } |
| 4062 | 4453 |
| 4063 void test_undefinedIdentifier_synthetic_whenExpression() { | 4454 void test_undefinedIdentifier_synthetic_whenExpression() { |
| 4064 Source source = addSource(EngineTestCase.createSource(["print(x) {}", "main(
) {", " print(is String);", "}"])); | 4455 Source source = addSource(r''' |
| 4456 print(x) {} |
| 4457 main() { |
| 4458 print(is String); |
| 4459 }'''); |
| 4065 resolve(source); | 4460 resolve(source); |
| 4066 assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]); | 4461 assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]); |
| 4067 } | 4462 } |
| 4068 | 4463 |
| 4069 void test_undefinedIdentifier_synthetic_whenMethodName() { | 4464 void test_undefinedIdentifier_synthetic_whenMethodName() { |
| 4070 Source source = addSource(EngineTestCase.createSource(["print(x) {}", "main(
int p) {", " p.();", "}"])); | 4465 Source source = addSource(r''' |
| 4466 print(x) {} |
| 4467 main(int p) { |
| 4468 p.(); |
| 4469 }'''); |
| 4071 resolve(source); | 4470 resolve(source); |
| 4072 assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]); | 4471 assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]); |
| 4073 } | 4472 } |
| 4074 | 4473 |
| 4075 void test_undefinedMethod_functionExpression_callMethod() { | 4474 void test_undefinedMethod_functionExpression_callMethod() { |
| 4076 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null).call();", "}"])); | 4475 Source source = addSource(r''' |
| 4476 main() { |
| 4477 (() => null).call(); |
| 4478 }'''); |
| 4077 resolve(source); | 4479 resolve(source); |
| 4078 assertNoErrors(source); | 4480 assertNoErrors(source); |
| 4079 // A call to verify(source) fails as '.call()' isn't resolved. | 4481 // A call to verify(source) fails as '.call()' isn't resolved. |
| 4080 } | 4482 } |
| 4081 | 4483 |
| 4082 void test_undefinedMethod_functionExpression_directCall() { | 4484 void test_undefinedMethod_functionExpression_directCall() { |
| 4083 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null)();", "}"])); | 4485 Source source = addSource(r''' |
| 4486 main() { |
| 4487 (() => null)(); |
| 4488 }'''); |
| 4084 resolve(source); | 4489 resolve(source); |
| 4085 assertNoErrors(source); | 4490 assertNoErrors(source); |
| 4086 // A call to verify(source) fails as '(() => null)()' isn't resolved. | 4491 // A call to verify(source) fails as '(() => null)()' isn't resolved. |
| 4087 } | 4492 } |
| 4088 | 4493 |
| 4089 void test_undefinedOperator_index() { | 4494 void test_undefinedOperator_index() { |
| 4090 Source source = addSource(EngineTestCase.createSource([ | 4495 Source source = addSource(r''' |
| 4091 "class A {", | 4496 class A { |
| 4092 " operator [](a) {}", | 4497 operator [](a) {} |
| 4093 " operator []=(a, b) {}", | 4498 operator []=(a, b) {} |
| 4094 "}", | 4499 } |
| 4095 "f(A a) {", | 4500 f(A a) { |
| 4096 " a[0];", | 4501 a[0]; |
| 4097 " a[0] = 1;", | 4502 a[0] = 1; |
| 4098 "}"])); | 4503 }'''); |
| 4099 resolve(source); | 4504 resolve(source); |
| 4100 assertNoErrors(source); | 4505 assertNoErrors(source); |
| 4101 verify([source]); | 4506 verify([source]); |
| 4102 } | 4507 } |
| 4103 | 4508 |
| 4104 void test_undefinedOperator_tilde() { | 4509 void test_undefinedOperator_tilde() { |
| 4105 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons
t B = ~((1 << A) - 1);"])); | 4510 Source source = addSource(r''' |
| 4511 const A = 3; |
| 4512 const B = ~((1 << A) - 1);'''); |
| 4106 resolve(source); | 4513 resolve(source); |
| 4107 assertNoErrors(source); | 4514 assertNoErrors(source); |
| 4108 verify([source]); | 4515 verify([source]); |
| 4109 } | 4516 } |
| 4110 | 4517 |
| 4111 void test_undefinedSetter_importWithPrefix() { | 4518 void test_undefinedSetter_importWithPrefix() { |
| 4112 addNamedSource("/lib.dart", EngineTestCase.createSource(["library lib;", "se
t y(int value) {}"])); | 4519 addNamedSource("/lib.dart", r''' |
| 4113 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
x;", "main() {", " x.y = 0;", "}"])); | 4520 library lib; |
| 4521 set y(int value) {}'''); |
| 4522 Source source = addSource(r''' |
| 4523 import 'lib.dart' as x; |
| 4524 main() { |
| 4525 x.y = 0; |
| 4526 }'''); |
| 4114 resolve(source); | 4527 resolve(source); |
| 4115 assertNoErrors(source); | 4528 assertNoErrors(source); |
| 4116 verify([source]); | 4529 verify([source]); |
| 4117 } | 4530 } |
| 4118 | 4531 |
| 4119 void test_undefinedSuperMethod_field() { | 4532 void test_undefinedSuperMethod_field() { |
| 4120 Source source = addSource(EngineTestCase.createSource([ | 4533 Source source = addSource(r''' |
| 4121 "class A {", | 4534 class A { |
| 4122 " var m;", | 4535 var m; |
| 4123 "}", | 4536 } |
| 4124 "class B extends A {", | 4537 class B extends A { |
| 4125 " f() {", | 4538 f() { |
| 4126 " super.m();", | 4539 super.m(); |
| 4127 " }", | 4540 } |
| 4128 "}"])); | 4541 }'''); |
| 4129 resolve(source); | 4542 resolve(source); |
| 4130 assertNoErrors(source); | 4543 assertNoErrors(source); |
| 4131 verify([source]); | 4544 verify([source]); |
| 4132 } | 4545 } |
| 4133 | 4546 |
| 4134 void test_undefinedSuperMethod_method() { | 4547 void test_undefinedSuperMethod_method() { |
| 4135 Source source = addSource(EngineTestCase.createSource([ | 4548 Source source = addSource(r''' |
| 4136 "class A {", | 4549 class A { |
| 4137 " m() {}", | 4550 m() {} |
| 4138 "}", | 4551 } |
| 4139 "class B extends A {", | 4552 class B extends A { |
| 4140 " f() {", | 4553 f() { |
| 4141 " super.m();", | 4554 super.m(); |
| 4142 " }", | 4555 } |
| 4143 "}"])); | 4556 }'''); |
| 4144 resolve(source); | 4557 resolve(source); |
| 4145 assertNoErrors(source); | 4558 assertNoErrors(source); |
| 4146 verify([source]); | 4559 verify([source]); |
| 4147 } | 4560 } |
| 4148 | 4561 |
| 4149 void test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() { | 4562 void test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() { |
| 4150 Source source = addSource(EngineTestCase.createSource([ | 4563 Source source = addSource(r''' |
| 4151 "class A {", | 4564 class A { |
| 4152 " A() {}", | 4565 A() {} |
| 4153 " A.named() {}", | 4566 A.named() {} |
| 4154 "}", | 4567 } |
| 4155 "/// [new A] or [new A.named]", | 4568 /// [new A] or [new A.named] |
| 4156 "main() {", | 4569 main() { |
| 4157 "}"])); | 4570 }'''); |
| 4158 resolve(source); | 4571 resolve(source); |
| 4159 assertNoErrors(source); | 4572 assertNoErrors(source); |
| 4160 verify([source]); | 4573 verify([source]); |
| 4161 } | 4574 } |
| 4162 | 4575 |
| 4163 void test_uriDoesNotExist_dll() { | 4576 void test_uriDoesNotExist_dll() { |
| 4164 addNamedSource("/lib.dll", ""); | 4577 addNamedSource("/lib.dll", ""); |
| 4165 Source source = addSource(EngineTestCase.createSource(["import 'dart-ext:lib
';"])); | 4578 Source source = addSource("import 'dart-ext:lib';"); |
| 4166 resolve(source); | 4579 resolve(source); |
| 4167 assertNoErrors(source); | 4580 assertNoErrors(source); |
| 4168 } | 4581 } |
| 4169 | 4582 |
| 4170 void test_uriDoesNotExist_dylib() { | 4583 void test_uriDoesNotExist_dylib() { |
| 4171 addNamedSource("/lib.dylib", ""); | 4584 addNamedSource("/lib.dylib", ""); |
| 4172 Source source = addSource(EngineTestCase.createSource(["import 'dart-ext:lib
';"])); | 4585 Source source = addSource("import 'dart-ext:lib';"); |
| 4173 resolve(source); | 4586 resolve(source); |
| 4174 assertNoErrors(source); | 4587 assertNoErrors(source); |
| 4175 } | 4588 } |
| 4176 | 4589 |
| 4177 void test_uriDoesNotExist_so() { | 4590 void test_uriDoesNotExist_so() { |
| 4178 addNamedSource("/lib.so", ""); | 4591 addNamedSource("/lib.so", ""); |
| 4179 Source source = addSource(EngineTestCase.createSource(["import 'dart-ext:lib
';"])); | 4592 Source source = addSource("import 'dart-ext:lib';"); |
| 4180 resolve(source); | 4593 resolve(source); |
| 4181 assertNoErrors(source); | 4594 assertNoErrors(source); |
| 4182 } | 4595 } |
| 4183 | 4596 |
| 4184 void test_wrongNumberOfParametersForOperator_index() { | 4597 void test_wrongNumberOfParametersForOperator_index() { |
| 4185 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); | 4598 Source source = addSource(r''' |
| 4599 class A { |
| 4600 operator []=(a, b) {} |
| 4601 }'''); |
| 4186 resolve(source); | 4602 resolve(source); |
| 4187 assertNoErrors(source); | 4603 assertNoErrors(source); |
| 4188 verify([source]); | 4604 verify([source]); |
| 4189 } | 4605 } |
| 4190 | 4606 |
| 4191 void test_wrongNumberOfParametersForOperator_minus() { | 4607 void test_wrongNumberOfParametersForOperator_minus() { |
| 4192 _check_wrongNumberOfParametersForOperator("-", ""); | 4608 _check_wrongNumberOfParametersForOperator("-", ""); |
| 4193 _check_wrongNumberOfParametersForOperator("-", "a"); | 4609 _check_wrongNumberOfParametersForOperator("-", "a"); |
| 4194 } | 4610 } |
| 4195 | 4611 |
| 4196 void test_wrongNumberOfParametersForOperator1() { | 4612 void test_wrongNumberOfParametersForOperator1() { |
| 4197 _check_wrongNumberOfParametersForOperator1("<"); | 4613 _check_wrongNumberOfParametersForOperator1("<"); |
| 4198 _check_wrongNumberOfParametersForOperator1(">"); | 4614 _check_wrongNumberOfParametersForOperator1(">"); |
| 4199 _check_wrongNumberOfParametersForOperator1("<="); | 4615 _check_wrongNumberOfParametersForOperator1("<="); |
| 4200 _check_wrongNumberOfParametersForOperator1(">="); | 4616 _check_wrongNumberOfParametersForOperator1(">="); |
| 4201 _check_wrongNumberOfParametersForOperator1("+"); | 4617 _check_wrongNumberOfParametersForOperator1("+"); |
| 4202 _check_wrongNumberOfParametersForOperator1("/"); | 4618 _check_wrongNumberOfParametersForOperator1("/"); |
| 4203 _check_wrongNumberOfParametersForOperator1("~/"); | 4619 _check_wrongNumberOfParametersForOperator1("~/"); |
| 4204 _check_wrongNumberOfParametersForOperator1("*"); | 4620 _check_wrongNumberOfParametersForOperator1("*"); |
| 4205 _check_wrongNumberOfParametersForOperator1("%"); | 4621 _check_wrongNumberOfParametersForOperator1("%"); |
| 4206 _check_wrongNumberOfParametersForOperator1("|"); | 4622 _check_wrongNumberOfParametersForOperator1("|"); |
| 4207 _check_wrongNumberOfParametersForOperator1("^"); | 4623 _check_wrongNumberOfParametersForOperator1("^"); |
| 4208 _check_wrongNumberOfParametersForOperator1("&"); | 4624 _check_wrongNumberOfParametersForOperator1("&"); |
| 4209 _check_wrongNumberOfParametersForOperator1("<<"); | 4625 _check_wrongNumberOfParametersForOperator1("<<"); |
| 4210 _check_wrongNumberOfParametersForOperator1(">>"); | 4626 _check_wrongNumberOfParametersForOperator1(">>"); |
| 4211 _check_wrongNumberOfParametersForOperator1("[]"); | 4627 _check_wrongNumberOfParametersForOperator1("[]"); |
| 4212 } | 4628 } |
| 4213 | 4629 |
| 4214 void test_wrongNumberOfParametersForSetter() { | 4630 void test_wrongNumberOfParametersForSetter() { |
| 4215 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a) {}", "}"])); | 4631 Source source = addSource(r''' |
| 4632 class A { |
| 4633 set x(a) {} |
| 4634 }'''); |
| 4216 resolve(source); | 4635 resolve(source); |
| 4217 assertNoErrors(source); | 4636 assertNoErrors(source); |
| 4218 verify([source]); | 4637 verify([source]); |
| 4219 } | 4638 } |
| 4220 | 4639 |
| 4221 void test_yieldEachInNonGenerator_asyncStar() { | 4640 void test_yieldEachInNonGenerator_asyncStar() { |
| 4222 resetWithAsync(); | 4641 resetWithAsync(); |
| 4223 Source source = addSource(EngineTestCase.createSource(["f() async* {", " yi
eld* 0;", "}"])); | 4642 Source source = addSource(r''' |
| 4643 f() async* { |
| 4644 yield* 0; |
| 4645 }'''); |
| 4224 resolve(source); | 4646 resolve(source); |
| 4225 assertNoErrors(source); | 4647 assertNoErrors(source); |
| 4226 verify([source]); | 4648 verify([source]); |
| 4227 } | 4649 } |
| 4228 | 4650 |
| 4229 void test_yieldEachInNonGenerator_syncStar() { | 4651 void test_yieldEachInNonGenerator_syncStar() { |
| 4230 resetWithAsync(); | 4652 resetWithAsync(); |
| 4231 Source source = addSource(EngineTestCase.createSource(["f() sync* {", " yie
ld* 0;", "}"])); | 4653 Source source = addSource(r''' |
| 4654 f() sync* { |
| 4655 yield* 0; |
| 4656 }'''); |
| 4232 resolve(source); | 4657 resolve(source); |
| 4233 assertNoErrors(source); | 4658 assertNoErrors(source); |
| 4234 verify([source]); | 4659 verify([source]); |
| 4235 } | 4660 } |
| 4236 | 4661 |
| 4237 void test_yieldInNonGenerator_asyncStar() { | 4662 void test_yieldInNonGenerator_asyncStar() { |
| 4238 resetWithAsync(); | 4663 resetWithAsync(); |
| 4239 Source source = addSource(EngineTestCase.createSource(["f() async* {", " yi
eld 0;", "}"])); | 4664 Source source = addSource(r''' |
| 4665 f() async* { |
| 4666 yield 0; |
| 4667 }'''); |
| 4240 resolve(source); | 4668 resolve(source); |
| 4241 assertNoErrors(source); | 4669 assertNoErrors(source); |
| 4242 verify([source]); | 4670 verify([source]); |
| 4243 } | 4671 } |
| 4244 | 4672 |
| 4245 void test_yieldInNonGenerator_syncStar() { | 4673 void test_yieldInNonGenerator_syncStar() { |
| 4246 resetWithAsync(); | 4674 resetWithAsync(); |
| 4247 Source source = addSource(EngineTestCase.createSource(["f() sync* {", " yie
ld 0;", "}"])); | 4675 Source source = addSource(r''' |
| 4676 f() sync* { |
| 4677 yield 0; |
| 4678 }'''); |
| 4248 resolve(source); | 4679 resolve(source); |
| 4249 assertNoErrors(source); | 4680 assertNoErrors(source); |
| 4250 verify([source]); | 4681 verify([source]); |
| 4251 } | 4682 } |
| 4252 | 4683 |
| 4253 void _check_wrongNumberOfParametersForOperator(String name, String parameters)
{ | 4684 void _check_wrongNumberOfParametersForOperator(String name, String parameters)
{ |
| 4254 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); | 4685 Source source = addSource(""" |
| 4686 class A { |
| 4687 operator $name($parameters) {} |
| 4688 }"""); |
| 4255 resolve(source); | 4689 resolve(source); |
| 4256 assertNoErrors(source); | 4690 assertNoErrors(source); |
| 4257 verify([source]); | 4691 verify([source]); |
| 4258 reset(); | 4692 reset(); |
| 4259 } | 4693 } |
| 4260 | 4694 |
| 4261 void _check_wrongNumberOfParametersForOperator1(String name) { | 4695 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 4262 _check_wrongNumberOfParametersForOperator(name, "a"); | 4696 _check_wrongNumberOfParametersForOperator(name, "a"); |
| 4263 } | 4697 } |
| 4264 } | 4698 } |
| 4265 | 4699 |
| 4266 main() { | 4700 main() { |
| 4267 _ut.groupSep = ' | '; | 4701 _ut.groupSep = ' | '; |
| 4268 runReflectiveTests(NonErrorResolverTest); | 4702 runReflectiveTests(NonErrorResolverTest); |
| 4269 } | 4703 } |
| OLD | NEW |