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

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

Issue 2729943003: Recover from bad supertypes. (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.kernel_target; 5 library fasta.kernel_target;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show File, IOSink; 9 import 'dart:io' show File, IOSink;
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return new KernelLibraryBuilder(uri, fileUri, loader); 125 return new KernelLibraryBuilder(uri, fileUri, loader);
126 } 126 }
127 127
128 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set) { 128 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set) {
129 if (cls == null) return; 129 if (cls == null) return;
130 TypeBuilder supertype = cls.supertype; 130 TypeBuilder supertype = cls.supertype;
131 add(NamedTypeBuilder type) { 131 add(NamedTypeBuilder type) {
132 Builder builder = type.builder; 132 Builder builder = type.builder;
133 if (builder is ClassBuilder) { 133 if (builder is ClassBuilder) {
134 set.add(builder); 134 set.add(builder);
135 } else if (builder is! InvalidTypeBuilder &&
136 builder is! DynamicTypeBuilder) {
137 internalError("Unhandled: ${builder.runtimeType}");
138 } 135 }
139 } 136 }
140 137
141 if (supertype == null) { 138 if (supertype == null) {
142 // OK. 139 // OK.
143 } else if (supertype is MixinApplicationBuilder) { 140 } else if (supertype is MixinApplicationBuilder) {
144 add(supertype.supertype); 141 add(supertype.supertype);
145 for (NamedTypeBuilder t in supertype.mixins) { 142 for (NamedTypeBuilder t in supertype.mixins) {
146 add(t); 143 add(t);
147 } 144 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Future<Program> writeOutline(Uri uri) async { 237 Future<Program> writeOutline(Uri uri) async {
241 if (loader.first == null) return null; 238 if (loader.first == null) return null;
242 try { 239 try {
243 await loader.buildOutlines(); 240 await loader.buildOutlines();
244 loader.resolveParts(); 241 loader.resolveParts();
245 loader.computeLibraryScopes(); 242 loader.computeLibraryScopes();
246 loader.resolveTypes(); 243 loader.resolveTypes();
247 loader.buildProgram(); 244 loader.buildProgram();
248 loader.checkSemantics(); 245 loader.checkSemantics();
249 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses(); 246 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses();
250 installDefaultSupertypes(sourceClasses); 247 installDefaultSupertypes();
251 installDefaultConstructors(sourceClasses); 248 installDefaultConstructors(sourceClasses);
252 loader.resolveConstructors(); 249 loader.resolveConstructors();
253 loader.finishTypeVariables(objectClassBuilder); 250 loader.finishTypeVariables(objectClassBuilder);
254 program = link(new List<Library>.from(loader.libraries)); 251 program = link(new List<Library>.from(loader.libraries));
255 if (uri == null) return program; 252 if (uri == null) return program;
256 return await writeLinkedProgram(uri, program, isFullProgram: false); 253 return await writeLinkedProgram(uri, program, isFullProgram: false);
257 } on InputError catch (e) { 254 } on InputError catch (e) {
258 return handleInputError(uri, e, isFullProgram: false); 255 return handleInputError(uri, e, isFullProgram: false);
259 } catch (e, s) { 256 } catch (e, s) {
260 return reportCrash(e, s, loader?.currentUriForCrashReporting); 257 return reportCrash(e, s, loader?.currentUriForCrashReporting);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 await sink.close(); 343 await sink.close();
347 } 344 }
348 if (isFullProgram) { 345 if (isFullProgram) {
349 ticker.logMs("Wrote program to ${uri.toFilePath()}"); 346 ticker.logMs("Wrote program to ${uri.toFilePath()}");
350 } else { 347 } else {
351 ticker.logMs("Wrote outline to ${uri.toFilePath()}"); 348 ticker.logMs("Wrote outline to ${uri.toFilePath()}");
352 } 349 }
353 return null; 350 return null;
354 } 351 }
355 352
356 void installDefaultSupertypes(List<SourceClassBuilder> builders) { 353 void installDefaultSupertypes() {
357 Class objectClass = this.objectClass; 354 Class objectClass = this.objectClass;
358 for (SourceClassBuilder builder in builders) { 355 loader.builders.forEach((Uri uri, LibraryBuilder library) {
Johnni Winther 2017/03/03 13:43:08 Why this change? Was the output of [collectAllSour
359 Class cls = builder.target; 356 library.members.forEach((String name, Builder builder) {
360 if (cls != objectClass) { 357 if (builder is SourceClassBuilder) {
361 cls.supertype ??= objectClass.asRawSupertype; 358 Class cls = builder.target;
362 } 359 if (cls != objectClass) {
363 if (builder.isMixinApplication) { 360 cls.supertype ??= objectClass.asRawSupertype;
364 cls.mixedInType = builder.mixedInType.buildSupertype(); 361 }
365 } 362 if (builder.isMixinApplication) {
366 } 363 cls.mixedInType = builder.mixedInType.buildSupertype(library);
ahe 2017/03/03 13:52:52 I need access to the library here.
364 }
365 }
366 });
367 });
367 ticker.logMs("Installed Object as implicit superclass"); 368 ticker.logMs("Installed Object as implicit superclass");
368 } 369 }
369 370
370 void installDefaultConstructors(List<SourceClassBuilder> builders) { 371 void installDefaultConstructors(List<SourceClassBuilder> builders) {
371 Class objectClass = this.objectClass; 372 Class objectClass = this.objectClass;
372 for (SourceClassBuilder builder in builders) { 373 for (SourceClassBuilder builder in builders) {
373 if (builder.target != objectClass) { 374 if (builder.target != objectClass) {
374 installDefaultConstructor(builder); 375 installDefaultConstructor(builder);
375 } 376 }
376 } 377 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 604 }
604 for (Constructor constructor in superclass.constructors) { 605 for (Constructor constructor in superclass.constructors) {
605 if (constructor.name.name.isEmpty) { 606 if (constructor.name.name.isEmpty) {
606 return constructor.function.requiredParameterCount == 0 607 return constructor.function.requiredParameterCount == 0
607 ? constructor 608 ? constructor
608 : null; 609 : null;
609 } 610 }
610 } 611 }
611 return null; 612 return null;
612 } 613 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698