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

Side by Side Diff: pkg/compiler/lib/src/elements/elements.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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; 5 library elements;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Resolution; 8 import '../common/resolution.dart' show Resolution;
9 import '../compiler.dart' show Compiler; 9 import '../compiler.dart' show Compiler;
10 import '../constants/constructors.dart'; 10 import '../constants/constructors.dart';
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 element = closureClass.methodElement; 479 element = closureClass.methodElement;
480 } 480 }
481 Element outer = element.outermostEnclosingMemberOrTopLevel; 481 Element outer = element.outermostEnclosingMemberOrTopLevel;
482 if (isUnresolved(outer)) return true; 482 if (isUnresolved(outer)) return true;
483 if (outer.isTopLevel) return true; 483 if (outer.isTopLevel) return true;
484 if (outer.isGenerativeConstructor) return false; 484 if (outer.isGenerativeConstructor) return false;
485 if (outer.isInstanceMember) return false; 485 if (outer.isInstanceMember) return false;
486 return true; 486 return true;
487 } 487 }
488 488
489 static bool hasAccessToTypeVariable(Element element, 489 static bool hasAccessToTypeVariables(Element element) {
490 TypeVariableElement typeVariable) {
491 GenericElement declaration = typeVariable.typeDeclaration;
492 if (declaration is FunctionElement || declaration is ParameterElement) {
493 return true;
494 }
495 Element outer = element.outermostEnclosingMemberOrTopLevel; 490 Element outer = element.outermostEnclosingMemberOrTopLevel;
496 return (outer != null && outer.isFactoryConstructor) || 491 return (outer != null && outer.isFactoryConstructor) ||
497 !isInStaticContext(element); 492 !isInStaticContext(element);
498 } 493 }
499 494
500 static bool isStaticOrTopLevelField(Element element) { 495 static bool isStaticOrTopLevelField(Element element) {
501 return isStaticOrTopLevel(element) && 496 return isStaticOrTopLevel(element) &&
502 (identical(element.kind, ElementKind.FIELD) || 497 (identical(element.kind, ElementKind.FIELD) ||
503 identical(element.kind, ElementKind.GETTER) || 498 identical(element.kind, ElementKind.GETTER) ||
504 identical(element.kind, ElementKind.SETTER)); 499 identical(element.kind, ElementKind.SETTER));
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 * looking at code like "foo.x", we don't have to look for both a 1100 * looking at code like "foo.x", we don't have to look for both a
1106 * field named "x", a getter named "x", and a setter named "x=". 1101 * field named "x", a getter named "x", and a setter named "x=".
1107 */ 1102 */
1108 abstract class AbstractFieldElement extends Element { 1103 abstract class AbstractFieldElement extends Element {
1109 GetterElement get getter; 1104 GetterElement get getter;
1110 SetterElement get setter; 1105 SetterElement get setter;
1111 } 1106 }
1112 1107
1113 abstract class FunctionSignature { 1108 abstract class FunctionSignature {
1114 FunctionType get type; 1109 FunctionType get type;
1115 List<DartType> get typeVariables;
1116 List<FormalElement> get requiredParameters; 1110 List<FormalElement> get requiredParameters;
1117 List<FormalElement> get optionalParameters; 1111 List<FormalElement> get optionalParameters;
1118 1112
1119 int get requiredParameterCount; 1113 int get requiredParameterCount;
1120 int get optionalParameterCount; 1114 int get optionalParameterCount;
1121 bool get optionalParametersAreNamed; 1115 bool get optionalParametersAreNamed;
1122 bool get hasOptionalParameters; 1116 bool get hasOptionalParameters;
1123 1117
1124 int get parameterCount; 1118 int get parameterCount;
1125 List<FormalElement> get orderedOptionalParameters; 1119 List<FormalElement> get orderedOptionalParameters;
1126 1120
1127 void forEachParameter(void function(FormalElement parameter)); 1121 void forEachParameter(void function(FormalElement parameter));
1128 void forEachRequiredParameter(void function(FormalElement parameter)); 1122 void forEachRequiredParameter(void function(FormalElement parameter));
1129 void forEachOptionalParameter(void function(FormalElement parameter)); 1123 void forEachOptionalParameter(void function(FormalElement parameter));
1130 1124
1131 void orderedForEachParameter(void function(FormalElement parameter)); 1125 void orderedForEachParameter(void function(FormalElement parameter));
1132 1126
1133 bool isCompatibleWith(FunctionSignature constructorSignature); 1127 bool isCompatibleWith(FunctionSignature constructorSignature);
1134 } 1128 }
1135 1129
1136 /// A top level, static or instance method, constructor, local function, or 1130 /// A top level, static or instance method, constructor, local function, or
1137 /// closure (anonymous local function). 1131 /// closure (anonymous local function).
1138 abstract class FunctionElement extends Element 1132 abstract class FunctionElement extends Element
1139 implements 1133 implements
1140 AstElement, 1134 AstElement,
1141 TypedElement, 1135 TypedElement,
1142 FunctionTypedElement, 1136 FunctionTypedElement,
1143 ExecutableElement, 1137 ExecutableElement {
1144 GenericElement {
1145 FunctionExpression get node; 1138 FunctionExpression get node;
1146 1139
1147 FunctionElement get patch; 1140 FunctionElement get patch;
1148 FunctionElement get origin; 1141 FunctionElement get origin;
1149 1142
1150 bool get hasFunctionSignature; 1143 bool get hasFunctionSignature;
1151 1144
1152 /// The parameters of this function. 1145 /// The parameters of this functions.
1153 List<ParameterElement> get parameters; 1146 List<ParameterElement> get parameters;
1154 1147
1155 /// The type of this function. 1148 /// The type of this function.
1156 FunctionType get type; 1149 FunctionType get type;
1157 1150
1158 /// The synchronous/asynchronous marker on this function. 1151 /// The synchronous/asynchronous marker on this function.
1159 AsyncMarker get asyncMarker; 1152 AsyncMarker get asyncMarker;
1160 1153
1161 /// `true` if this function is external. 1154 /// `true` if this function is external.
1162 bool get isExternal; 1155 bool get isExternal;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 @deprecated 1315 @deprecated
1323 get enclosingElement; 1316 get enclosingElement;
1324 } 1317 }
1325 1318
1326 /// JavaScript backend specific element for the body of constructor. 1319 /// JavaScript backend specific element for the body of constructor.
1327 // TODO(johnniwinther): Remove this class from the element model. 1320 // TODO(johnniwinther): Remove this class from the element model.
1328 abstract class ConstructorBodyElement extends MethodElement { 1321 abstract class ConstructorBodyElement extends MethodElement {
1329 FunctionElement get constructor; 1322 FunctionElement get constructor;
1330 } 1323 }
1331 1324
1332 /// [GenericElement] defines the common interface for generic functions and
1333 /// [TypeDeclarationElement].
1334 abstract class GenericElement extends Element implements AstElement {
1335 /**
1336 * The type variables declared on this declaration. The type variables are not
1337 * available until the type of the element has been computed through
1338 * [computeType].
1339 */
1340 List<DartType> get typeVariables;
1341 }
1342
1343 /// [TypeDeclarationElement] defines the common interface for class/interface 1325 /// [TypeDeclarationElement] defines the common interface for class/interface
1344 /// declarations and typedefs. 1326 /// declarations and typedefs.
1345 abstract class TypeDeclarationElement extends GenericElement { 1327 abstract class TypeDeclarationElement extends Element implements AstElement {
1346 /// The name of this type declaration, taking privacy into account. 1328 /// The name of this type declaration, taking privacy into account.
1347 Name get memberName; 1329 Name get memberName;
1348 1330
1349 /// Do not use [computeType] outside of the resolver; instead retrieve the 1331 /// Do not use [computeType] outside of the resolver; instead retrieve the
1350 /// type from the [thisType] or [rawType], depending on the use case. 1332 /// type from the [thisType] or [rawType], depending on the use case.
1351 /// 1333 ///
1352 /// Trying to access a type that has not been computed in resolution is an 1334 /// Trying to access a type that has not been computed in resolution is an
1353 /// error and calling [computeType] covers that error. 1335 /// error and calling [computeType] covers that error.
1354 /// This method will go away! 1336 /// This method will go away!
1355 @deprecated 1337 @deprecated
(...skipping 21 matching lines...) Expand all
1377 * The [rawType] field is a canonicalization of the raw type and should be 1359 * The [rawType] field is a canonicalization of the raw type and should be
1378 * used to distinguish explicit and implicit uses of the [dynamic] 1360 * used to distinguish explicit and implicit uses of the [dynamic]
1379 * type arguments. For instance should [:List:] be the [rawType] of the 1361 * type arguments. For instance should [:List:] be the [rawType] of the
1380 * [:List:] class element whereas [:List<dynamic>:] should be its own 1362 * [:List:] class element whereas [:List<dynamic>:] should be its own
1381 * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using 1363 * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using
1382 * this distinction, we can print the raw type with type arguments only when 1364 * this distinction, we can print the raw type with type arguments only when
1383 * the input source has used explicit type arguments. 1365 * the input source has used explicit type arguments.
1384 */ 1366 */
1385 GenericType get rawType; 1367 GenericType get rawType;
1386 1368
1369 /**
1370 * The type variables declared on this declaration. The type variables are not
1371 * available until the type of the element has been computed through
1372 * [computeType].
1373 */
1374 List<DartType> get typeVariables;
1375
1387 bool get isResolved; 1376 bool get isResolved;
1388 1377
1389 void ensureResolved(Resolution resolution); 1378 void ensureResolved(Resolution resolution);
1390 } 1379 }
1391 1380
1392 abstract class ClassElement extends TypeDeclarationElement 1381 abstract class ClassElement extends TypeDeclarationElement
1393 implements ScopeContainerElement { 1382 implements ScopeContainerElement {
1394 /// The length of the longest inheritance path from [:Object:]. 1383 /// The length of the longest inheritance path from [:Object:].
1395 int get hierarchyDepth; 1384 int get hierarchyDepth;
1396 1385
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 /// The [Element] for a type variable declaration on a generic class or typedef. 1562 /// The [Element] for a type variable declaration on a generic class or typedef.
1574 abstract class TypeVariableElement extends Element 1563 abstract class TypeVariableElement extends Element
1575 implements AstElement, TypedElement { 1564 implements AstElement, TypedElement {
1576 /// The name of this type variable, taking privacy into account. 1565 /// The name of this type variable, taking privacy into account.
1577 Name get memberName; 1566 Name get memberName;
1578 1567
1579 /// Use [typeDeclaration] instead. 1568 /// Use [typeDeclaration] instead.
1580 @deprecated 1569 @deprecated
1581 get enclosingElement; 1570 get enclosingElement;
1582 1571
1583 /// The class, typedef, function, method, or function typed parameter on 1572 /// The class or typedef on which this type variable is defined.
1584 /// which this type variable is defined. 1573 TypeDeclarationElement get typeDeclaration;
1585 GenericElement get typeDeclaration;
1586 1574
1587 /// The index of this type variable within its type declaration. 1575 /// The index of this type variable within its type declaration.
1588 int get index; 1576 int get index;
1589 1577
1590 /// The [type] defined by the type variable. 1578 /// The [type] defined by the type variable.
1591 TypeVariableType get type; 1579 TypeVariableType get type;
1592 1580
1593 /// The upper bound on the type variable. If not explicitly declared, this is 1581 /// The upper bound on the type variable. If not explicitly declared, this is
1594 /// `Object`. 1582 /// `Object`.
1595 DartType get bound; 1583 DartType get bound;
(...skipping 21 matching lines...) Expand all
1617 /// Trying to access a type that has not been computed in resolution is an 1605 /// Trying to access a type that has not been computed in resolution is an
1618 /// error and calling [computeType] covers that error. 1606 /// error and calling [computeType] covers that error.
1619 /// This method will go away! 1607 /// This method will go away!
1620 @deprecated 1608 @deprecated
1621 DartType computeType(Resolution resolution); 1609 DartType computeType(Resolution resolution);
1622 1610
1623 DartType get type; 1611 DartType get type;
1624 } 1612 }
1625 1613
1626 /// An [Element] that can define a function type. 1614 /// An [Element] that can define a function type.
1627 abstract class FunctionTypedElement extends Element implements GenericElement { 1615 abstract class FunctionTypedElement extends Element {
1628 /// The function signature for the function type defined by this element, 1616 /// The function signature for the function type defined by this element,
1629 /// if any. 1617 /// if any.
1630 FunctionSignature get functionSignature; 1618 FunctionSignature get functionSignature;
1631 } 1619 }
1632 1620
1633 /// An [Element] that holds a [TreeElements] mapping. 1621 /// An [Element] that holds a [TreeElements] mapping.
1634 abstract class AnalyzableElement extends Element { 1622 abstract class AnalyzableElement extends Element {
1635 /// Return `true` if [treeElements] have been (partially) computed for this 1623 /// Return `true` if [treeElements] have been (partially) computed for this
1636 /// element. 1624 /// element.
1637 bool get hasTreeElements; 1625 bool get hasTreeElements;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 /// by a field. 1801 /// by a field.
1814 bool get isDeclaredByField; 1802 bool get isDeclaredByField;
1815 1803
1816 /// Returns `true` if this member is abstract. 1804 /// Returns `true` if this member is abstract.
1817 bool get isAbstract; 1805 bool get isAbstract;
1818 1806
1819 /// If abstract, [implementation] points to the overridden concrete member, 1807 /// If abstract, [implementation] points to the overridden concrete member,
1820 /// if any. Otherwise [implementation] points to the member itself. 1808 /// if any. Otherwise [implementation] points to the member itself.
1821 Member get implementation; 1809 Member get implementation;
1822 } 1810 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698