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

Side by Side Diff: pkg/kernel/test/typecheck.dart

Issue 2930973002: Remove ClassHierarchy factory constructor. (Closed)
Patch Set: Created 3 years, 6 months 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/kernel/test/type_subtype_test.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 import 'package:kernel/kernel.dart'; 4 import 'package:kernel/kernel.dart';
5 import 'package:kernel/class_hierarchy.dart'; 5 import 'package:kernel/class_hierarchy.dart';
6 import 'package:kernel/core_types.dart'; 6 import 'package:kernel/core_types.dart';
7 import 'package:kernel/src/incremental_class_hierarchy.dart';
7 import 'package:kernel/type_checker.dart'; 8 import 'package:kernel/type_checker.dart';
8 import 'dart:io'; 9 import 'dart:io';
9 10
10 final String usage = ''' 11 final String usage = '''
11 Usage: typecheck FILE.dill 12 Usage: typecheck FILE.dill
12 13
13 Runs the strong mode type checker on the given program. 14 Runs the strong mode type checker on the given program.
14 '''; 15 ''';
15 16
16 main(List<String> args) { 17 main(List<String> args) {
17 if (args.length != 1) { 18 if (args.length != 1) {
18 print(usage); 19 print(usage);
19 exit(1); 20 exit(1);
20 } 21 }
21 var program = loadProgramFromBinary(args[0]); 22 var program = loadProgramFromBinary(args[0]);
22 var coreTypes = new CoreTypes(program); 23 var coreTypes = new CoreTypes(program);
23 var hierarchy = new ClassHierarchy(program); 24 var hierarchy = new IncrementalClassHierarchy();
24 new TestTypeChecker(coreTypes, hierarchy).checkProgram(program); 25 new TestTypeChecker(coreTypes, hierarchy).checkProgram(program);
25 } 26 }
26 27
27 class TestTypeChecker extends TypeChecker { 28 class TestTypeChecker extends TypeChecker {
28 TestTypeChecker(CoreTypes coreTypes, ClassHierarchy hierarchy) 29 TestTypeChecker(CoreTypes coreTypes, ClassHierarchy hierarchy)
29 : super(coreTypes, hierarchy); 30 : super(coreTypes, hierarchy);
30 31
31 @override 32 @override
32 void checkAssignable(TreeNode where, DartType from, DartType to) { 33 void checkAssignable(TreeNode where, DartType from, DartType to) {
33 if (!environment.isSubtypeOf(from, to)) { 34 if (!environment.isSubtypeOf(from, to)) {
34 fail(where, '$from is not a subtype of $to'); 35 fail(where, '$from is not a subtype of $to');
35 } 36 }
36 } 37 }
37 38
38 @override 39 @override
39 void fail(TreeNode where, String message) { 40 void fail(TreeNode where, String message) {
40 Location location = where.location; 41 Location location = where.location;
41 String locationString = location == null ? '' : '($location)'; 42 String locationString = location == null ? '' : '($location)';
42 print('[error] $message $locationString'); 43 print('[error] $message $locationString');
43 } 44 }
44 } 45 }
OLDNEW
« no previous file with comments | « pkg/kernel/test/type_subtype_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698