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

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

Issue 2647833002: fix #28008, fix #28009 implement FutureOr<T> (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into 28008_futureort Created 3 years, 11 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 return typeArguments; 1353 return typeArguments;
1354 } 1354 }
1355 } 1355 }
1356 1356
1357 class _ResynthesizerContext implements ResynthesizerContext { 1357 class _ResynthesizerContext implements ResynthesizerContext {
1358 final _UnitResynthesizer _unitResynthesizer; 1358 final _UnitResynthesizer _unitResynthesizer;
1359 1359
1360 _ResynthesizerContext(this._unitResynthesizer); 1360 _ResynthesizerContext(this._unitResynthesizer);
1361 1361
1362 @override 1362 @override
1363 bool get isStrongMode => _unitResynthesizer.summaryResynthesizer.strongMode;
1364
1365 @override
1363 ElementAnnotationImpl buildAnnotation(ElementImpl context, UnlinkedExpr uc) { 1366 ElementAnnotationImpl buildAnnotation(ElementImpl context, UnlinkedExpr uc) {
1364 return _unitResynthesizer.buildAnnotation(context, uc); 1367 return _unitResynthesizer.buildAnnotation(context, uc);
1365 } 1368 }
1366 1369
1367 @override 1370 @override
1368 Expression buildExpression(ElementImpl context, UnlinkedExpr uc) { 1371 Expression buildExpression(ElementImpl context, UnlinkedExpr uc) {
1369 return _unitResynthesizer._buildConstExpression(context, uc); 1372 return _unitResynthesizer._buildConstExpression(context, uc);
1370 } 1373 }
1371 1374
1372 @override 1375 @override
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 String identifier = _getElementIdentifier(name, linkedReference.kind); 1733 String identifier = _getElementIdentifier(name, linkedReference.kind);
1731 locationComponents = 1734 locationComponents =
1732 enclosingInfo.element.location.components.toList(); 1735 enclosingInfo.element.location.components.toList();
1733 locationComponents.add(identifier); 1736 locationComponents.add(identifier);
1734 } else { 1737 } else {
1735 String identifier = _getElementIdentifier(name, linkedReference.kind); 1738 String identifier = _getElementIdentifier(name, linkedReference.kind);
1736 locationComponents = 1739 locationComponents =
1737 libraryResynthesizer.getReferencedLocationComponents( 1740 libraryResynthesizer.getReferencedLocationComponents(
1738 linkedReference.dependency, linkedReference.unit, identifier); 1741 linkedReference.dependency, linkedReference.unit, identifier);
1739 } 1742 }
1743 if (!_resynthesizerContext.isStrongMode &&
1744 locationComponents.length == 3 &&
1745 locationComponents[0] == 'dart:async' &&
1746 locationComponents[2] == 'FutureOr') {
1747 type = typeProvider.dynamicType;
1748 numTypeParameters = 0;
1749 }
1740 ElementLocation location = 1750 ElementLocation location =
1741 new ElementLocationImpl.con3(locationComponents); 1751 new ElementLocationImpl.con3(locationComponents);
1742 if (enclosingInfo != null) { 1752 if (enclosingInfo != null) {
1743 numTypeParameters += enclosingInfo.numTypeParameters; 1753 numTypeParameters += enclosingInfo.numTypeParameters;
1744 } 1754 }
1745 switch (linkedReference.kind) { 1755 switch (linkedReference.kind) {
1746 case ReferenceKind.classOrEnum: 1756 case ReferenceKind.classOrEnum:
1747 element = new ClassElementHandle(summaryResynthesizer, location); 1757 element = new ClassElementHandle(summaryResynthesizer, location);
1748 break; 1758 break;
1749 case ReferenceKind.constructor: 1759 case ReferenceKind.constructor:
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 static String _getElementIdentifier(String name, ReferenceKind kind) { 1889 static String _getElementIdentifier(String name, ReferenceKind kind) {
1880 if (kind == ReferenceKind.topLevelPropertyAccessor || 1890 if (kind == ReferenceKind.topLevelPropertyAccessor ||
1881 kind == ReferenceKind.propertyAccessor) { 1891 kind == ReferenceKind.propertyAccessor) {
1882 if (!name.endsWith('=')) { 1892 if (!name.endsWith('=')) {
1883 return name + '?'; 1893 return name + '?';
1884 } 1894 }
1885 } 1895 }
1886 return name; 1896 return name;
1887 } 1897 }
1888 } 1898 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | pkg/analyzer/test/generated/analysis_context_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698