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 engine.resolver; | 5 library engine.resolver; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'ast.dart'; | 9 import 'ast.dart'; |
10 import 'constant.dart'; | 10 import 'constant.dart'; |
(...skipping 14921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14932 * Given a parameter element, create a function type based on the given return
type and parameter | 14932 * Given a parameter element, create a function type based on the given return
type and parameter |
14933 * list and associate the created type with the element. | 14933 * list and associate the created type with the element. |
14934 * | 14934 * |
14935 * @param element the parameter element whose type is to be set | 14935 * @param element the parameter element whose type is to be set |
14936 * @param returnType the (possibly `null`) return type of the function | 14936 * @param returnType the (possibly `null`) return type of the function |
14937 * @param parameterList the list of parameters to the function | 14937 * @param parameterList the list of parameters to the function |
14938 */ | 14938 */ |
14939 void _setFunctionTypedParameterType(ParameterElementImpl element, | 14939 void _setFunctionTypedParameterType(ParameterElementImpl element, |
14940 TypeName returnType, FormalParameterList parameterList) { | 14940 TypeName returnType, FormalParameterList parameterList) { |
14941 List<ParameterElement> parameters = _getElements(parameterList); | 14941 List<ParameterElement> parameters = _getElements(parameterList); |
14942 FunctionTypeAliasElementImpl aliasElement = | 14942 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(null); |
14943 new FunctionTypeAliasElementImpl.forNode(null); | 14943 functionElement.synthetic = true; |
14944 aliasElement.synthetic = true; | 14944 functionElement.shareParameters(parameters); |
14945 aliasElement.shareParameters(parameters); | 14945 functionElement.returnType = _computeReturnType(returnType); |
14946 aliasElement.returnType = _computeReturnType(returnType); | 14946 functionElement.enclosingElement = element; |
14947 // FunctionTypeAliasElementImpl assumes the enclosing element is a | 14947 element.type = new FunctionTypeImpl(functionElement); |
14948 // CompilationUnitElement (because non-synthetic function types can only be | |
14949 // declared at top level), so to avoid breaking things, go find the | |
14950 // compilation unit element. | |
14951 aliasElement.enclosingElement = | |
14952 element.getAncestor((element) => element is CompilationUnitElement); | |
14953 ClassElement definingClass = | |
14954 element.getAncestor((element) => element is ClassElement); | |
14955 if (definingClass != null) { | |
14956 aliasElement.shareTypeParameters(definingClass.typeParameters); | |
14957 } else { | |
14958 FunctionTypeAliasElement alias = | |
14959 element.getAncestor((element) => element is FunctionTypeAliasElement); | |
14960 while (alias != null && alias.isSynthetic) { | |
14961 alias = | |
14962 alias.getAncestor((element) => element is FunctionTypeAliasElement); | |
14963 } | |
14964 if (alias != null) { | |
14965 aliasElement.typeParameters = alias.typeParameters; | |
14966 } | |
14967 } | |
14968 element.type = new FunctionTypeImpl.forTypedef(aliasElement); | |
14969 } | 14948 } |
14970 | 14949 |
14971 /** | 14950 /** |
14972 * @return `true` if the name of the given [TypeName] is an built-in identifie
r. | 14951 * @return `true` if the name of the given [TypeName] is an built-in identifie
r. |
14973 */ | 14952 */ |
14974 static bool _isBuiltInIdentifier(TypeName node) { | 14953 static bool _isBuiltInIdentifier(TypeName node) { |
14975 sc.Token token = node.name.beginToken; | 14954 sc.Token token = node.name.beginToken; |
14976 return token.type == sc.TokenType.KEYWORD; | 14955 return token.type == sc.TokenType.KEYWORD; |
14977 } | 14956 } |
14978 | 14957 |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15570 nonFields.add(node); | 15549 nonFields.add(node); |
15571 return null; | 15550 return null; |
15572 } | 15551 } |
15573 | 15552 |
15574 @override | 15553 @override |
15575 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); | 15554 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); |
15576 | 15555 |
15577 @override | 15556 @override |
15578 Object visitWithClause(WithClause node) => null; | 15557 Object visitWithClause(WithClause node) => null; |
15579 } | 15558 } |
OLD | NEW |