| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 | 7 |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import 'package:compiler/src/constants/expressions.dart'; | 10 import 'package:compiler/src/constants/expressions.dart'; |
| 11 import 'package:compiler/src/dart_types.dart'; | 11 import 'package:compiler/src/dart_types.dart'; |
| 12 import 'package:compiler/src/elements/modelx.dart'; | 12 import 'package:compiler/src/elements/modelx.dart'; |
| 13 import 'package:compiler/src/resolution/constructors.dart'; | 13 import 'package:compiler/src/resolution/constructors.dart'; |
| 14 import 'package:compiler/src/resolution/members.dart'; | 14 import 'package:compiler/src/resolution/members.dart'; |
| 15 import 'package:compiler/src/resolution/registry.dart'; | 15 import 'package:compiler/src/resolution/registry.dart'; |
| 16 import 'package:compiler/src/resolution/resolution_result.dart'; | 16 import 'package:compiler/src/resolution/resolution_result.dart'; |
| 17 import 'package:compiler/src/resolution/scope.dart'; | 17 import 'package:compiler/src/resolution/scope.dart'; |
| 18 import 'package:compiler/src/resolution/tree_elements.dart'; | 18 import 'package:compiler/src/resolution/tree_elements.dart'; |
| 19 import 'package:compiler/src/universe/use.dart'; |
| 20 import 'package:compiler/src/universe/world_impact.dart'; |
| 19 | 21 |
| 20 import 'compiler_helper.dart'; | 22 import 'compiler_helper.dart'; |
| 21 import 'link_helper.dart'; | 23 import 'link_helper.dart'; |
| 22 import 'parser_helper.dart'; | 24 import 'parser_helper.dart'; |
| 23 | 25 |
| 24 Node buildIdentifier(String name) => new Identifier(scan(name)); | 26 Node buildIdentifier(String name) => new Identifier(scan(name)); |
| 25 | 27 |
| 26 Node buildInitialization(String name) => parseBodyCode('$name = 1', | 28 Node buildInitialization(String name) => parseBodyCode('$name = 1', |
| 27 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); | 29 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); |
| 28 | 30 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 }); | 236 }); |
| 235 } | 237 } |
| 236 | 238 |
| 237 Future testSwitch() { | 239 Future testSwitch() { |
| 238 return MockCompiler.create((MockCompiler compiler) { | 240 return MockCompiler.create((MockCompiler compiler) { |
| 239 compiler.parseScript("class Foo { foo() {" | 241 compiler.parseScript("class Foo { foo() {" |
| 240 "switch (null) { case '': break; case 2: break; } } }"); | 242 "switch (null) { case '': break; case 2: break; } } }"); |
| 241 compiler.resolveStatement("Foo foo;"); | 243 compiler.resolveStatement("Foo foo;"); |
| 242 ClassElement fooElement = compiler.mainApp.find("Foo"); | 244 ClassElement fooElement = compiler.mainApp.find("Foo"); |
| 243 FunctionElement funElement = fooElement.lookupLocalMember("foo"); | 245 FunctionElement funElement = fooElement.lookupLocalMember("foo"); |
| 244 compiler.enqueuer.resolution.addToWorkList(funElement); | 246 compiler.enqueuer.resolution.applyImpact(new WorldImpactBuilderImpl() |
| 247 ..registerStaticUse(new StaticUse.foreignUse(funElement))); |
| 245 compiler.processQueue(compiler.enqueuer.resolution, null); | 248 compiler.processQueue(compiler.enqueuer.resolution, null); |
| 246 DiagnosticCollector collector = compiler.diagnosticCollector; | 249 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 247 Expect.equals(0, collector.warnings.length); | 250 Expect.equals(0, collector.warnings.length); |
| 248 Expect.equals(1, collector.errors.length); | 251 Expect.equals(1, collector.errors.length); |
| 249 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL, | 252 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL, |
| 250 collector.errors.first.message.kind); | 253 collector.errors.first.message.kind); |
| 251 Expect.equals(2, collector.infos.length); | 254 Expect.equals(2, collector.infos.length); |
| 252 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, | 255 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, |
| 253 collector.infos.first.message.kind); | 256 collector.infos.first.message.kind); |
| 254 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, | 257 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 functionName: 'm'); | 1534 functionName: 'm'); |
| 1532 check( | 1535 check( |
| 1533 ''' | 1536 ''' |
| 1534 class A { | 1537 class A { |
| 1535 m() => () => await - 3; | 1538 m() => () => await - 3; |
| 1536 } | 1539 } |
| 1537 main() => new A().m(); | 1540 main() => new A().m(); |
| 1538 ''', | 1541 ''', |
| 1539 className: 'A'); | 1542 className: 'A'); |
| 1540 } | 1543 } |
| OLD | NEW |