| OLD | NEW |
| 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 analyzer.src.generated.resolver; | 5 library analyzer.src.generated.resolver; |
| 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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 6283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6294 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 6294 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 6295 InferenceContext.setType(node.defaultValue, node.parameter.element?.type); | 6295 InferenceContext.setType(node.defaultValue, node.parameter.element?.type); |
| 6296 super.visitDefaultFormalParameter(node); | 6296 super.visitDefaultFormalParameter(node); |
| 6297 ParameterElement element = node.element; | 6297 ParameterElement element = node.element; |
| 6298 if (element.initializer != null && node.defaultValue != null) { | 6298 if (element.initializer != null && node.defaultValue != null) { |
| 6299 (element.initializer as FunctionElementImpl).returnType = | 6299 (element.initializer as FunctionElementImpl).returnType = |
| 6300 node.defaultValue.staticType; | 6300 node.defaultValue.staticType; |
| 6301 } | 6301 } |
| 6302 // Clone the ASTs for default formal parameters, so that we can use them | 6302 // Clone the ASTs for default formal parameters, so that we can use them |
| 6303 // during constant evaluation. | 6303 // during constant evaluation. |
| 6304 (element as ConstVariableElement).constantInitializer = | 6304 if (!LibraryElementImpl.hasResolutionCapability( |
| 6305 new ConstantAstCloner().cloneNode(node.defaultValue); | 6305 definingLibrary, LibraryResolutionCapability.constantExpressions)) { |
| 6306 (element as ConstVariableElement).constantInitializer = |
| 6307 new ConstantAstCloner().cloneNode(node.defaultValue); |
| 6308 } |
| 6306 return null; | 6309 return null; |
| 6307 } | 6310 } |
| 6308 | 6311 |
| 6309 @override | 6312 @override |
| 6310 Object visitDoStatement(DoStatement node) { | 6313 Object visitDoStatement(DoStatement node) { |
| 6311 _overrideManager.enterScope(); | 6314 _overrideManager.enterScope(); |
| 6312 try { | 6315 try { |
| 6313 super.visitDoStatement(node); | 6316 super.visitDoStatement(node); |
| 6314 } finally { | 6317 } finally { |
| 6315 _overrideManager.exitScope(); | 6318 _overrideManager.exitScope(); |
| (...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9183 // TODO(scheglov) report error when don't apply type bounds for type bounds | 9186 // TODO(scheglov) report error when don't apply type bounds for type bounds |
| 9184 } | 9187 } |
| 9185 | 9188 |
| 9186 void _resolveTypeParameters( | 9189 void _resolveTypeParameters( |
| 9187 TypeParameterList typeParameters, Scope createTypeParametersScope()) { | 9190 TypeParameterList typeParameters, Scope createTypeParametersScope()) { |
| 9188 if (typeParameters != null) { | 9191 if (typeParameters != null) { |
| 9189 Scope typeParametersScope = null; | 9192 Scope typeParametersScope = null; |
| 9190 for (TypeParameter typeParameter in typeParameters.typeParameters) { | 9193 for (TypeParameter typeParameter in typeParameters.typeParameters) { |
| 9191 TypeName bound = typeParameter.bound; | 9194 TypeName bound = typeParameter.bound; |
| 9192 if (bound != null) { | 9195 if (bound != null) { |
| 9193 libraryScope ??= new LibraryScope(library, errorListener); | |
| 9194 typeParametersScope ??= createTypeParametersScope(); | |
| 9195 typeNameResolver ??= new TypeNameResolver(new TypeSystemImpl(), | |
| 9196 typeProvider, library, source, errorListener); | |
| 9197 typeNameResolver.nameScope = typeParametersScope; | |
| 9198 _resolveTypeName(bound); | |
| 9199 Element typeParameterElement = typeParameter.name.staticElement; | 9196 Element typeParameterElement = typeParameter.name.staticElement; |
| 9200 if (typeParameterElement is TypeParameterElementImpl) { | 9197 if (typeParameterElement is TypeParameterElementImpl) { |
| 9201 typeParameterElement.bound = bound.type; | 9198 if (LibraryElementImpl.hasResolutionCapability( |
| 9199 library, LibraryResolutionCapability.resolvedTypeNames)) { |
| 9200 bound.type = typeParameterElement.bound; |
| 9201 } else { |
| 9202 libraryScope ??= new LibraryScope(library, errorListener); |
| 9203 typeParametersScope ??= createTypeParametersScope(); |
| 9204 typeNameResolver ??= new TypeNameResolver(new TypeSystemImpl(), |
| 9205 typeProvider, library, source, errorListener); |
| 9206 typeNameResolver.nameScope = typeParametersScope; |
| 9207 _resolveTypeName(bound); |
| 9208 typeParameterElement.bound = bound.type; |
| 9209 } |
| 9202 } | 9210 } |
| 9203 } | 9211 } |
| 9204 } | 9212 } |
| 9205 } | 9213 } |
| 9206 } | 9214 } |
| 9207 } | 9215 } |
| 9208 | 9216 |
| 9209 /** | 9217 /** |
| 9210 * Instances of the class `TypePromotionManager` manage the ability to promote t
ypes of local | 9218 * Instances of the class `TypePromotionManager` manage the ability to promote t
ypes of local |
| 9211 * variables and formal parameters from their declared types based on control fl
ow. | 9219 * variables and formal parameters from their declared types based on control fl
ow. |
| (...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10971 return null; | 10979 return null; |
| 10972 } | 10980 } |
| 10973 if (identical(node.staticElement, variable)) { | 10981 if (identical(node.staticElement, variable)) { |
| 10974 if (node.inSetterContext()) { | 10982 if (node.inSetterContext()) { |
| 10975 result = true; | 10983 result = true; |
| 10976 } | 10984 } |
| 10977 } | 10985 } |
| 10978 return null; | 10986 return null; |
| 10979 } | 10987 } |
| 10980 } | 10988 } |
| OLD | NEW |