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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.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: 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 ClassScope, LibraryScope, Scope, TypeDeclarationScope; 18 show
19 ClassScope,
20 LibraryScope,
21 Scope,
22 TypeDeclarationScope;
19 import '../resolution/resolution.dart' show AnalyzableElementX; 23 import '../resolution/resolution.dart' show AnalyzableElementX;
20 import '../resolution/tree_elements.dart' show TreeElements; 24 import '../resolution/tree_elements.dart' show TreeElements;
21 import '../resolution/typedefs.dart' show TypedefCyclicVisitor; 25 import '../resolution/typedefs.dart' show TypedefCyclicVisitor;
22 import '../script.dart'; 26 import '../script.dart';
23 import '../tokens/token.dart' show ErrorToken, Token; 27 import '../tokens/token.dart' show ErrorToken, Token;
24 import '../tokens/token_constants.dart' as Tokens show EOF_TOKEN; 28 import '../tokens/token_constants.dart' as Tokens show EOF_TOKEN;
25 import '../tree/tree.dart'; 29 import '../tree/tree.dart';
26 import '../util/util.dart'; 30 import '../util/util.dart';
27 31
28 import 'common.dart'; 32 import 'common.dart';
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return visitor.visitErroneousElement(this, arg); 285 return visitor.visitErroneousElement(this, arg);
282 } 286 }
283 287
284 @override 288 @override
285 get isEffectiveTargetMalformed { 289 get isEffectiveTargetMalformed {
286 throw new UnsupportedError("isEffectiveTargetMalformed"); 290 throw new UnsupportedError("isEffectiveTargetMalformed");
287 } 291 }
288 292
289 @override 293 @override
290 bool get isFromEnvironmentConstructor => false; 294 bool get isFromEnvironmentConstructor => false;
295
296 @override
297 List<DartType> get typeVariables => unsupported();
291 } 298 }
292 299
293 /// A constructor that was synthesized to recover from a compile-time error. 300 /// A constructor that was synthesized to recover from a compile-time error.
294 class ErroneousConstructorElementX extends ErroneousElementX 301 class ErroneousConstructorElementX extends ErroneousElementX
295 with 302 with
296 PatchMixin<FunctionElement>, 303 PatchMixin<FunctionElement>,
297 AnalyzableElementX, 304 AnalyzableElementX,
298 ConstantConstructorMixin 305 ConstantConstructorMixin
299 implements ConstructorElementX { 306 implements ConstructorElementX {
300 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should 307 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 } 1663 }
1657 1664
1658 /// [Element] for a parameter-like element. 1665 /// [Element] for a parameter-like element.
1659 class FormalElementX extends ElementX 1666 class FormalElementX extends ElementX
1660 with AstElementMixin 1667 with AstElementMixin
1661 implements FormalElement { 1668 implements FormalElement {
1662 final VariableDefinitions definitions; 1669 final VariableDefinitions definitions;
1663 final Identifier identifier; 1670 final Identifier identifier;
1664 DartType typeCache; 1671 DartType typeCache;
1665 1672
1673 @override
1674 List<DartType> get typeVariables => functionSignature.typeVariables;
1675
1666 /** 1676 /**
1667 * Function signature for a variable with a function type. The signature is 1677 * Function signature for a variable with a function type. The signature is
1668 * kept to provide full information about parameter names through the mirror 1678 * kept to provide full information about parameter names through the mirror
1669 * system. 1679 * system.
1670 */ 1680 */
1671 FunctionSignature _functionSignatureCache; 1681 FunctionSignature _functionSignatureCache;
1672 1682
1673 FormalElementX(ElementKind elementKind, FunctionTypedElement enclosingElement, 1683 FormalElementX(ElementKind elementKind, FunctionTypedElement enclosingElement,
1674 this.definitions, Identifier identifier) 1684 this.definitions, Identifier identifier)
1675 : this.identifier = identifier, 1685 : this.identifier = identifier,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 return getter != null && getter.isAbstract || 1895 return getter != null && getter.isAbstract ||
1886 setter != null && setter.isAbstract; 1896 setter != null && setter.isAbstract;
1887 } 1897 }
1888 } 1898 }
1889 1899
1890 // TODO(johnniwinther): [FunctionSignature] should be merged with 1900 // TODO(johnniwinther): [FunctionSignature] should be merged with
1891 // [FunctionType]. 1901 // [FunctionType].
1892 // TODO(karlklose): all these lists should have element type [FormalElement]. 1902 // TODO(karlklose): all these lists should have element type [FormalElement].
1893 class FunctionSignatureX extends FunctionSignatureCommon 1903 class FunctionSignatureX extends FunctionSignatureCommon
1894 implements FunctionSignature { 1904 implements FunctionSignature {
1905 final List<DartType> typeVariables;
1895 final List<Element> requiredParameters; 1906 final List<Element> requiredParameters;
1896 final List<Element> optionalParameters; 1907 final List<Element> optionalParameters;
1897 final int requiredParameterCount; 1908 final int requiredParameterCount;
1898 final int optionalParameterCount; 1909 final int optionalParameterCount;
1899 final bool optionalParametersAreNamed; 1910 final bool optionalParametersAreNamed;
1900 final List<Element> orderedOptionalParameters; 1911 final List<Element> orderedOptionalParameters;
1901 final FunctionType type; 1912 final FunctionType type;
1902 final bool hasOptionalParameters; 1913 final bool hasOptionalParameters;
1903 1914
1904 FunctionSignatureX( 1915 FunctionSignatureX(
1905 {this.requiredParameters: const <Element>[], 1916 {this.typeVariables: const <DartType>[],
1917 this.requiredParameters: const <Element>[],
1906 this.requiredParameterCount: 0, 1918 this.requiredParameterCount: 0,
1907 List<Element> optionalParameters: const <Element>[], 1919 List<Element> optionalParameters: const <Element>[],
1908 this.optionalParameterCount: 0, 1920 this.optionalParameterCount: 0,
1909 this.optionalParametersAreNamed: false, 1921 this.optionalParametersAreNamed: false,
1910 this.orderedOptionalParameters: const <Element>[], 1922 this.orderedOptionalParameters: const <Element>[],
1911 this.type}) 1923 this.type})
1912 : optionalParameters = optionalParameters, 1924 : optionalParameters = optionalParameters,
1913 hasOptionalParameters = !optionalParameters.isEmpty; 1925 hasOptionalParameters = !optionalParameters.isEmpty;
1914 } 1926 }
1915 1927
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 } 1988 }
1977 1989
1978 FunctionType get type { 1990 FunctionType get type {
1979 assert(invariant(this, typeCache != null, 1991 assert(invariant(this, typeCache != null,
1980 message: "Type has not been computed for $this.")); 1992 message: "Type has not been computed for $this."));
1981 return typeCache; 1993 return typeCache;
1982 } 1994 }
1983 1995
1984 FunctionElement asFunctionElement() => this; 1996 FunctionElement asFunctionElement() => this;
1985 1997
1998 @override
1999 Scope buildScope() => new TypeDeclarationScope(super.buildScope(), this);
2000
1986 String toString() { 2001 String toString() {
1987 if (isPatch) { 2002 if (isPatch) {
1988 return 'patch ${super.toString()}'; 2003 return 'patch ${super.toString()}';
1989 } else if (isPatched) { 2004 } else if (isPatched) {
1990 return 'origin ${super.toString()}'; 2005 return 'origin ${super.toString()}';
1991 } else { 2006 } else {
1992 return super.toString(); 2007 return super.toString();
1993 } 2008 }
1994 } 2009 }
1995 2010
1996 bool get isAbstract => false; 2011 bool get isAbstract => false;
1997 2012
1998 // A function is defined by the implementation element. 2013 // A function is defined by the implementation element.
1999 AstElement get definingElement => implementation; 2014 AstElement get definingElement => implementation;
2015
2016 @override
2017 List<DartType> get typeVariables => functionSignature.typeVariables;
2000 } 2018 }
2001 2019
2002 abstract class FunctionElementX extends BaseFunctionElementX 2020 abstract class FunctionElementX extends BaseFunctionElementX
2003 with AnalyzableElementX 2021 with AnalyzableElementX
2004 implements MethodElement { 2022 implements MethodElement {
2005 FunctionElementX( 2023 FunctionElementX(
2006 String name, ElementKind kind, Modifiers modifiers, Element enclosing) 2024 String name, ElementKind kind, Modifiers modifiers, Element enclosing)
2007 : super(name, kind, modifiers, enclosing); 2025 : super(name, kind, modifiers, enclosing);
2008 2026
2009 MemberElement get memberContext => this; 2027 MemberElement get memberContext => this;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 } 2165 }
2148 } 2166 }
2149 2167
2150 bool get isFromEnvironmentConstructor { 2168 bool get isFromEnvironmentConstructor {
2151 return name == 'fromEnvironment' && 2169 return name == 'fromEnvironment' &&
2152 library.isDartCore && 2170 library.isDartCore &&
2153 (enclosingClass.name == 'bool' || 2171 (enclosingClass.name == 'bool' ||
2154 enclosingClass.name == 'int' || 2172 enclosingClass.name == 'int' ||
2155 enclosingClass.name == 'String'); 2173 enclosingClass.name == 'String');
2156 } 2174 }
2175
2176 /// Returns the empty list of type variables by default.
2177 @override
2178 List<DartType> get typeVariables => functionSignature.typeVariables;
2157 } 2179 }
2158 2180
2159 abstract class ConstructorElementX extends FunctionElementX 2181 abstract class ConstructorElementX extends FunctionElementX
2160 with ConstantConstructorMixin 2182 with ConstantConstructorMixin
2161 implements ConstructorElement { 2183 implements ConstructorElement {
2162 bool isRedirectingGenerative = false; 2184 bool isRedirectingGenerative = false;
2163 2185
2164 ConstructorElementX( 2186 ConstructorElementX(
2165 String name, ElementKind kind, Modifiers modifiers, Element enclosing) 2187 String name, ElementKind kind, Modifiers modifiers, Element enclosing)
2166 : super(name, kind, modifiers, enclosing); 2188 : super(name, kind, modifiers, enclosing);
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 3129
3108 class TypeVariableElementX extends ElementX 3130 class TypeVariableElementX extends ElementX
3109 with AstElementMixin 3131 with AstElementMixin
3110 implements TypeVariableElement { 3132 implements TypeVariableElement {
3111 final int index; 3133 final int index;
3112 final Node node; 3134 final Node node;
3113 TypeVariableType typeCache; 3135 TypeVariableType typeCache;
3114 DartType boundCache; 3136 DartType boundCache;
3115 3137
3116 TypeVariableElementX( 3138 TypeVariableElementX(
3117 String name, TypeDeclarationElement enclosing, this.index, this.node) 3139 String name, GenericElement enclosing, this.index, this.node)
3118 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 3140 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
3119 3141
3120 TypeDeclarationElement get typeDeclaration => enclosingElement; 3142 GenericElement get typeDeclaration => enclosingElement;
3121 3143
3122 TypeVariableType computeType(Resolution resolution) => type; 3144 TypeVariableType computeType(Resolution resolution) => type;
3123 3145
3124 TypeVariableType get type { 3146 TypeVariableType get type {
3125 assert(invariant(this, typeCache != null, 3147 assert(invariant(this, typeCache != null,
3126 message: "Type has not been set on $this.")); 3148 message: "Type has not been set on $this."));
3127 return typeCache; 3149 return typeCache;
3128 } 3150 }
3129 3151
3130 DartType get bound { 3152 DartType get bound {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 if (definingElement.isField) { 3296 if (definingElement.isField) {
3275 FieldElement field = definingElement; 3297 FieldElement field = definingElement;
3276 body = field.initializer; 3298 body = field.initializer;
3277 } else if (node != null && node.asFunctionExpression() != null) { 3299 } else if (node != null && node.asFunctionExpression() != null) {
3278 body = node.asFunctionExpression().body; 3300 body = node.asFunctionExpression().body;
3279 } 3301 }
3280 return new ParsedResolvedAst( 3302 return new ParsedResolvedAst(
3281 declaration, node, body, definingElement.treeElements); 3303 declaration, node, body, definingElement.treeElements);
3282 } 3304 }
3283 } 3305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698