| 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 analyzer.test.generated.static_warning_code_test; | 5 library analyzer.test.generated.static_warning_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/error/error.dart'; | 7 import 'package:analyzer/error/error.dart'; |
| 8 import 'package:analyzer/src/error/codes.dart'; | 8 import 'package:analyzer/src/error/codes.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 await computeAnalysisResult(source); | 65 await computeAnalysisResult(source); |
| 66 assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]); | 66 assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]); |
| 67 verify([source]); | 67 verify([source]); |
| 68 } | 68 } |
| 69 | 69 |
| 70 test_ambiguousImport_as() async { | 70 test_ambiguousImport_as() async { |
| 71 Source source = addSource(r''' | 71 Source source = addSource(r''' |
| 72 import 'lib1.dart'; | 72 import 'lib1.dart'; |
| 73 import 'lib2.dart'; | 73 import 'lib2.dart'; |
| 74 f(p) {p as N;}'''); | 74 f(p) {p as N;}'''); |
| 75 addNamedSource( | 75 addNamedSource("/lib1.dart", r''' |
| 76 "/lib1.dart", | |
| 77 r''' | |
| 78 library lib1; | 76 library lib1; |
| 79 class N {}'''); | 77 class N {}'''); |
| 80 addNamedSource( | 78 addNamedSource("/lib2.dart", r''' |
| 81 "/lib2.dart", | |
| 82 r''' | |
| 83 library lib2; | 79 library lib2; |
| 84 class N {}'''); | 80 class N {}'''); |
| 85 await computeAnalysisResult(source); | 81 await computeAnalysisResult(source); |
| 86 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 82 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 87 } | 83 } |
| 88 | 84 |
| 89 test_ambiguousImport_extends() async { | 85 test_ambiguousImport_extends() async { |
| 90 Source source = addSource(r''' | 86 Source source = addSource(r''' |
| 91 import 'lib1.dart'; | 87 import 'lib1.dart'; |
| 92 import 'lib2.dart'; | 88 import 'lib2.dart'; |
| 93 class A extends N {}'''); | 89 class A extends N {}'''); |
| 94 addNamedSource( | 90 addNamedSource("/lib1.dart", r''' |
| 95 "/lib1.dart", | |
| 96 r''' | |
| 97 library lib1; | 91 library lib1; |
| 98 class N {}'''); | 92 class N {}'''); |
| 99 addNamedSource( | 93 addNamedSource("/lib2.dart", r''' |
| 100 "/lib2.dart", | |
| 101 r''' | |
| 102 library lib2; | 94 library lib2; |
| 103 class N {}'''); | 95 class N {}'''); |
| 104 await computeAnalysisResult(source); | 96 await computeAnalysisResult(source); |
| 105 assertErrors(source, [ | 97 assertErrors(source, [ |
| 106 StaticWarningCode.AMBIGUOUS_IMPORT, | 98 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 107 CompileTimeErrorCode.EXTENDS_NON_CLASS | 99 CompileTimeErrorCode.EXTENDS_NON_CLASS |
| 108 ]); | 100 ]); |
| 109 } | 101 } |
| 110 | 102 |
| 111 test_ambiguousImport_implements() async { | 103 test_ambiguousImport_implements() async { |
| 112 Source source = addSource(r''' | 104 Source source = addSource(r''' |
| 113 import 'lib1.dart'; | 105 import 'lib1.dart'; |
| 114 import 'lib2.dart'; | 106 import 'lib2.dart'; |
| 115 class A implements N {}'''); | 107 class A implements N {}'''); |
| 116 addNamedSource( | 108 addNamedSource("/lib1.dart", r''' |
| 117 "/lib1.dart", | |
| 118 r''' | |
| 119 library lib1; | 109 library lib1; |
| 120 class N {}'''); | 110 class N {}'''); |
| 121 addNamedSource( | 111 addNamedSource("/lib2.dart", r''' |
| 122 "/lib2.dart", | |
| 123 r''' | |
| 124 library lib2; | 112 library lib2; |
| 125 class N {}'''); | 113 class N {}'''); |
| 126 await computeAnalysisResult(source); | 114 await computeAnalysisResult(source); |
| 127 assertErrors(source, [ | 115 assertErrors(source, [ |
| 128 StaticWarningCode.AMBIGUOUS_IMPORT, | 116 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 129 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS | 117 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS |
| 130 ]); | 118 ]); |
| 131 } | 119 } |
| 132 | 120 |
| 133 test_ambiguousImport_inPart() async { | 121 test_ambiguousImport_inPart() async { |
| 134 Source source = addSource(r''' | 122 Source source = addSource(r''' |
| 135 library lib; | 123 library lib; |
| 136 import 'lib1.dart'; | 124 import 'lib1.dart'; |
| 137 import 'lib2.dart'; | 125 import 'lib2.dart'; |
| 138 part 'part.dart';'''); | 126 part 'part.dart';'''); |
| 139 addNamedSource( | 127 addNamedSource("/lib1.dart", r''' |
| 140 "/lib1.dart", | |
| 141 r''' | |
| 142 library lib1; | 128 library lib1; |
| 143 class N {}'''); | 129 class N {}'''); |
| 144 addNamedSource( | 130 addNamedSource("/lib2.dart", r''' |
| 145 "/lib2.dart", | |
| 146 r''' | |
| 147 library lib2; | 131 library lib2; |
| 148 class N {}'''); | 132 class N {}'''); |
| 149 Source partSource = addNamedSource( | 133 Source partSource = addNamedSource("/part.dart", r''' |
| 150 "/part.dart", | |
| 151 r''' | |
| 152 part of lib; | 134 part of lib; |
| 153 class A extends N {}'''); | 135 class A extends N {}'''); |
| 154 await computeAnalysisResult(source); | 136 await computeAnalysisResult(source); |
| 155 await computeAnalysisResult(partSource); | 137 await computeAnalysisResult(partSource); |
| 156 assertNoErrors(source); | 138 assertNoErrors(source); |
| 157 assertErrors(partSource, [ | 139 assertErrors(partSource, [ |
| 158 StaticWarningCode.AMBIGUOUS_IMPORT, | 140 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 159 CompileTimeErrorCode.EXTENDS_NON_CLASS | 141 CompileTimeErrorCode.EXTENDS_NON_CLASS |
| 160 ]); | 142 ]); |
| 161 } | 143 } |
| 162 | 144 |
| 163 test_ambiguousImport_instanceCreation() async { | 145 test_ambiguousImport_instanceCreation() async { |
| 164 Source source = addSource(r''' | 146 Source source = addSource(r''' |
| 165 library L; | 147 library L; |
| 166 import 'lib1.dart'; | 148 import 'lib1.dart'; |
| 167 import 'lib2.dart'; | 149 import 'lib2.dart'; |
| 168 f() {new N();}'''); | 150 f() {new N();}'''); |
| 169 addNamedSource( | 151 addNamedSource("/lib1.dart", r''' |
| 170 "/lib1.dart", | |
| 171 r''' | |
| 172 library lib1; | 152 library lib1; |
| 173 class N {}'''); | 153 class N {}'''); |
| 174 addNamedSource( | 154 addNamedSource("/lib2.dart", r''' |
| 175 "/lib2.dart", | |
| 176 r''' | |
| 177 library lib2; | 155 library lib2; |
| 178 class N {}'''); | 156 class N {}'''); |
| 179 await computeAnalysisResult(source); | 157 await computeAnalysisResult(source); |
| 180 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 158 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 181 } | 159 } |
| 182 | 160 |
| 183 test_ambiguousImport_is() async { | 161 test_ambiguousImport_is() async { |
| 184 Source source = addSource(r''' | 162 Source source = addSource(r''' |
| 185 import 'lib1.dart'; | 163 import 'lib1.dart'; |
| 186 import 'lib2.dart'; | 164 import 'lib2.dart'; |
| 187 f(p) {p is N;}'''); | 165 f(p) {p is N;}'''); |
| 188 addNamedSource( | 166 addNamedSource("/lib1.dart", r''' |
| 189 "/lib1.dart", | |
| 190 r''' | |
| 191 library lib1; | 167 library lib1; |
| 192 class N {}'''); | 168 class N {}'''); |
| 193 addNamedSource( | 169 addNamedSource("/lib2.dart", r''' |
| 194 "/lib2.dart", | |
| 195 r''' | |
| 196 library lib2; | 170 library lib2; |
| 197 class N {}'''); | 171 class N {}'''); |
| 198 await computeAnalysisResult(source); | 172 await computeAnalysisResult(source); |
| 199 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 173 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 200 } | 174 } |
| 201 | 175 |
| 202 test_ambiguousImport_qualifier() async { | 176 test_ambiguousImport_qualifier() async { |
| 203 Source source = addSource(r''' | 177 Source source = addSource(r''' |
| 204 import 'lib1.dart'; | 178 import 'lib1.dart'; |
| 205 import 'lib2.dart'; | 179 import 'lib2.dart'; |
| 206 g() { N.FOO; }'''); | 180 g() { N.FOO; }'''); |
| 207 addNamedSource( | 181 addNamedSource("/lib1.dart", r''' |
| 208 "/lib1.dart", | |
| 209 r''' | |
| 210 library lib1; | 182 library lib1; |
| 211 class N {}'''); | 183 class N {}'''); |
| 212 addNamedSource( | 184 addNamedSource("/lib2.dart", r''' |
| 213 "/lib2.dart", | |
| 214 r''' | |
| 215 library lib2; | 185 library lib2; |
| 216 class N {}'''); | 186 class N {}'''); |
| 217 await computeAnalysisResult(source); | 187 await computeAnalysisResult(source); |
| 218 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 188 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 219 } | 189 } |
| 220 | 190 |
| 221 test_ambiguousImport_typeAnnotation() async { | 191 test_ambiguousImport_typeAnnotation() async { |
| 222 Source source = addSource(r''' | 192 Source source = addSource(r''' |
| 223 import 'lib1.dart'; | 193 import 'lib1.dart'; |
| 224 import 'lib2.dart'; | 194 import 'lib2.dart'; |
| 225 typedef N FT(N p); | 195 typedef N FT(N p); |
| 226 N f(N p) { | 196 N f(N p) { |
| 227 N v; | 197 N v; |
| 228 return null; | 198 return null; |
| 229 } | 199 } |
| 230 class A { | 200 class A { |
| 231 N m() { return null; } | 201 N m() { return null; } |
| 232 } | 202 } |
| 233 class B<T extends N> {}'''); | 203 class B<T extends N> {}'''); |
| 234 addNamedSource( | 204 addNamedSource("/lib1.dart", r''' |
| 235 "/lib1.dart", | |
| 236 r''' | |
| 237 library lib1; | 205 library lib1; |
| 238 class N {}'''); | 206 class N {}'''); |
| 239 addNamedSource( | 207 addNamedSource("/lib2.dart", r''' |
| 240 "/lib2.dart", | |
| 241 r''' | |
| 242 library lib2; | 208 library lib2; |
| 243 class N {}'''); | 209 class N {}'''); |
| 244 await computeAnalysisResult(source); | 210 await computeAnalysisResult(source); |
| 245 assertErrors(source, [ | 211 assertErrors(source, [ |
| 246 StaticWarningCode.AMBIGUOUS_IMPORT, | 212 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 247 StaticWarningCode.AMBIGUOUS_IMPORT, | 213 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 248 StaticWarningCode.AMBIGUOUS_IMPORT, | 214 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 249 StaticWarningCode.AMBIGUOUS_IMPORT, | 215 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 250 StaticWarningCode.AMBIGUOUS_IMPORT, | 216 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 251 StaticWarningCode.AMBIGUOUS_IMPORT, | 217 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 252 StaticWarningCode.AMBIGUOUS_IMPORT | 218 StaticWarningCode.AMBIGUOUS_IMPORT |
| 253 ]); | 219 ]); |
| 254 } | 220 } |
| 255 | 221 |
| 256 test_ambiguousImport_typeArgument_annotation() async { | 222 test_ambiguousImport_typeArgument_annotation() async { |
| 257 Source source = addSource(r''' | 223 Source source = addSource(r''' |
| 258 import 'lib1.dart'; | 224 import 'lib1.dart'; |
| 259 import 'lib2.dart'; | 225 import 'lib2.dart'; |
| 260 class A<T> {} | 226 class A<T> {} |
| 261 A<N> f() { return null; }'''); | 227 A<N> f() { return null; }'''); |
| 262 addNamedSource( | 228 addNamedSource("/lib1.dart", r''' |
| 263 "/lib1.dart", | |
| 264 r''' | |
| 265 library lib1; | 229 library lib1; |
| 266 class N {}'''); | 230 class N {}'''); |
| 267 addNamedSource( | 231 addNamedSource("/lib2.dart", r''' |
| 268 "/lib2.dart", | |
| 269 r''' | |
| 270 library lib2; | 232 library lib2; |
| 271 class N {}'''); | 233 class N {}'''); |
| 272 await computeAnalysisResult(source); | 234 await computeAnalysisResult(source); |
| 273 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 235 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 274 } | 236 } |
| 275 | 237 |
| 276 test_ambiguousImport_typeArgument_instanceCreation() async { | 238 test_ambiguousImport_typeArgument_instanceCreation() async { |
| 277 Source source = addSource(r''' | 239 Source source = addSource(r''' |
| 278 import 'lib1.dart'; | 240 import 'lib1.dart'; |
| 279 import 'lib2.dart'; | 241 import 'lib2.dart'; |
| 280 class A<T> {} | 242 class A<T> {} |
| 281 f() {new A<N>();}'''); | 243 f() {new A<N>();}'''); |
| 282 addNamedSource( | 244 addNamedSource("/lib1.dart", r''' |
| 283 "/lib1.dart", | |
| 284 r''' | |
| 285 library lib1; | 245 library lib1; |
| 286 class N {}'''); | 246 class N {}'''); |
| 287 addNamedSource( | 247 addNamedSource("/lib2.dart", r''' |
| 288 "/lib2.dart", | |
| 289 r''' | |
| 290 library lib2; | 248 library lib2; |
| 291 class N {}'''); | 249 class N {}'''); |
| 292 await computeAnalysisResult(source); | 250 await computeAnalysisResult(source); |
| 293 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 251 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 294 } | 252 } |
| 295 | 253 |
| 296 test_ambiguousImport_varRead() async { | 254 test_ambiguousImport_varRead() async { |
| 297 Source source = addSource(r''' | 255 Source source = addSource(r''' |
| 298 import 'lib1.dart'; | 256 import 'lib1.dart'; |
| 299 import 'lib2.dart'; | 257 import 'lib2.dart'; |
| 300 f() { g(v); } | 258 f() { g(v); } |
| 301 g(p) {}'''); | 259 g(p) {}'''); |
| 302 addNamedSource( | 260 addNamedSource("/lib1.dart", r''' |
| 303 "/lib1.dart", | |
| 304 r''' | |
| 305 library lib1; | 261 library lib1; |
| 306 var v;'''); | 262 var v;'''); |
| 307 addNamedSource( | 263 addNamedSource("/lib2.dart", r''' |
| 308 "/lib2.dart", | |
| 309 r''' | |
| 310 library lib2; | 264 library lib2; |
| 311 var v;'''); | 265 var v;'''); |
| 312 await computeAnalysisResult(source); | 266 await computeAnalysisResult(source); |
| 313 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 267 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 314 } | 268 } |
| 315 | 269 |
| 316 test_ambiguousImport_varWrite() async { | 270 test_ambiguousImport_varWrite() async { |
| 317 Source source = addSource(r''' | 271 Source source = addSource(r''' |
| 318 import 'lib1.dart'; | 272 import 'lib1.dart'; |
| 319 import 'lib2.dart'; | 273 import 'lib2.dart'; |
| 320 f() { v = 0; }'''); | 274 f() { v = 0; }'''); |
| 321 addNamedSource( | 275 addNamedSource("/lib1.dart", r''' |
| 322 "/lib1.dart", | |
| 323 r''' | |
| 324 library lib1; | 276 library lib1; |
| 325 var v;'''); | 277 var v;'''); |
| 326 addNamedSource( | 278 addNamedSource("/lib2.dart", r''' |
| 327 "/lib2.dart", | |
| 328 r''' | |
| 329 library lib2; | 279 library lib2; |
| 330 var v;'''); | 280 var v;'''); |
| 331 await computeAnalysisResult(source); | 281 await computeAnalysisResult(source); |
| 332 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 282 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 333 } | 283 } |
| 334 | 284 |
| 335 test_ambiguousImport_withPrefix() async { | 285 test_ambiguousImport_withPrefix() async { |
| 336 Source source = addSource(r''' | 286 Source source = addSource(r''' |
| 337 library test; | 287 library test; |
| 338 import 'lib1.dart' as p; | 288 import 'lib1.dart' as p; |
| 339 import 'lib2.dart' as p; | 289 import 'lib2.dart' as p; |
| 340 main() { | 290 main() { |
| 341 p.f(); | 291 p.f(); |
| 342 }'''); | 292 }'''); |
| 343 addNamedSource( | 293 addNamedSource("/lib1.dart", r''' |
| 344 "/lib1.dart", | |
| 345 r''' | |
| 346 library lib1; | 294 library lib1; |
| 347 f() {}'''); | 295 f() {}'''); |
| 348 addNamedSource( | 296 addNamedSource("/lib2.dart", r''' |
| 349 "/lib2.dart", | |
| 350 r''' | |
| 351 library lib2; | 297 library lib2; |
| 352 f() {}'''); | 298 f() {}'''); |
| 353 await computeAnalysisResult(source); | 299 await computeAnalysisResult(source); |
| 354 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 300 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 355 } | 301 } |
| 356 | 302 |
| 357 test_argumentTypeNotAssignable_ambiguousClassName() async { | 303 test_argumentTypeNotAssignable_ambiguousClassName() async { |
| 358 // See dartbug.com/19624 | 304 // See dartbug.com/19624 |
| 359 Source source = addNamedSource( | 305 Source source = addNamedSource("/lib1.dart", r''' |
| 360 "/lib1.dart", | |
| 361 r''' | |
| 362 library lib1; | 306 library lib1; |
| 363 import 'lib2.dart'; | 307 import 'lib2.dart'; |
| 364 class _A {} | 308 class _A {} |
| 365 f() { | 309 f() { |
| 366 g((_A a) {}); | 310 g((_A a) {}); |
| 367 }'''); | 311 }'''); |
| 368 addNamedSource( | 312 addNamedSource("/lib2.dart", r''' |
| 369 "/lib2.dart", | |
| 370 r''' | |
| 371 library lib2; | 313 library lib2; |
| 372 class _A {} | 314 class _A {} |
| 373 g(h(_A a)) {}'''); | 315 g(h(_A a)) {}'''); |
| 374 // The name _A is private to the library it's defined in, so this is a type | 316 // The name _A is private to the library it's defined in, so this is a type |
| 375 // mismatch. Furthermore, the error message should mention both _A and the | 317 // mismatch. Furthermore, the error message should mention both _A and the |
| 376 // filenames so the user can figure out what's going on. | 318 // filenames so the user can figure out what's going on. |
| 377 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 319 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 378 List<AnalysisError> errors = analysisResult.errors; | 320 List<AnalysisError> errors = analysisResult.errors; |
| 379 expect(errors, hasLength(1)); | 321 expect(errors, hasLength(1)); |
| 380 AnalysisError error = errors[0]; | 322 AnalysisError error = errors[0]; |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]); | 948 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]); |
| 1007 verify([source]); | 949 verify([source]); |
| 1008 } | 950 } |
| 1009 | 951 |
| 1010 test_conflictingDartImport() async { | 952 test_conflictingDartImport() async { |
| 1011 Source source = addSource(r''' | 953 Source source = addSource(r''' |
| 1012 import 'lib.dart'; | 954 import 'lib.dart'; |
| 1013 import 'dart:async'; | 955 import 'dart:async'; |
| 1014 Future f = null; | 956 Future f = null; |
| 1015 Stream s;'''); | 957 Stream s;'''); |
| 1016 addNamedSource( | 958 addNamedSource("/lib.dart", r''' |
| 1017 "/lib.dart", | |
| 1018 r''' | |
| 1019 library lib; | 959 library lib; |
| 1020 class Future {}'''); | 960 class Future {}'''); |
| 1021 await computeAnalysisResult(source); | 961 await computeAnalysisResult(source); |
| 1022 assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]); | 962 assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]); |
| 1023 } | 963 } |
| 1024 | 964 |
| 1025 test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter() as
ync { | 965 test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter() as
ync { |
| 1026 Source source = addSource(r''' | 966 Source source = addSource(r''' |
| 1027 class A { | 967 class A { |
| 1028 static set v(x) {} | 968 static set v(x) {} |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 void f() { | 2480 void f() { |
| 2541 var a = new A(); | 2481 var a = new A(); |
| 2542 }'''); | 2482 }'''); |
| 2543 await computeAnalysisResult(source); | 2483 await computeAnalysisResult(source); |
| 2544 assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]); | 2484 assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]); |
| 2545 verify([source]); | 2485 verify([source]); |
| 2546 } | 2486 } |
| 2547 | 2487 |
| 2548 test_newWithNonType_fromLibrary() async { | 2488 test_newWithNonType_fromLibrary() async { |
| 2549 Source source1 = addNamedSource("/lib.dart", "class B {}"); | 2489 Source source1 = addNamedSource("/lib.dart", "class B {}"); |
| 2550 Source source2 = addNamedSource( | 2490 Source source2 = addNamedSource("/lib2.dart", r''' |
| 2551 "/lib2.dart", | |
| 2552 r''' | |
| 2553 import 'lib.dart' as lib; | 2491 import 'lib.dart' as lib; |
| 2554 void f() { | 2492 void f() { |
| 2555 var a = new lib.A(); | 2493 var a = new lib.A(); |
| 2556 } | 2494 } |
| 2557 lib.B b;'''); | 2495 lib.B b;'''); |
| 2558 await computeAnalysisResult(source1); | 2496 await computeAnalysisResult(source1); |
| 2559 await computeAnalysisResult(source2); | 2497 await computeAnalysisResult(source2); |
| 2560 assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]); | 2498 assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]); |
| 2561 verify([source1]); | 2499 verify([source1]); |
| 2562 } | 2500 } |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3609 } | 3547 } |
| 3610 | 3548 |
| 3611 test_undefinedClassBoolean_variableDeclaration() async { | 3549 test_undefinedClassBoolean_variableDeclaration() async { |
| 3612 Source source = addSource("f() { boolean v; }"); | 3550 Source source = addSource("f() { boolean v; }"); |
| 3613 await computeAnalysisResult(source); | 3551 await computeAnalysisResult(source); |
| 3614 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); | 3552 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); |
| 3615 } | 3553 } |
| 3616 | 3554 |
| 3617 test_undefinedGetter_fromLibrary() async { | 3555 test_undefinedGetter_fromLibrary() async { |
| 3618 Source source1 = addNamedSource("/lib.dart", ""); | 3556 Source source1 = addNamedSource("/lib.dart", ""); |
| 3619 Source source2 = addNamedSource( | 3557 Source source2 = addNamedSource("/lib2.dart", r''' |
| 3620 "/lib2.dart", | |
| 3621 r''' | |
| 3622 import 'lib.dart' as lib; | 3558 import 'lib.dart' as lib; |
| 3623 void f() { | 3559 void f() { |
| 3624 var g = lib.gg; | 3560 var g = lib.gg; |
| 3625 }'''); | 3561 }'''); |
| 3626 await computeAnalysisResult(source1); | 3562 await computeAnalysisResult(source1); |
| 3627 await computeAnalysisResult(source2); | 3563 await computeAnalysisResult(source2); |
| 3628 assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]); | 3564 assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]); |
| 3629 verify([source1]); | 3565 verify([source1]); |
| 3630 } | 3566 } |
| 3631 | 3567 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3662 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 3598 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 3663 } | 3599 } |
| 3664 | 3600 |
| 3665 test_undefinedIdentifier_methodInvocation() async { | 3601 test_undefinedIdentifier_methodInvocation() async { |
| 3666 Source source = addSource("f() { C.m(); }"); | 3602 Source source = addSource("f() { C.m(); }"); |
| 3667 await computeAnalysisResult(source); | 3603 await computeAnalysisResult(source); |
| 3668 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 3604 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 3669 } | 3605 } |
| 3670 | 3606 |
| 3671 test_undefinedIdentifier_private_getter() async { | 3607 test_undefinedIdentifier_private_getter() async { |
| 3672 addNamedSource( | 3608 addNamedSource("/lib.dart", r''' |
| 3673 "/lib.dart", | |
| 3674 r''' | |
| 3675 library lib; | 3609 library lib; |
| 3676 class A { | 3610 class A { |
| 3677 var _foo; | 3611 var _foo; |
| 3678 }'''); | 3612 }'''); |
| 3679 Source source = addSource(r''' | 3613 Source source = addSource(r''' |
| 3680 import 'lib.dart'; | 3614 import 'lib.dart'; |
| 3681 class B extends A { | 3615 class B extends A { |
| 3682 test() { | 3616 test() { |
| 3683 var v = _foo; | 3617 var v = _foo; |
| 3684 } | 3618 } |
| 3685 }'''); | 3619 }'''); |
| 3686 await computeAnalysisResult(source); | 3620 await computeAnalysisResult(source); |
| 3687 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 3621 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 3688 } | 3622 } |
| 3689 | 3623 |
| 3690 test_undefinedIdentifier_private_setter() async { | 3624 test_undefinedIdentifier_private_setter() async { |
| 3691 addNamedSource( | 3625 addNamedSource("/lib.dart", r''' |
| 3692 "/lib.dart", | |
| 3693 r''' | |
| 3694 library lib; | 3626 library lib; |
| 3695 class A { | 3627 class A { |
| 3696 var _foo; | 3628 var _foo; |
| 3697 }'''); | 3629 }'''); |
| 3698 Source source = addSource(r''' | 3630 Source source = addSource(r''' |
| 3699 import 'lib.dart'; | 3631 import 'lib.dart'; |
| 3700 class B extends A { | 3632 class B extends A { |
| 3701 test() { | 3633 test() { |
| 3702 _foo = 42; | 3634 _foo = 42; |
| 3703 } | 3635 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3718 main() { | 3650 main() { |
| 3719 f(c: 1); | 3651 f(c: 1); |
| 3720 }'''); | 3652 }'''); |
| 3721 await computeAnalysisResult(source); | 3653 await computeAnalysisResult(source); |
| 3722 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); | 3654 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); |
| 3723 // no verify(), 'c' is not resolved | 3655 // no verify(), 'c' is not resolved |
| 3724 } | 3656 } |
| 3725 | 3657 |
| 3726 test_undefinedSetter() async { | 3658 test_undefinedSetter() async { |
| 3727 addNamedSource("/lib.dart", ""); | 3659 addNamedSource("/lib.dart", ""); |
| 3728 Source source2 = addNamedSource( | 3660 Source source2 = addNamedSource("/lib2.dart", r''' |
| 3729 "/lib2.dart", | |
| 3730 r''' | |
| 3731 import 'lib.dart' as lib; | 3661 import 'lib.dart' as lib; |
| 3732 void f() { | 3662 void f() { |
| 3733 lib.gg = null; | 3663 lib.gg = null; |
| 3734 }'''); | 3664 }'''); |
| 3735 await computeAnalysisResult(source2); | 3665 await computeAnalysisResult(source2); |
| 3736 assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]); | 3666 assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]); |
| 3737 } | 3667 } |
| 3738 | 3668 |
| 3739 test_undefinedStaticMethodOrGetter_getter() async { | 3669 test_undefinedStaticMethodOrGetter_getter() async { |
| 3740 Source source = addSource(r''' | 3670 Source source = addSource(r''' |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3797 | 3727 |
| 3798 test_voidReturnForGetter() async { | 3728 test_voidReturnForGetter() async { |
| 3799 Source source = addSource(r''' | 3729 Source source = addSource(r''' |
| 3800 class S { | 3730 class S { |
| 3801 void get value {} | 3731 void get value {} |
| 3802 }'''); | 3732 }'''); |
| 3803 await computeAnalysisResult(source); | 3733 await computeAnalysisResult(source); |
| 3804 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); | 3734 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); |
| 3805 } | 3735 } |
| 3806 } | 3736 } |
| OLD | NEW |