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