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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 1933403002: Revert "Implements support for ignoring method type arguments in resolution." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 elements.modelx; 5 library elements.modelx;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Resolution, ParsingContext; 8 import '../common/resolution.dart' show Resolution, ParsingContext;
9 import '../compiler.dart' show Compiler; 9 import '../compiler.dart' show Compiler;
10 import '../constants/constant_constructors.dart'; 10 import '../constants/constant_constructors.dart';
11 import '../constants/constructors.dart'; 11 import '../constants/constructors.dart';
12 import '../constants/expressions.dart'; 12 import '../constants/expressions.dart';
13 import '../dart_types.dart'; 13 import '../dart_types.dart';
14 import '../diagnostics/messages.dart' show MessageTemplate; 14 import '../diagnostics/messages.dart' show MessageTemplate;
15 import '../ordered_typeset.dart' show OrderedTypeSet; 15 import '../ordered_typeset.dart' show OrderedTypeSet;
16 import '../resolution/class_members.dart' show ClassMemberMixin; 16 import '../resolution/class_members.dart' show ClassMemberMixin;
17 import '../resolution/scope.dart' 17 import '../resolution/scope.dart'
18 show 18 show ClassScope, LibraryScope, Scope, TypeDeclarationScope;
19 ClassScope,
20 LibraryScope,
21 Scope,
22 TypeDeclarationScope;
23 import '../resolution/resolution.dart' show AnalyzableElementX; 19 import '../resolution/resolution.dart' show AnalyzableElementX;
24 import '../resolution/tree_elements.dart' show TreeElements; 20 import '../resolution/tree_elements.dart' show TreeElements;
25 import '../resolution/typedefs.dart' show TypedefCyclicVisitor; 21 import '../resolution/typedefs.dart' show TypedefCyclicVisitor;
26 import '../script.dart'; 22 import '../script.dart';
27 import '../tokens/token.dart' show ErrorToken, Token; 23 import '../tokens/token.dart' show ErrorToken, Token;
28 import '../tokens/token_constants.dart' as Tokens show EOF_TOKEN; 24 import '../tokens/token_constants.dart' as Tokens show EOF_TOKEN;
29 import '../tree/tree.dart'; 25 import '../tree/tree.dart';
30 import '../util/util.dart'; 26 import '../util/util.dart';
31 27
32 import 'common.dart'; 28 import 'common.dart';
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return visitor.visitErroneousElement(this, arg); 276 return visitor.visitErroneousElement(this, arg);
281 } 277 }
282 278
283 @override 279 @override
284 get isEffectiveTargetMalformed { 280 get isEffectiveTargetMalformed {
285 throw new UnsupportedError("isEffectiveTargetMalformed"); 281 throw new UnsupportedError("isEffectiveTargetMalformed");
286 } 282 }
287 283
288 @override 284 @override
289 bool get isFromEnvironmentConstructor => false; 285 bool get isFromEnvironmentConstructor => false;
290
291 @override
292 List<DartType> get typeVariables => unsupported();
293 } 286 }
294 287
295 /// A constructor that was synthesized to recover from a compile-time error. 288 /// A constructor that was synthesized to recover from a compile-time error.
296 class ErroneousConstructorElementX extends ErroneousElementX 289 class ErroneousConstructorElementX extends ErroneousElementX
297 with 290 with
298 PatchMixin<FunctionElement>, 291 PatchMixin<FunctionElement>,
299 AnalyzableElementX, 292 AnalyzableElementX,
300 ConstantConstructorMixin 293 ConstantConstructorMixin
301 implements ConstructorElementX { 294 implements ConstructorElementX {
302 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should 295 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 } 1657 }
1665 1658
1666 /// [Element] for a parameter-like element. 1659 /// [Element] for a parameter-like element.
1667 class FormalElementX extends ElementX 1660 class FormalElementX extends ElementX
1668 with AstElementMixin 1661 with AstElementMixin
1669 implements FormalElement { 1662 implements FormalElement {
1670 final VariableDefinitions definitions; 1663 final VariableDefinitions definitions;
1671 final Identifier identifier; 1664 final Identifier identifier;
1672 DartType typeCache; 1665 DartType typeCache;
1673 1666
1674 @override
1675 List<DartType> get typeVariables => functionSignature.typeVariables;
1676
1677 /** 1667 /**
1678 * Function signature for a variable with a function type. The signature is 1668 * Function signature for a variable with a function type. The signature is
1679 * kept to provide full information about parameter names through the mirror 1669 * kept to provide full information about parameter names through the mirror
1680 * system. 1670 * system.
1681 */ 1671 */
1682 FunctionSignature _functionSignatureCache; 1672 FunctionSignature _functionSignatureCache;
1683 1673
1684 FormalElementX(ElementKind elementKind, FunctionTypedElement enclosingElement, 1674 FormalElementX(ElementKind elementKind, FunctionTypedElement enclosingElement,
1685 this.definitions, Identifier identifier) 1675 this.definitions, Identifier identifier)
1686 : this.identifier = identifier, 1676 : this.identifier = identifier,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 return getter != null && getter.isAbstract || 1886 return getter != null && getter.isAbstract ||
1897 setter != null && setter.isAbstract; 1887 setter != null && setter.isAbstract;
1898 } 1888 }
1899 } 1889 }
1900 1890
1901 // TODO(johnniwinther): [FunctionSignature] should be merged with 1891 // TODO(johnniwinther): [FunctionSignature] should be merged with
1902 // [FunctionType]. 1892 // [FunctionType].
1903 // TODO(karlklose): all these lists should have element type [FormalElement]. 1893 // TODO(karlklose): all these lists should have element type [FormalElement].
1904 class FunctionSignatureX extends FunctionSignatureCommon 1894 class FunctionSignatureX extends FunctionSignatureCommon
1905 implements FunctionSignature { 1895 implements FunctionSignature {
1906 final List<DartType> typeVariables;
1907 final List<Element> requiredParameters; 1896 final List<Element> requiredParameters;
1908 final List<Element> optionalParameters; 1897 final List<Element> optionalParameters;
1909 final int requiredParameterCount; 1898 final int requiredParameterCount;
1910 final int optionalParameterCount; 1899 final int optionalParameterCount;
1911 final bool optionalParametersAreNamed; 1900 final bool optionalParametersAreNamed;
1912 final List<Element> orderedOptionalParameters; 1901 final List<Element> orderedOptionalParameters;
1913 final FunctionType type; 1902 final FunctionType type;
1914 final bool hasOptionalParameters; 1903 final bool hasOptionalParameters;
1915 1904
1916 FunctionSignatureX( 1905 FunctionSignatureX(
1917 {this.typeVariables: const <DartType>[], 1906 {this.requiredParameters: const <Element>[],
1918 this.requiredParameters: const <Element>[],
1919 this.requiredParameterCount: 0, 1907 this.requiredParameterCount: 0,
1920 List<Element> optionalParameters: const <Element>[], 1908 List<Element> optionalParameters: const <Element>[],
1921 this.optionalParameterCount: 0, 1909 this.optionalParameterCount: 0,
1922 this.optionalParametersAreNamed: false, 1910 this.optionalParametersAreNamed: false,
1923 this.orderedOptionalParameters: const <Element>[], 1911 this.orderedOptionalParameters: const <Element>[],
1924 this.type}) 1912 this.type})
1925 : optionalParameters = optionalParameters, 1913 : optionalParameters = optionalParameters,
1926 hasOptionalParameters = !optionalParameters.isEmpty; 1914 hasOptionalParameters = !optionalParameters.isEmpty;
1927 } 1915 }
1928 1916
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 } 1977 }
1990 1978
1991 FunctionType get type { 1979 FunctionType get type {
1992 assert(invariant(this, typeCache != null, 1980 assert(invariant(this, typeCache != null,
1993 message: "Type has not been computed for $this.")); 1981 message: "Type has not been computed for $this."));
1994 return typeCache; 1982 return typeCache;
1995 } 1983 }
1996 1984
1997 FunctionElement asFunctionElement() => this; 1985 FunctionElement asFunctionElement() => this;
1998 1986
1999 @override
2000 Scope buildScope() => new TypeDeclarationScope(super.buildScope(), this);
2001
2002 String toString() { 1987 String toString() {
2003 if (isPatch) { 1988 if (isPatch) {
2004 return 'patch ${super.toString()}'; 1989 return 'patch ${super.toString()}';
2005 } else if (isPatched) { 1990 } else if (isPatched) {
2006 return 'origin ${super.toString()}'; 1991 return 'origin ${super.toString()}';
2007 } else { 1992 } else {
2008 return super.toString(); 1993 return super.toString();
2009 } 1994 }
2010 } 1995 }
2011 1996
2012 bool get isAbstract => false; 1997 bool get isAbstract => false;
2013 1998
2014 // A function is defined by the implementation element. 1999 // A function is defined by the implementation element.
2015 AstElement get definingElement => implementation; 2000 AstElement get definingElement => implementation;
2016
2017 @override
2018 List<DartType> get typeVariables => functionSignature.typeVariables;
2019 } 2001 }
2020 2002
2021 abstract class FunctionElementX extends BaseFunctionElementX 2003 abstract class FunctionElementX extends BaseFunctionElementX
2022 with AnalyzableElementX 2004 with AnalyzableElementX
2023 implements MethodElement { 2005 implements MethodElement {
2024 FunctionElementX( 2006 FunctionElementX(
2025 String name, ElementKind kind, Modifiers modifiers, Element enclosing) 2007 String name, ElementKind kind, Modifiers modifiers, Element enclosing)
2026 : super(name, kind, modifiers, enclosing); 2008 : super(name, kind, modifiers, enclosing);
2027 2009
2028 MemberElement get memberContext => this; 2010 MemberElement get memberContext => this;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 } 2148 }
2167 } 2149 }
2168 2150
2169 bool get isFromEnvironmentConstructor { 2151 bool get isFromEnvironmentConstructor {
2170 return name == 'fromEnvironment' && 2152 return name == 'fromEnvironment' &&
2171 library.isDartCore && 2153 library.isDartCore &&
2172 (enclosingClass.name == 'bool' || 2154 (enclosingClass.name == 'bool' ||
2173 enclosingClass.name == 'int' || 2155 enclosingClass.name == 'int' ||
2174 enclosingClass.name == 'String'); 2156 enclosingClass.name == 'String');
2175 } 2157 }
2176
2177 /// Returns the empty list of type variables by default.
2178 @override
2179 List<DartType> get typeVariables => functionSignature.typeVariables;
2180 } 2158 }
2181 2159
2182 abstract class ConstructorElementX extends FunctionElementX 2160 abstract class ConstructorElementX extends FunctionElementX
2183 with ConstantConstructorMixin 2161 with ConstantConstructorMixin
2184 implements ConstructorElement { 2162 implements ConstructorElement {
2185 bool isRedirectingGenerative = false; 2163 bool isRedirectingGenerative = false;
2186 2164
2187 ConstructorElementX( 2165 ConstructorElementX(
2188 String name, ElementKind kind, Modifiers modifiers, Element enclosing) 2166 String name, ElementKind kind, Modifiers modifiers, Element enclosing)
2189 : super(name, kind, modifiers, enclosing); 2167 : super(name, kind, modifiers, enclosing);
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 3078
3101 class TypeVariableElementX extends ElementX 3079 class TypeVariableElementX extends ElementX
3102 with AstElementMixin 3080 with AstElementMixin
3103 implements TypeVariableElement { 3081 implements TypeVariableElement {
3104 final int index; 3082 final int index;
3105 final Node node; 3083 final Node node;
3106 TypeVariableType typeCache; 3084 TypeVariableType typeCache;
3107 DartType boundCache; 3085 DartType boundCache;
3108 3086
3109 TypeVariableElementX( 3087 TypeVariableElementX(
3110 String name, GenericElement enclosing, this.index, this.node) 3088 String name, TypeDeclarationElement enclosing, this.index, this.node)
3111 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 3089 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
3112 3090
3113 GenericElement get typeDeclaration => enclosingElement; 3091 TypeDeclarationElement get typeDeclaration => enclosingElement;
3114 3092
3115 TypeVariableType computeType(Resolution resolution) => type; 3093 TypeVariableType computeType(Resolution resolution) => type;
3116 3094
3117 TypeVariableType get type { 3095 TypeVariableType get type {
3118 assert(invariant(this, typeCache != null, 3096 assert(invariant(this, typeCache != null,
3119 message: "Type has not been set on $this.")); 3097 message: "Type has not been set on $this."));
3120 return typeCache; 3098 return typeCache;
3121 } 3099 }
3122 3100
3123 DartType get bound { 3101 DartType get bound {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 if (definingElement.isField) { 3245 if (definingElement.isField) {
3268 FieldElement field = definingElement; 3246 FieldElement field = definingElement;
3269 body = field.initializer; 3247 body = field.initializer;
3270 } else if (node != null && node.asFunctionExpression() != null) { 3248 } else if (node != null && node.asFunctionExpression() != null) {
3271 body = node.asFunctionExpression().body; 3249 body = node.asFunctionExpression().body;
3272 } 3250 }
3273 return new ParsedResolvedAst( 3251 return new ParsedResolvedAst(
3274 declaration, node, body, definingElement.treeElements); 3252 declaration, node, body, definingElement.treeElements);
3275 } 3253 }
3276 } 3254 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/parser/node_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698