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

Side by Side Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 2994913002: Fix for inheriting covariance from a resynthesyzed parameter. (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
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 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 * Element representing a compilation unit which is depended upon 1427 * Element representing a compilation unit which is depended upon
1428 * (either directly or indirectly) by the build unit being linked. 1428 * (either directly or indirectly) by the build unit being linked.
1429 * 1429 *
1430 * TODO(paulberry): ensure that inferred types in dependencies are properly 1430 * TODO(paulberry): ensure that inferred types in dependencies are properly
1431 * resynthesized. 1431 * resynthesized.
1432 */ 1432 */
1433 class CompilationUnitElementInDependency extends CompilationUnitElementForLink { 1433 class CompilationUnitElementInDependency extends CompilationUnitElementForLink {
1434 @override 1434 @override
1435 final LinkedUnit _linkedUnit; 1435 final LinkedUnit _linkedUnit;
1436 1436
1437 /**
1438 * Set of slot ids corresponding to parameters that inherit `covariant`.
1439 */
1440 Set<int> parametersInheritingCovariant;
1441
1437 List<EntityRef> _linkedTypeRefs; 1442 List<EntityRef> _linkedTypeRefs;
1438 1443
1439 @override 1444 @override
1440 final LibraryElementInDependency enclosingElement; 1445 final LibraryElementInDependency enclosingElement;
1441 1446
1442 CompilationUnitElementInDependency( 1447 CompilationUnitElementInDependency(
1443 this.enclosingElement, 1448 this.enclosingElement,
1444 UnlinkedUnit unlinkedUnit, 1449 UnlinkedUnit unlinkedUnit,
1445 LinkedUnit linkedUnit, 1450 LinkedUnit linkedUnit,
1446 int unitNum, 1451 int unitNum,
1447 String absoluteUri) 1452 String absoluteUri)
1448 : _linkedUnit = linkedUnit, 1453 : _linkedUnit = linkedUnit,
1449 super( 1454 super(
1450 unlinkedUnit, unitNum, linkedUnit.references.length, absoluteUri) { 1455 unlinkedUnit, unitNum, linkedUnit.references.length, absoluteUri) {
1456 parametersInheritingCovariant =
1457 _linkedUnit.parametersInheritingCovariant.toSet();
1451 // Make one pass through the linked types to determine the lengths for 1458 // Make one pass through the linked types to determine the lengths for
1452 // _linkedTypeRefs and _linkedTypes. TODO(paulberry): add an int to the 1459 // _linkedTypeRefs and _linkedTypes. TODO(paulberry): add an int to the
1453 // summary to make this unnecessary. 1460 // summary to make this unnecessary.
1454 int maxLinkedTypeSlot = 0; 1461 int maxLinkedTypeSlot = 0;
1455 for (EntityRef ref in _linkedUnit.types) { 1462 for (EntityRef ref in _linkedUnit.types) {
1456 if (ref.slot > maxLinkedTypeSlot) { 1463 if (ref.slot > maxLinkedTypeSlot) {
1457 maxLinkedTypeSlot = ref.slot; 1464 maxLinkedTypeSlot = ref.slot;
1458 } 1465 }
1459 } 1466 }
1460 // Initialize _linkedTypeRefs. 1467 // Initialize _linkedTypeRefs.
(...skipping 2829 matching lines...) Expand 10 before | Expand all | Expand 10 after
4290 DartType _inferredType; 4297 DartType _inferredType;
4291 TopLevelInferenceErrorBuilder _inferenceError; 4298 TopLevelInferenceErrorBuilder _inferenceError;
4292 DartType _declaredType; 4299 DartType _declaredType;
4293 bool _inheritsCovariant = false; 4300 bool _inheritsCovariant = false;
4294 4301
4295 ParameterElementForLink(this.enclosingElement, this._unlinkedParam, 4302 ParameterElementForLink(this.enclosingElement, this._unlinkedParam,
4296 this._typeParameterContext, this.compilationUnit, this._parameterIndex) { 4303 this._typeParameterContext, this.compilationUnit, this._parameterIndex) {
4297 if (_unlinkedParam.initializer?.bodyExpr != null) { 4304 if (_unlinkedParam.initializer?.bodyExpr != null) {
4298 _constNode = new ConstParameterNode(this); 4305 _constNode = new ConstParameterNode(this);
4299 } 4306 }
4307 if (compilationUnit is CompilationUnitElementInDependency) {
4308 _inheritsCovariant =
4309 (compilationUnit as CompilationUnitElementInDependency)
4310 .parametersInheritingCovariant
4311 .contains(_unlinkedParam.inheritsCovariantSlot);
4312 }
4300 } 4313 }
4301 4314
4302 factory ParameterElementForLink.forFactory( 4315 factory ParameterElementForLink.forFactory(
4303 ParameterParentElementForLink enclosingElement, 4316 ParameterParentElementForLink enclosingElement,
4304 UnlinkedParam unlinkedParameter, 4317 UnlinkedParam unlinkedParameter,
4305 TypeParameterizedElementMixin typeParameterContext, 4318 TypeParameterizedElementMixin typeParameterContext,
4306 CompilationUnitElementForLink compilationUnit, 4319 CompilationUnitElementForLink compilationUnit,
4307 int parameterIndex) { 4320 int parameterIndex) {
4308 if (unlinkedParameter.isInitializingFormal) { 4321 if (unlinkedParameter.isInitializingFormal) {
4309 return new FieldFormalParameterElementForLink( 4322 return new FieldFormalParameterElementForLink(
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 * there are no type parameters in scope. 5515 * there are no type parameters in scope.
5503 */ 5516 */
5504 TypeParameterizedElementMixin get _typeParameterContext; 5517 TypeParameterizedElementMixin get _typeParameterContext;
5505 5518
5506 @override 5519 @override
5507 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 5520 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
5508 5521
5509 @override 5522 @override
5510 String toString() => '$enclosingElement.$name'; 5523 String toString() => '$enclosingElement.$name';
5511 } 5524 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698