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

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

Issue 2689303003: Implement type variables in mixin applications. (Closed)
Patch Set: Address comments. Created 3 years, 10 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 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:io' show 10 import 'dart:io' show
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return null; 337 return null;
338 } 338 }
339 339
340 void installDefaultSupertypes(List<SourceClassBuilder> builders) { 340 void installDefaultSupertypes(List<SourceClassBuilder> builders) {
341 Class objectClass = this.objectClass; 341 Class objectClass = this.objectClass;
342 for (SourceClassBuilder builder in builders) { 342 for (SourceClassBuilder builder in builders) {
343 Class cls = builder.target; 343 Class cls = builder.target;
344 if (cls != objectClass) { 344 if (cls != objectClass) {
345 cls.supertype ??= objectClass.asRawSupertype; 345 cls.supertype ??= objectClass.asRawSupertype;
346 } 346 }
347 if (builder.isMixinApplication) {
348 cls.mixedInType = builder.mixedInType.buildSupertype();
349 }
347 } 350 }
348 ticker.logMs("Installed Object as implicit superclass"); 351 ticker.logMs("Installed Object as implicit superclass");
349 } 352 }
350 353
351 void installDefaultConstructors(List<SourceClassBuilder> builders) { 354 void installDefaultConstructors(List<SourceClassBuilder> builders) {
352 Class objectClass = this.objectClass; 355 Class objectClass = this.objectClass;
353 for (SourceClassBuilder builder in builders) { 356 for (SourceClassBuilder builder in builders) {
354 if (builder.target != objectClass) { 357 if (builder.target != objectClass) {
355 installDefaultConstructor(builder); 358 installDefaultConstructor(builder);
356 } 359 }
357 } 360 }
358 ticker.logMs("Installed default constructors"); 361 ticker.logMs("Installed default constructors");
359 } 362 }
360 363
361 KernelClassBuilder get objectClassBuilder { 364 KernelClassBuilder get objectClassBuilder {
362 return loader.coreLibrary.exports["Object"]; 365 return loader.coreLibrary.exports["Object"];
363 } 366 }
364 367
365 Class get objectClass => objectClassBuilder.cls; 368 Class get objectClass => objectClassBuilder.cls;
366 369
367 /// If [builder] doesn't have a constructors, install the defaults. 370 /// If [builder] doesn't have a constructors, install the defaults.
368 void installDefaultConstructor(SourceClassBuilder builder) { 371 void installDefaultConstructor(SourceClassBuilder builder) {
369 if (!builder.constructors.isEmpty) return; 372 if (builder.isMixinApplication || builder.constructors.isNotEmpty) return;
370 /// Quotes below are from [Dart Programming Language Specification, 4th 373 /// Quotes below are from [Dart Programming Language Specification, 4th
371 /// Edition](http://www.ecma-international.org/publications/files/ECMA-ST/EC MA-408.pdf): 374 /// Edition](http://www.ecma-international.org/publications/files/ECMA-ST/EC MA-408.pdf):
372 if (builder is NamedMixinApplicationBuilder) { 375 if (builder is NamedMixinApplicationBuilder) {
373 /// >A mixin application of the form S with M; defines a class C with 376 /// >A mixin application of the form S with M; defines a class C with
374 /// >superclass S. 377 /// >superclass S.
375 /// >... 378 /// >...
376 379
377 /// >Let LM be the library in which M is declared. For each generative 380 /// >Let LM be the library in which M is declared. For each generative
378 /// >constructor named qi(Ti1 ai1, . . . , Tiki aiki), i in 1..n of S 381 /// >constructor named qi(Ti1 ai1, . . . , Tiki aiki), i in 1..n of S
379 /// >that is accessible to LM , C has an implicitly declared constructor 382 /// >that is accessible to LM , C has an implicitly declared constructor
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 superclass = superclass.superclass; 579 superclass = superclass.superclass;
577 } 580 }
578 for (Constructor constructor in superclass.constructors) { 581 for (Constructor constructor in superclass.constructors) {
579 if (constructor.name.name.isEmpty) { 582 if (constructor.name.name.isEmpty) {
580 return constructor.function.requiredParameterCount == 0 ? 583 return constructor.function.requiredParameterCount == 0 ?
581 constructor : null; 584 constructor : null;
582 } 585 }
583 } 586 }
584 return null; 587 return null;
585 } 588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698