| 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'; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind); | 140 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind); |
| 141 Expect.equals(0, collector.crashes.length); | 141 Expect.equals(0, collector.crashes.length); |
| 142 }), | 142 }), |
| 143 ]); | 143 ]); |
| 144 } | 144 } |
| 145 | 145 |
| 146 Future testTypeVariables() { | 146 Future testTypeVariables() { |
| 147 matchResolvedTypes(visitor, text, name, expectedElements) { | 147 matchResolvedTypes(visitor, text, name, expectedElements) { |
| 148 VariableDefinitions definition = parseStatement(text); | 148 VariableDefinitions definition = parseStatement(text); |
| 149 visitor.visit(definition.type); | 149 visitor.visit(definition.type); |
| 150 InterfaceType type = visitor.registry.mapping.getType(definition.type); | 150 ResolutionInterfaceType type = |
| 151 visitor.registry.mapping.getType(definition.type); |
| 151 Expect.equals( | 152 Expect.equals( |
| 152 definition.type.typeArguments.slowLength(), type.typeArguments.length); | 153 definition.type.typeArguments.slowLength(), type.typeArguments.length); |
| 153 int index = 0; | 154 int index = 0; |
| 154 for (DartType argument in type.typeArguments) { | 155 for (ResolutionDartType argument in type.typeArguments) { |
| 155 Expect.equals(true, index < expectedElements.length); | 156 Expect.equals(true, index < expectedElements.length); |
| 156 Expect.equals(expectedElements[index], argument.element); | 157 Expect.equals(expectedElements[index], argument.element); |
| 157 index++; | 158 index++; |
| 158 } | 159 } |
| 159 Expect.equals(index, expectedElements.length); | 160 Expect.equals(index, expectedElements.length); |
| 160 } | 161 } |
| 161 | 162 |
| 162 return Future.wait([ | 163 return Future.wait([ |
| 163 MockCompiler.create((MockCompiler compiler) { | 164 MockCompiler.create((MockCompiler compiler) { |
| 164 ResolverVisitor visitor = compiler.resolverVisitor(); | 165 ResolverVisitor visitor = compiler.resolverVisitor(); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 compiler.parseScript("""class A extends B {} | 797 compiler.parseScript("""class A extends B {} |
| 797 class B extends C {} | 798 class B extends C {} |
| 798 class C {} | 799 class C {} |
| 799 main() { return new A(); }"""); | 800 main() { return new A(); }"""); |
| 800 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 801 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 801 compiler.resolver.resolve(mainElement); | 802 compiler.resolver.resolve(mainElement); |
| 802 DiagnosticCollector collector = compiler.diagnosticCollector; | 803 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 803 Expect.equals(0, collector.warnings.length); | 804 Expect.equals(0, collector.warnings.length); |
| 804 Expect.equals(0, collector.errors.length); | 805 Expect.equals(0, collector.errors.length); |
| 805 ClassElement aElement = compiler.mainApp.find("A"); | 806 ClassElement aElement = compiler.mainApp.find("A"); |
| 806 Link<DartType> supertypes = aElement.allSupertypes; | 807 Link<ResolutionDartType> supertypes = aElement.allSupertypes; |
| 807 Expect.equals(<String>['B', 'C', 'Object'].toString(), | 808 Expect.equals(<String>['B', 'C', 'Object'].toString(), |
| 808 asSortedStrings(supertypes).toString()); | 809 asSortedStrings(supertypes).toString()); |
| 809 }), | 810 }), |
| 810 MockCompiler.create((MockCompiler compiler) { | 811 MockCompiler.create((MockCompiler compiler) { |
| 811 compiler.parseScript("""class A<T> {} | 812 compiler.parseScript("""class A<T> {} |
| 812 class B<Z,W> extends A<int> | 813 class B<Z,W> extends A<int> |
| 813 implements I<Z,List<W>> {} | 814 implements I<Z,List<W>> {} |
| 814 class I<X,Y> {} | 815 class I<X,Y> {} |
| 815 class C extends B<bool,String> {} | 816 class C extends B<bool,String> {} |
| 816 main() { return new C(); }"""); | 817 main() { return new C(); }"""); |
| 817 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 818 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 818 compiler.resolver.resolve(mainElement); | 819 compiler.resolver.resolve(mainElement); |
| 819 DiagnosticCollector collector = compiler.diagnosticCollector; | 820 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 820 Expect.equals(0, collector.warnings.length); | 821 Expect.equals(0, collector.warnings.length); |
| 821 Expect.equals(0, collector.errors.length); | 822 Expect.equals(0, collector.errors.length); |
| 822 ClassElement aElement = compiler.mainApp.find("C"); | 823 ClassElement aElement = compiler.mainApp.find("C"); |
| 823 Link<DartType> supertypes = aElement.allSupertypes; | 824 Link<ResolutionDartType> supertypes = aElement.allSupertypes; |
| 824 // Object is once per inheritance path, that is from both A and I. | 825 // Object is once per inheritance path, that is from both A and I. |
| 825 Expect.equals( | 826 Expect.equals( |
| 826 <String>[ | 827 <String>[ |
| 827 'A<int>', | 828 'A<int>', |
| 828 'B<bool, String>', | 829 'B<bool, String>', |
| 829 'I<bool, List<String>>', | 830 'I<bool, List<String>>', |
| 830 'Object' | 831 'Object' |
| 831 ].toString(), | 832 ].toString(), |
| 832 asSortedStrings(supertypes).toString()); | 833 asSortedStrings(supertypes).toString()); |
| 833 }), | 834 }), |
| 834 MockCompiler.create((MockCompiler compiler) { | 835 MockCompiler.create((MockCompiler compiler) { |
| 835 compiler.parseScript("""class A<T> {} | 836 compiler.parseScript("""class A<T> {} |
| 836 class D extends A<E> {} | 837 class D extends A<E> {} |
| 837 class E extends D {} | 838 class E extends D {} |
| 838 main() { return new E(); }"""); | 839 main() { return new E(); }"""); |
| 839 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 840 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 840 compiler.resolver.resolve(mainElement); | 841 compiler.resolver.resolve(mainElement); |
| 841 DiagnosticCollector collector = compiler.diagnosticCollector; | 842 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 842 Expect.equals(0, collector.warnings.length); | 843 Expect.equals(0, collector.warnings.length); |
| 843 Expect.equals(0, collector.errors.length); | 844 Expect.equals(0, collector.errors.length); |
| 844 ClassElement aElement = compiler.mainApp.find("E"); | 845 ClassElement aElement = compiler.mainApp.find("E"); |
| 845 Link<DartType> supertypes = aElement.allSupertypes; | 846 Link<ResolutionDartType> supertypes = aElement.allSupertypes; |
| 846 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(), | 847 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(), |
| 847 asSortedStrings(supertypes).toString()); | 848 asSortedStrings(supertypes).toString()); |
| 848 }), | 849 }), |
| 849 MockCompiler.create((MockCompiler compiler) { | 850 MockCompiler.create((MockCompiler compiler) { |
| 850 compiler.parseScript("""class A<T> {} | 851 compiler.parseScript("""class A<T> {} |
| 851 class D extends A<int> implements A<double> {} | 852 class D extends A<int> implements A<double> {} |
| 852 main() { return new D(); }"""); | 853 main() { return new D(); }"""); |
| 853 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 854 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 854 compiler.resolver.resolve(mainElement); | 855 compiler.resolver.resolve(mainElement); |
| 855 DiagnosticCollector collector = compiler.diagnosticCollector; | 856 DiagnosticCollector collector = compiler.diagnosticCollector; |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 functionName: 'm'); | 1537 functionName: 'm'); |
| 1537 check( | 1538 check( |
| 1538 ''' | 1539 ''' |
| 1539 class A { | 1540 class A { |
| 1540 m() => () => await - 3; | 1541 m() => () => await - 3; |
| 1541 } | 1542 } |
| 1542 main() => new A().m(); | 1543 main() => new A().m(); |
| 1543 ''', | 1544 ''', |
| 1544 className: 'A'); | 1545 className: 'A'); |
| 1545 } | 1546 } |
| OLD | NEW |