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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/verifier.dart

Issue 2843333005: Extend pkg/front_end/lib/src/fasta/kernel/verifier.dart to check for UnknownType. (Closed)
Patch Set: Created 3 years, 7 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/front_end/front_end.iml ('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 fasta.verifier; 5 library fasta.verifier;
6 6
7 import 'package:front_end/src/fasta/type_inference/type_schema.dart'
8 show TypeSchemaVisitor, UnknownType;
9
7 import 'package:kernel/ast.dart' 10 import 'package:kernel/ast.dart'
8 show 11 show
9 InvalidExpression, 12 InvalidExpression,
10 InvalidStatement, 13 InvalidStatement,
11 InvalidInitializer, 14 InvalidInitializer,
12 Class, 15 Class,
13 ExpressionStatement, 16 ExpressionStatement,
14 Field, 17 Field,
15 Library, 18 Library,
16 Procedure, 19 Procedure,
17 Program, 20 Program,
18 TreeNode; 21 TreeNode;
19 22
20 import 'package:kernel/verifier.dart' show VerificationError, VerifyingVisitor; 23 import 'package:kernel/verifier.dart' show VerificationError, VerifyingVisitor;
21 24
22 import '../errors.dart' show printUnexpected; 25 import '../errors.dart' show printUnexpected;
23 26
24 import 'redirecting_factory_body.dart' show RedirectingFactoryBody; 27 import 'redirecting_factory_body.dart' show RedirectingFactoryBody;
25 28
26 List<VerificationError> verifyProgram(Program program, 29 List<VerificationError> verifyProgram(Program program,
27 {bool isOutline: false}) { 30 {bool isOutline: false}) {
28 FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline); 31 FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline);
29 program.accept(verifier); 32 program.accept(verifier);
30 return verifier.errors; 33 return verifier.errors;
31 } 34 }
32 35
33 class FastaVerifyingVisitor extends VerifyingVisitor { 36 class FastaVerifyingVisitor extends VerifyingVisitor
37 implements TypeSchemaVisitor {
34 final List<VerificationError> errors = <VerificationError>[]; 38 final List<VerificationError> errors = <VerificationError>[];
35 39
36 String fileUri; 40 String fileUri;
37 41
38 FastaVerifyingVisitor(bool isOutline) { 42 FastaVerifyingVisitor(bool isOutline) {
39 this.isOutline = isOutline; 43 this.isOutline = isOutline;
40 } 44 }
41 45
42 @override 46 @override
43 problem(TreeNode node, String details) { 47 problem(TreeNode node, String details) {
44 VerificationError error = new VerificationError(context, node, details); 48 VerificationError error = new VerificationError(context, node, details);
45 printUnexpected(Uri.parse(fileUri), node.fileOffset, "$error"); 49 printUnexpected(Uri.parse(fileUri), node?.fileOffset ?? 0, "$error");
ahe 2017/04/27 16:38:20 -1.
Paul Berry 2017/04/27 16:43:51 Done.
46 errors.add(error); 50 errors.add(error);
47 } 51 }
48 52
49 @override 53 @override
50 visitExpressionStatement(ExpressionStatement node) { 54 visitExpressionStatement(ExpressionStatement node) {
51 // Bypass verification of the [StaticGet] in [RedirectingFactoryBody] as 55 // Bypass verification of the [StaticGet] in [RedirectingFactoryBody] as
52 // this is a static get without a getter. 56 // this is a static get without a getter.
53 if (node is! RedirectingFactoryBody) { 57 if (node is! RedirectingFactoryBody) {
54 super.visitExpressionStatement(node); 58 super.visitExpressionStatement(node);
55 } 59 }
(...skipping 30 matching lines...) Expand all
86 90
87 @override 91 @override
88 visitInvalidStatement(InvalidStatement node) { 92 visitInvalidStatement(InvalidStatement node) {
89 problem(node, "Invalid statement."); 93 problem(node, "Invalid statement.");
90 } 94 }
91 95
92 @override 96 @override
93 visitInvalidInitializer(InvalidInitializer node) { 97 visitInvalidInitializer(InvalidInitializer node) {
94 problem(node, "Invalid initializer."); 98 problem(node, "Invalid initializer.");
95 } 99 }
100
101 @override
102 visitUnknownType(UnknownType node) {
103 // Note: we can't pass [node] to [problem] because it's not a [TreeNode].
104 problem(null, "Unexpected appearance of the unknown type.");
105 }
96 } 106 }
OLDNEW
« no previous file with comments | « pkg/front_end/front_end.iml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698