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

Side by Side Diff: test/typecheck.dart

Issue 2465893002: Add strong mode type checking pass. (Closed)
Patch Set: Merge with master and remove visitBlockExpression Created 4 years, 1 month 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 | « test/baseline_type_propagation_test.dart ('k') | testcases/strong-mode/DeltaBlue.baseline.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 import 'package:kernel/kernel.dart';
5 import 'package:kernel/class_hierarchy.dart';
6 import 'package:kernel/core_types.dart';
7 import 'package:kernel/type_checker.dart';
8 import 'dart:io';
9
10 final String usage = '''
11 Usage: typecheck FILE.dill
12
13 Runs the strong mode type checker on the given program.
14 ''';
15
16 main(List<String> args) {
17 if (args.length != 1) {
18 print(usage);
19 exit(1);
20 }
21 var program = loadProgramFromBinary(args[0]);
22 var coreTypes = new CoreTypes(program);
23 var hierarchy = new ClassHierarchy(program);
24 new TestTypeChecker(coreTypes, hierarchy).checkProgram(program);
25 }
26
27 class TestTypeChecker extends TypeChecker {
28 TestTypeChecker(CoreTypes coreTypes, ClassHierarchy hierarchy)
29 : super(coreTypes, hierarchy);
30
31 @override
32 void checkAssignable(TreeNode where, DartType from, DartType to) {
33 if (!environment.isSubtypeOf(from, to)) {
34 fail(where, '$from is not a subtype of $to');
35 }
36 }
37
38 @override
39 void fail(TreeNode where, String message) {
40 Location location = where.location;
41 String locationString = location == null ? '' : '($location)';
42 print('[error] $message $locationString');
43 }
44 }
OLDNEW
« no previous file with comments | « test/baseline_type_propagation_test.dart ('k') | testcases/strong-mode/DeltaBlue.baseline.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698