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

Side by Side Diff: pkg/compiler/lib/src/deferred_load.dart

Issue 3000843002: Add dependencies to type variables used in the super type declaration, but do (Closed)
Patch Set: Created 3 years, 4 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 | « no previous file | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 deferred_load; 5 library deferred_load;
6 6
7 import 'common/tasks.dart' show CompilerTask; 7 import 'common/tasks.dart' show CompilerTask;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compiler.dart' show Compiler; 9 import 'compiler.dart' show Compiler;
10 import 'constants/expressions.dart' show ConstantExpression; 10 import 'constants/expressions.dart' show ConstantExpression;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 collectTypeDependencies(argumentType); 312 collectTypeDependencies(argumentType);
313 } 313 }
314 for (ResolutionDartType argumentType in type.namedParameterTypes) { 314 for (ResolutionDartType argumentType in type.namedParameterTypes) {
315 collectTypeDependencies(argumentType); 315 collectTypeDependencies(argumentType);
316 } 316 }
317 collectTypeDependencies(type.returnType); 317 collectTypeDependencies(type.returnType);
318 } else if (type is ResolutionTypedefType) { 318 } else if (type is ResolutionTypedefType) {
319 elements.add(type.element); 319 elements.add(type.element);
320 collectTypeDependencies(type.unaliased); 320 collectTypeDependencies(type.unaliased);
321 } else if (type is ResolutionInterfaceType) { 321 } else if (type is ResolutionInterfaceType) {
322 if (elements.add(type.element)) { 322 elements.add(type.element);
323 collectTypeDependencies(type.element.supertype);
324 }
325 } 323 }
326 } 324 }
327 325
328 /// Collects all direct dependencies of [element]. 326 /// Collects all direct dependencies of [element].
329 /// 327 ///
330 /// The collected dependent elements and constants are are added to 328 /// The collected dependent elements and constants are are added to
331 /// [elements] and [constants] respectively. 329 /// [elements] and [constants] respectively.
332 void collectDependencies(Element element) { 330 void collectDependencies(Element element) {
333 // TODO(johnniwinther): Remove this when [AbstractFieldElement] has been 331 // TODO(johnniwinther): Remove this when [AbstractFieldElement] has been
334 // removed. 332 // removed.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // extra dependencies due to mirrors. 447 // extra dependencies due to mirrors.
450 void addLiveInstanceMember(_, _element) { 448 void addLiveInstanceMember(_, _element) {
451 MemberElement element = _element; 449 MemberElement element = _element;
452 if (!compiler.resolutionWorldBuilder.isMemberUsed(element)) return; 450 if (!compiler.resolutionWorldBuilder.isMemberUsed(element)) return;
453 if (!isMirrorUsage && !element.isInstanceMember) return; 451 if (!isMirrorUsage && !element.isInstanceMember) return;
454 elements.add(element); 452 elements.add(element);
455 collectDependencies(element); 453 collectDependencies(element);
456 } 454 }
457 455
458 ClassElement cls = element.declaration; 456 ClassElement cls = element.declaration;
459 cls.implementation.forEachMember(addLiveInstanceMember); 457 ClassElement implementation = cls.implementation;
460 for (ResolutionInterfaceType type in cls.implementation.allSupertypes) { 458 implementation.forEachMember(addLiveInstanceMember);
459 var supertype = implementation.supertype;
460 if (supertype is GenericType) {
461 supertype.typeArguments.forEach(collectTypeDependencies);
462 }
463 for (ResolutionInterfaceType type in implementation.allSupertypes) {
461 elements.add(type.element.implementation); 464 elements.add(type.element.implementation);
sra1 2017/08/11 21:55:46 I think we need types from all supertypes to ensur
Siggi Cherem (dart-lang) 2017/08/11 22:08:15 Done. Also added a test with an `is` check. We sho
462 } 465 }
463 elements.add(cls.implementation); 466 elements.add(implementation);
464 } else if (Elements.isStaticOrTopLevel(element) || element.isConstructor) { 467 } else if (Elements.isStaticOrTopLevel(element) || element.isConstructor) {
465 elements.add(element); 468 elements.add(element);
466 collectDependencies(element); 469 collectDependencies(element);
467 } 470 }
468 if (element.isGenerativeConstructor) { 471 if (element.isGenerativeConstructor) {
469 // When instantiating a class, we record a reference to the 472 // When instantiating a class, we record a reference to the
470 // constructor, not the class itself. We must add all the 473 // constructor, not the class itself. We must add all the
471 // instance members of the constructor's class. 474 // instance members of the constructor's class.
472 ClassElement implementation = element.enclosingClass.implementation; 475 ClassElement implementation = element.enclosingClass.implementation;
473 _collectAllElementsAndConstantsResolvedFrom( 476 _collectAllElementsAndConstantsResolvedFrom(
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 1127
1125 bool operator ==(other) { 1128 bool operator ==(other) {
1126 if (other is! _DeclaredDeferredImport) return false; 1129 if (other is! _DeclaredDeferredImport) return false;
1127 return declaration == other.declaration; 1130 return declaration == other.declaration;
1128 } 1131 }
1129 1132
1130 int get hashCode => declaration.hashCode * 17; 1133 int get hashCode => declaration.hashCode * 17;
1131 1134
1132 String toString() => '$declaration'; 1135 String toString() => '$declaration';
1133 } 1136 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698