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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/source_loader.dart

Issue 2767633004: Report compile-time errors on cyclic hierarchies. (Closed)
Patch Set: Created 3 years, 9 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
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.source_loader; 5 library fasta.source_loader;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show FileSystemException; 9 import 'dart:io' show FileSystemException;
10 10
11 import 'dart:typed_data' show Uint8List; 11 import 'dart:typed_data' show Uint8List;
12 12
13 import 'package:kernel/ast.dart' show Program; 13 import 'package:kernel/ast.dart' show Program;
14 14
15 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; 15 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
16 16
17 import 'package:kernel/core_types.dart' show CoreTypes; 17 import 'package:kernel/core_types.dart' show CoreTypes;
18 18
19 import '../builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; 19 import '../builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder;
20 20
21 import '../compiler_context.dart' show CompilerContext; 21 import '../compiler_context.dart' show CompilerContext;
22 22
23 import '../errors.dart' show inputError; 23 import '../errors.dart' show inputError;
24 24
25 import '../export.dart' show Export; 25 import '../export.dart' show Export;
26 26
27 import '../loader.dart' show Loader; 27 import '../loader.dart' show Loader;
28 28
29 import '../messages.dart' show warning;
30
31 import '../parser/class_member_parser.dart' show ClassMemberParser; 29 import '../parser/class_member_parser.dart' show ClassMemberParser;
32 30
33 import '../scanner.dart' show ErrorToken, ScannerResult, Token, scan; 31 import '../scanner.dart' show ErrorToken, ScannerResult, Token, scan;
34 32
35 import '../scanner/io.dart' show readBytesFromFile; 33 import '../scanner/io.dart' show readBytesFromFile;
36 34
37 import '../target_implementation.dart' show TargetImplementation; 35 import '../target_implementation.dart' show TargetImplementation;
38 36
39 import 'diet_listener.dart' show DietListener; 37 import 'diet_listener.dart' show DietListener;
40 38
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 realCycles.forEach((ClassBuilder cls, Set<ClassBuilder> cycles) { 327 realCycles.forEach((ClassBuilder cls, Set<ClassBuilder> cycles) {
330 target.breakCycle(cls); 328 target.breakCycle(cls);
331 if (reported.add(cls)) { 329 if (reported.add(cls)) {
332 List<ClassBuilder> involved = <ClassBuilder>[]; 330 List<ClassBuilder> involved = <ClassBuilder>[];
333 for (ClassBuilder cls in cycles) { 331 for (ClassBuilder cls in cycles) {
334 if (realCycles.containsKey(cls)) { 332 if (realCycles.containsKey(cls)) {
335 involved.add(cls); 333 involved.add(cls);
336 reported.add(cls); 334 reported.add(cls);
337 } 335 }
338 } 336 }
339 warning( 337 cls.addCompileTimeError(
340 cls.fileUri,
341 cls.charOffset, 338 cls.charOffset,
342 "'${cls.name}' is a supertype of " 339 "'${cls.name}' is a supertype of "
343 "itself via '${involved.map((c) => c.name).join(' ')}'."); 340 "itself via '${involved.map((c) => c.name).join(' ')}'.");
344 } 341 }
345 }); 342 });
346 ticker.logMs("Found cycles"); 343 ticker.logMs("Found cycles");
347 } 344 }
348 345
349 void buildProgram() { 346 void buildProgram() {
350 builders.forEach((Uri uri, LibraryBuilder library) { 347 builders.forEach((Uri uri, LibraryBuilder library) {
(...skipping 14 matching lines...) Expand all
365 void checkOverrides(List<SourceClassBuilder> sourceClasses) { 362 void checkOverrides(List<SourceClassBuilder> sourceClasses) {
366 assert(hierarchy != null); 363 assert(hierarchy != null);
367 for (SourceClassBuilder builder in sourceClasses) { 364 for (SourceClassBuilder builder in sourceClasses) {
368 builder.checkOverrides(hierarchy); 365 builder.checkOverrides(hierarchy);
369 } 366 }
370 ticker.logMs("Checked overrides"); 367 ticker.logMs("Checked overrides");
371 } 368 }
372 369
373 List<Uri> getDependencies() => sourceBytes.keys.toList(); 370 List<Uri> getDependencies() => sourceBytes.keys.toList();
374 } 371 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698