Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: tests/compiler/dart2js/kernel/impact_test.dart

Issue 2574193003: Support generic methods in kernel (Closed)
Patch Set: Cleanup Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 dart2js.kernel.impact_test; 5 library dart2js.kernel.impact_test;
6 6
7 import 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import 'package:compiler/src/commandline_options.dart'; 8 import 'package:compiler/src/commandline_options.dart';
9 import 'package:compiler/src/common.dart'; 9 import 'package:compiler/src/common.dart';
10 import 'package:compiler/src/common/names.dart'; 10 import 'package:compiler/src/common/names.dart';
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 testGenericClass(); 161 testGenericClass();
162 testSuperCall(); 162 testSuperCall();
163 testSuperGet(); 163 testSuperGet();
164 testSuperFieldSet(); 164 testSuperFieldSet();
165 testSuperSetterSet(); 165 testSuperSetterSet();
166 testSuperClosurization(); 166 testSuperClosurization();
167 testForwardingConstructor(); 167 testForwardingConstructor();
168 testForwardingConstructorTyped(); 168 testForwardingConstructorTyped();
169 testForwardingConstructorGeneric(); 169 testForwardingConstructorGeneric();
170 testEnum(); 170 testEnum();
171 testStaticGenericMethod();
172 testInstanceGenericMethod();
171 } 173 }
172 174
173 testEmpty() {} 175 testEmpty() {}
174 testNull() => null; 176 testNull() => null;
175 testTrue() => true; 177 testTrue() => true;
176 testFalse() => false; 178 testFalse() => false;
177 testInt() => 42; 179 testInt() => 42;
178 testDouble() => 37.5; 180 testDouble() => 37.5;
179 testString() => 'foo'; 181 testString() => 'foo';
180 testStringInterpolation() => '${0}'; 182 testStringInterpolation() => '${0}';
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 ForwardingConstructorGenericSuperClass(T arg); 578 ForwardingConstructorGenericSuperClass(T arg);
577 } 579 }
578 class ForwardingConstructorGenericClass<S> = 580 class ForwardingConstructorGenericClass<S> =
579 ForwardingConstructorGenericSuperClass<S> with EmptyMixin; 581 ForwardingConstructorGenericSuperClass<S> with EmptyMixin;
580 testForwardingConstructorGeneric() { 582 testForwardingConstructorGeneric() {
581 new ForwardingConstructorGenericClass<int>(null); 583 new ForwardingConstructorGenericClass<int>(null);
582 } 584 }
583 585
584 enum Enum { A } 586 enum Enum { A }
585 testEnum() => Enum.A; 587 testEnum() => Enum.A;
588
589 List<T> staticGenericMethod<T>(T arg) => [arg];
590 testStaticGenericMethod() {
591 staticGenericMethod<int>(0);
592 }
593
594 testInstanceGenericMethod() {
595 new GenericClass<int, String>.generative().genericMethod<bool>(false);
596 }
586 ''', 597 ''',
587 'helper.dart': ''' 598 'helper.dart': '''
588 class Class { 599 class Class {
589 const Class.generative(); 600 const Class.generative();
590 factory Class.fact() => null; 601 factory Class.fact() => null;
591 const factory Class.redirect() = Class.generative; 602 const factory Class.redirect() = Class.generative;
592 } 603 }
593 class GenericClass<X, Y> { 604 class GenericClass<X, Y> {
594 const GenericClass.generative(); 605 const GenericClass.generative();
595 factory GenericClass.fact() => null; 606 factory GenericClass.fact() => null;
596 const factory GenericClass.redirect() = GenericClass<X, Y>.generative; 607 const factory GenericClass.redirect() = GenericClass<X, Y>.generative;
608
609 Map<X, T> genericMethod<T>(T arg) => { null: arg };
597 } 610 }
598 typedef Typedef(); 611 typedef Typedef();
599 typedef X GenericTypedef<X, Y>(Y y); 612 typedef X GenericTypedef<X, Y>(Y y);
600 ''', 613 ''',
601 }; 614 };
602 615
603 main(List<String> args) { 616 main(List<String> args) {
604 asyncTest(() async { 617 asyncTest(() async {
605 enableDebugMode(); 618 enableDebugMode();
606 Uri entryPoint = Uri.parse('memory:main.dart'); 619 Uri entryPoint = Uri.parse('memory:main.dart');
607 Compiler compiler = compilerFor( 620 Compiler compiler = compilerFor(
608 entryPoint: entryPoint, 621 entryPoint: entryPoint,
609 memorySourceFiles: SOURCE, 622 memorySourceFiles: SOURCE,
610 options: [ 623 options: [
611 Flags.analyzeAll, 624 Flags.analyzeAll,
612 Flags.useKernel, 625 Flags.useKernel,
613 Flags.enableAssertMessage 626 Flags.enableAssertMessage
614 ]); 627 ]);
615 compiler.resolution.retainCachesForTesting = true; 628 compiler.resolution.retainCachesForTesting = true;
616 await compiler.run(entryPoint); 629 await compiler.run(entryPoint);
630 checkLibrary(compiler, compiler.mainApp, fullTest: args.contains('--full'));
617 compiler.libraryLoader.libraries.forEach((LibraryElement library) { 631 compiler.libraryLoader.libraries.forEach((LibraryElement library) {
632 if (library == compiler.mainApp) return;
618 checkLibrary(compiler, library, fullTest: args.contains('--full')); 633 checkLibrary(compiler, library, fullTest: args.contains('--full'));
619 }); 634 });
620 }); 635 });
621 } 636 }
622 637
623 void checkLibrary(Compiler compiler, LibraryElement library, 638 void checkLibrary(Compiler compiler, LibraryElement library,
624 {bool fullTest: false}) { 639 {bool fullTest: false}) {
625 library.forEachLocalMember((AstElement element) { 640 library.forEachLocalMember((AstElement element) {
626 if (element.isClass) { 641 if (element.isClass) {
627 ClassElement cls = element; 642 ClassElement cls = element;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 visitList(type.optionalParameterTypes), 821 visitList(type.optionalParameterTypes),
807 type.namedParameters, 822 type.namedParameters,
808 visitList(type.namedParameterTypes)); 823 visitList(type.namedParameterTypes));
809 } 824 }
810 } 825 }
811 826
812 /// Perform unaliasing of all typedefs nested within a [DartType]. 827 /// Perform unaliasing of all typedefs nested within a [DartType].
813 DartType unalias(DartType type) { 828 DartType unalias(DartType type) {
814 return const Unaliaser().visit(type); 829 return const Unaliaser().visit(type);
815 } 830 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698