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

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

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