OLD | NEW |
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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 // If type arguments are specified, use them. | 1287 // If type arguments are specified, use them. |
1288 // Otherwise, delay until they are requested. | 1288 // Otherwise, delay until they are requested. |
1289 if (numTypeParameters == 0) { | 1289 if (numTypeParameters == 0) { |
1290 return element.type; | 1290 return element.type; |
1291 } else if (numTypeArguments == numTypeParameters) { | 1291 } else if (numTypeArguments == numTypeParameters) { |
1292 typeArguments = _buildTypeArguments(numTypeArguments, getTypeArgument); | 1292 typeArguments = _buildTypeArguments(numTypeArguments, getTypeArgument); |
1293 } | 1293 } |
1294 InterfaceTypeImpl type = | 1294 InterfaceTypeImpl type = |
1295 new InterfaceTypeImpl.elementWithNameAndArgs(element, name, () { | 1295 new InterfaceTypeImpl.elementWithNameAndArgs(element, name, () { |
1296 if (typeArguments == null) { | 1296 if (typeArguments == null) { |
1297 if (libraryResynthesizer.summaryResynthesizer.strongMode && | 1297 if (libraryResynthesizer.summaryResynthesizer.strongMode) { |
1298 instantiateToBoundsAllowed) { | |
1299 InterfaceType instantiatedToBounds = libraryResynthesizer | 1298 InterfaceType instantiatedToBounds = libraryResynthesizer |
1300 .summaryResynthesizer.context.typeSystem | 1299 .summaryResynthesizer.context.typeSystem |
1301 .instantiateToBounds(element.type) as InterfaceType; | 1300 .instantiateToBounds(element.type) as InterfaceType; |
1302 return instantiatedToBounds.typeArguments; | 1301 return instantiatedToBounds.typeArguments; |
1303 } else { | 1302 } else { |
1304 return new List<DartType>.filled( | 1303 return new List<DartType>.filled( |
1305 numTypeParameters, DynamicTypeImpl.instance); | 1304 numTypeParameters, DynamicTypeImpl.instance); |
1306 } | 1305 } |
1307 } | 1306 } |
1308 return typeArguments; | 1307 return typeArguments; |
1309 }); | 1308 }); |
1310 // Mark the type as having implicit type arguments, so that we don't | 1309 // Mark the type as having implicit type arguments, so that we don't |
1311 // attempt to request them during constant expression resynthesizing. | 1310 // attempt to request them during constant expression resynthesizing. |
1312 if (typeArguments == null) { | 1311 if (typeArguments == null) { |
1313 libraryResynthesizer.typesWithImplicitTypeArguments.add(type); | 1312 libraryResynthesizer.typesWithImplicitTypeArguments.add(type); |
1314 } | 1313 } |
1315 // Done. | 1314 // Done. |
1316 return type; | 1315 return type; |
1317 } else if (element is FunctionTypedElement) { | 1316 } else if (element is FunctionTypedElement) { |
1318 if (element is FunctionTypeAliasElementHandle) { | 1317 if (element is FunctionTypeAliasElementHandle) { |
1319 List<DartType> typeArguments; | 1318 List<DartType> typeArguments; |
1320 if (numTypeArguments == numTypeParameters) { | 1319 if (numTypeArguments == numTypeParameters) { |
1321 typeArguments = | 1320 typeArguments = |
1322 _buildTypeArguments(numTypeArguments, getTypeArgument); | 1321 _buildTypeArguments(numTypeArguments, getTypeArgument); |
1323 } else if (libraryResynthesizer.summaryResynthesizer.strongMode && | 1322 } else if (libraryResynthesizer.summaryResynthesizer.strongMode) { |
1324 instantiateToBoundsAllowed) { | |
1325 FunctionType instantiatedToBounds = libraryResynthesizer | 1323 FunctionType instantiatedToBounds = libraryResynthesizer |
1326 .summaryResynthesizer.context.typeSystem | 1324 .summaryResynthesizer.context.typeSystem |
1327 .instantiateToBounds(element.type) as FunctionType; | 1325 .instantiateToBounds(element.type) as FunctionType; |
1328 typeArguments = instantiatedToBounds.typeArguments; | 1326 typeArguments = instantiatedToBounds.typeArguments; |
1329 } else { | 1327 } else { |
1330 typeArguments = new List<DartType>.filled( | 1328 typeArguments = new List<DartType>.filled( |
1331 numTypeParameters, DynamicTypeImpl.instance); | 1329 numTypeParameters, DynamicTypeImpl.instance); |
1332 } | 1330 } |
1333 return new FunctionTypeImpl.elementWithNameAndArgs( | 1331 return new FunctionTypeImpl.elementWithNameAndArgs( |
1334 element, name, typeArguments, numTypeParameters != 0); | 1332 element, name, typeArguments, numTypeParameters != 0); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1955 static String _getElementIdentifier(String name, ReferenceKind kind) { |
1958 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1956 if (kind == ReferenceKind.topLevelPropertyAccessor || |
1959 kind == ReferenceKind.propertyAccessor) { | 1957 kind == ReferenceKind.propertyAccessor) { |
1960 if (!name.endsWith('=')) { | 1958 if (!name.endsWith('=')) { |
1961 return name + '?'; | 1959 return name + '?'; |
1962 } | 1960 } |
1963 } | 1961 } |
1964 return name; | 1962 return name; |
1965 } | 1963 } |
1966 } | 1964 } |
OLD | NEW |