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

Side by Side Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 2002353006: Fix some corner cases of inferring type parameters from bounds. (Closed) Base URL: git@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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 */ 307 */
308 typedef LinkedLibrary GetDependencyCallback(String absoluteUri); 308 typedef LinkedLibrary GetDependencyCallback(String absoluteUri);
309 309
310 /** 310 /**
311 * Type of the callback used by [link] and [relink] to request 311 * Type of the callback used by [link] and [relink] to request
312 * [UnlinkedUnit] objects. 312 * [UnlinkedUnit] objects.
313 */ 313 */
314 typedef UnlinkedUnit GetUnitCallback(String absoluteUri); 314 typedef UnlinkedUnit GetUnitCallback(String absoluteUri);
315 315
316 /** 316 /**
317 * Stub implementation of [AnalysisOptions] used during linking.
318 */
319 class AnalysisOptionsForLink implements AnalysisOptions {
320 final Linker _linker;
321
322 AnalysisOptionsForLink(this._linker);
323
324 @override
325 bool get strongMode => _linker.strongMode;
326
327 @override
328 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
329 }
330
331 /**
317 * Element representing a class or enum resynthesized from a summary 332 * Element representing a class or enum resynthesized from a summary
318 * during linking. 333 * during linking.
319 */ 334 */
320 abstract class ClassElementForLink extends Object 335 abstract class ClassElementForLink extends Object
321 with ReferenceableElementForLink 336 with ReferenceableElementForLink
322 implements ClassElementImpl { 337 implements ClassElementImpl {
323 Map<String, ReferenceableElementForLink> _containedNames; 338 Map<String, ReferenceableElementForLink> _containedNames;
324 339
325 @override 340 @override
326 final CompilationUnitElementForLink enclosingElement; 341 final CompilationUnitElementForLink enclosingElement;
(...skipping 12 matching lines...) Expand all
339 ConstructorElementForLink get asConstructor => unnamedConstructor; 354 ConstructorElementForLink get asConstructor => unnamedConstructor;
340 355
341 @override 356 @override
342 DartType get asStaticType => 357 DartType get asStaticType =>
343 enclosingElement.enclosingElement._linker.typeProvider.typeType; 358 enclosingElement.enclosingElement._linker.typeProvider.typeType;
344 359
345 @override 360 @override
346 List<ConstructorElementForLink> get constructors; 361 List<ConstructorElementForLink> get constructors;
347 362
348 @override 363 @override
364 CompilationUnitElementForLink get enclosingUnit => enclosingElement;
365
366 @override
349 List<FieldElementForLink> get fields; 367 List<FieldElementForLink> get fields;
350 368
351 /** 369 /**
352 * Indicates whether this is the core class `Object`. 370 * Indicates whether this is the core class `Object`.
353 */ 371 */
354 bool get isObject; 372 bool get isObject;
355 373
356 @override 374 @override
357 LibraryElementForLink get library => enclosingElement.library; 375 LibraryElementForLink get library => enclosingElement.library;
358 376
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 if (_constructors.isEmpty) { 493 if (_constructors.isEmpty) {
476 _unnamedConstructorComputed = true; 494 _unnamedConstructorComputed = true;
477 _unnamedConstructor = new ConstructorElementForLink_Synthetic(this); 495 _unnamedConstructor = new ConstructorElementForLink_Synthetic(this);
478 _constructors.add(_unnamedConstructor); 496 _constructors.add(_unnamedConstructor);
479 } 497 }
480 } 498 }
481 return _constructors; 499 return _constructors;
482 } 500 }
483 501
484 @override 502 @override
503 ContextForLink get context => enclosingUnit.context;
504
505 @override
485 String get displayName => _unlinkedClass.name; 506 String get displayName => _unlinkedClass.name;
486 507
487 @override 508 @override
488 TypeParameterizedElementMixin get enclosingTypeParameterContext => null; 509 TypeParameterizedElementMixin get enclosingTypeParameterContext => null;
489 510
490 @override 511 @override
491 List<FieldElementForLink_ClassField> get fields { 512 List<FieldElementForLink_ClassField> get fields {
492 if (_fields == null) { 513 if (_fields == null) {
493 _fields = <FieldElementForLink_ClassField>[]; 514 _fields = <FieldElementForLink_ClassField>[];
494 for (UnlinkedVariable field in _unlinkedClass.fields) { 515 for (UnlinkedVariable field in _unlinkedClass.fields) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } 588 }
568 589
569 @override 590 @override
570 DartType buildType( 591 DartType buildType(
571 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { 592 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) {
572 int numTypeParameters = _unlinkedClass.typeParameters.length; 593 int numTypeParameters = _unlinkedClass.typeParameters.length;
573 if (numTypeParameters != 0) { 594 if (numTypeParameters != 0) {
574 return new InterfaceTypeImpl.elementWithNameAndArgs(this, name, () { 595 return new InterfaceTypeImpl.elementWithNameAndArgs(this, name, () {
575 List<DartType> typeArguments = new List<DartType>(numTypeParameters); 596 List<DartType> typeArguments = new List<DartType>(numTypeParameters);
576 for (int i = 0; i < numTypeParameters; i++) { 597 for (int i = 0; i < numTypeParameters; i++) {
577 typeArguments[i] = getTypeArgument(i); 598 typeArguments[i] =
599 getTypeArgument(i) ?? computeDefaultTypeArgument(i);
578 } 600 }
579 return typeArguments; 601 return typeArguments;
580 }); 602 });
581 } else { 603 } else {
582 return _type ??= new InterfaceTypeImpl(this); 604 return _type ??= new InterfaceTypeImpl(this);
583 } 605 }
584 } 606 }
585 607
586 @override 608 @override
587 PropertyAccessorElement getGetter(String getterName) { 609 PropertyAccessorElement getGetter(String getterName) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 _accessors.add(variable.getter); 829 _accessors.add(variable.getter);
808 if (!variable.isConst && !variable.isFinal) { 830 if (!variable.isConst && !variable.isFinal) {
809 _accessors.add(variable.setter); 831 _accessors.add(variable.setter);
810 } 832 }
811 } 833 }
812 } 834 }
813 return _accessors; 835 return _accessors;
814 } 836 }
815 837
816 @override 838 @override
839 ContextForLink get context => library.context;
840
841 @override
817 LibraryElementForLink get enclosingElement; 842 LibraryElementForLink get enclosingElement;
818 843
819 @override 844 @override
820 List<ClassElementForLink_Enum> get enums { 845 List<ClassElementForLink_Enum> get enums {
821 if (_enums == null) { 846 if (_enums == null) {
822 _enums = <ClassElementForLink_Enum>[]; 847 _enums = <ClassElementForLink_Enum>[];
823 for (UnlinkedEnum unlinkedEnum in _unlinkedUnit.enums) { 848 for (UnlinkedEnum unlinkedEnum in _unlinkedUnit.enums) {
824 _enums.add(new ClassElementForLink_Enum(this, unlinkedEnum)); 849 _enums.add(new ClassElementForLink_Enum(this, unlinkedEnum));
825 } 850 }
826 } 851 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 * Compute the type referred to by the given linked type [slot] (interpreted 963 * Compute the type referred to by the given linked type [slot] (interpreted
939 * relative to [typeParameterContext]). If there is no inferred type in the 964 * relative to [typeParameterContext]). If there is no inferred type in the
940 * given slot, `dynamic` is returned. 965 * given slot, `dynamic` is returned.
941 */ 966 */
942 DartType getLinkedType( 967 DartType getLinkedType(
943 int slot, TypeParameterizedElementMixin typeParameterContext); 968 int slot, TypeParameterizedElementMixin typeParameterContext);
944 969
945 @override 970 @override
946 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 971 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
947 972
948 @override
949 DartType resolveTypeRef(
950 EntityRef type, TypeParameterizedElementMixin typeParameterContext,
951 {bool defaultVoid: false, bool instantiateToBoundsAllowed: true}) {
952 if (type == null) {
953 if (defaultVoid) {
954 return VoidTypeImpl.instance;
955 } else {
956 return DynamicTypeImpl.instance;
957 }
958 }
959 if (type.paramReference != 0) {
960 return typeParameterContext.getTypeParameterType(type.paramReference);
961 } else if (type.syntheticReturnType != null) {
962 // TODO(paulberry): implement.
963 throw new UnimplementedError();
964 } else if (type.implicitFunctionTypeIndices.isNotEmpty) {
965 // TODO(paulberry): implement.
966 throw new UnimplementedError();
967 } else {
968 DartType getTypeArgument(int i) {
969 if (i < type.typeArguments.length) {
970 return resolveTypeRef(type.typeArguments[i], typeParameterContext);
971 } else {
972 return DynamicTypeImpl.instance;
973 }
974 }
975 ReferenceableElementForLink element = resolveRef(type.reference);
976 return element.buildType(
977 getTypeArgument, type.implicitFunctionTypeIndices);
978 }
979 }
980
981 /** 973 /**
982 * Return the element referred to by the given [index] in 974 * Return the element referred to by the given [index] in
983 * [UnlinkedUnit.references]. If the reference is unresolved, 975 * [UnlinkedUnit.references]. If the reference is unresolved,
984 * return [UndefinedElementForLink.instance]. 976 * return [UndefinedElementForLink.instance].
985 */ 977 */
986 ReferenceableElementForLink resolveRef(int index) { 978 ReferenceableElementForLink resolveRef(int index) {
987 if (_references[index] == null) { 979 if (_references[index] == null) {
988 UnlinkedReference unlinkedReference = 980 UnlinkedReference unlinkedReference =
989 index < _unlinkedUnit.references.length 981 index < _unlinkedUnit.references.length
990 ? _unlinkedUnit.references[index] 982 ? _unlinkedUnit.references[index]
(...skipping 30 matching lines...) Expand all
1021 } else { 1013 } else {
1022 LibraryElementForLink dependency = 1014 LibraryElementForLink dependency =
1023 enclosingElement._getDependency(linkedReference.dependency); 1015 enclosingElement._getDependency(linkedReference.dependency);
1024 _references[index] = dependency.getContainedName(name); 1016 _references[index] = dependency.getContainedName(name);
1025 } 1017 }
1026 } 1018 }
1027 return _references[index]; 1019 return _references[index];
1028 } 1020 }
1029 1021
1030 @override 1022 @override
1023 DartType resolveTypeRef(
1024 EntityRef type, TypeParameterizedElementMixin typeParameterContext,
1025 {bool defaultVoid: false, bool instantiateToBoundsAllowed: true}) {
1026 if (type == null) {
1027 if (defaultVoid) {
1028 return VoidTypeImpl.instance;
1029 } else {
1030 return DynamicTypeImpl.instance;
1031 }
1032 }
1033 if (type.paramReference != 0) {
1034 return typeParameterContext.getTypeParameterType(type.paramReference);
1035 } else if (type.syntheticReturnType != null) {
1036 // TODO(paulberry): implement.
1037 throw new UnimplementedError();
1038 } else if (type.implicitFunctionTypeIndices.isNotEmpty) {
1039 // TODO(paulberry): implement.
1040 throw new UnimplementedError();
1041 } else {
1042 DartType getTypeArgument(int i) {
1043 if (i < type.typeArguments.length) {
1044 return resolveTypeRef(type.typeArguments[i], typeParameterContext);
1045 } else if (!instantiateToBoundsAllowed) {
1046 // Do not allow buildType to instantiate the bounds; force dynamic.
1047 return DynamicTypeImpl.instance;
1048 } else {
1049 return null;
1050 }
1051 }
1052 ReferenceableElementForLink element = resolveRef(type.reference);
1053 return element.buildType(
1054 getTypeArgument, type.implicitFunctionTypeIndices);
1055 }
1056 }
1057
1058 @override
1031 String toString() => enclosingElement.toString(); 1059 String toString() => enclosingElement.toString();
1032 } 1060 }
1033 1061
1034 /** 1062 /**
1035 * Element representing a compilation unit which is part of the build 1063 * Element representing a compilation unit which is part of the build
1036 * unit being linked. 1064 * unit being linked.
1037 */ 1065 */
1038 class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink { 1066 class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink {
1039 @override 1067 @override
1040 final LinkedUnitBuilder _linkedUnit; 1068 final LinkedUnitBuilder _linkedUnit;
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 /** 1639 /**
1612 * Stub implementation of [AnalysisContext] which provides just those methods 1640 * Stub implementation of [AnalysisContext] which provides just those methods
1613 * needed during linking. 1641 * needed during linking.
1614 */ 1642 */
1615 class ContextForLink implements AnalysisContext { 1643 class ContextForLink implements AnalysisContext {
1616 final Linker _linker; 1644 final Linker _linker;
1617 1645
1618 ContextForLink(this._linker); 1646 ContextForLink(this._linker);
1619 1647
1620 @override 1648 @override
1649 AnalysisOptionsForLink get analysisOptions => _linker.analysisOptions;
1650
1651 @override
1621 TypeSystem get typeSystem => _linker.typeSystem; 1652 TypeSystem get typeSystem => _linker.typeSystem;
1622 1653
1623 @override 1654 @override
1624 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 1655 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
1625 } 1656 }
1626 1657
1627 /** 1658 /**
1628 * An instance of [DependencyWalker] contains the core algorithms for 1659 * An instance of [DependencyWalker] contains the core algorithms for
1629 * walking a dependency graph and evaluating nodes in a safe order. 1660 * walking a dependency graph and evaluating nodes in a safe order.
1630 */ 1661 */
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 DartType _inferredReturnType; 1797 DartType _inferredReturnType;
1767 FunctionTypeImpl _type; 1798 FunctionTypeImpl _type;
1768 String _name; 1799 String _name;
1769 String _displayName; 1800 String _displayName;
1770 1801
1771 @override 1802 @override
1772 final CompilationUnitElementForLink compilationUnit; 1803 final CompilationUnitElementForLink compilationUnit;
1773 1804
1774 ExecutableElementForLink(this.compilationUnit, this._unlinkedExecutable); 1805 ExecutableElementForLink(this.compilationUnit, this._unlinkedExecutable);
1775 1806
1807 @override
1808 ContextForLink get context => compilationUnit.context;
1809
1776 /** 1810 /**
1777 * If the executable element had an explicitly declared return type, return 1811 * If the executable element had an explicitly declared return type, return
1778 * it. Otherwise return `null`. 1812 * it. Otherwise return `null`.
1779 */ 1813 */
1780 DartType get declaredReturnType { 1814 DartType get declaredReturnType {
1781 if (_unlinkedExecutable.returnType == null) { 1815 if (_unlinkedExecutable.returnType == null) {
1782 return null; 1816 return null;
1783 } else { 1817 } else {
1784 return _declaredReturnType ??= 1818 return _declaredReturnType ??=
1785 compilationUnit.resolveTypeRef(_unlinkedExecutable.returnType, this); 1819 compilationUnit.resolveTypeRef(_unlinkedExecutable.returnType, this);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 EntityRef ref = _getNextRef(); 2306 EntityRef ref = _getNextRef();
2273 ConstructorElementForLink element = 2307 ConstructorElementForLink element =
2274 unit.resolveRef(ref.reference).asConstructor; 2308 unit.resolveRef(ref.reference).asConstructor;
2275 if (element != null) { 2309 if (element != null) {
2276 ClassElementForLink_Class enclosingClass = element.enclosingClass; 2310 ClassElementForLink_Class enclosingClass = element.enclosingClass;
2277 stack.add(enclosingClass.buildType((int i) { 2311 stack.add(enclosingClass.buildType((int i) {
2278 // Type argument explicitly specified. 2312 // Type argument explicitly specified.
2279 if (i < ref.typeArguments.length) { 2313 if (i < ref.typeArguments.length) {
2280 return unit.resolveTypeRef( 2314 return unit.resolveTypeRef(
2281 ref.typeArguments[i], variable._typeParameterContext); 2315 ref.typeArguments[i], variable._typeParameterContext);
2316 } else {
2317 return null;
2282 } 2318 }
2283 // In strong mode, type argument defaults to bound (if any).
2284 if (linker.strongMode) {
2285 TypeParameterElement typeParameter = enclosingClass.typeParameters[i];
2286 if (typeParameter.bound != null) {
2287 return typeParameter.bound;
2288 }
2289 }
2290 // Otherwise type argument defaults to `dynamic`.
2291 return DynamicTypeImpl.instance;
2292 }, const [])); 2319 }, const []));
2293 } else { 2320 } else {
2294 stack.add(DynamicTypeImpl.instance); 2321 stack.add(DynamicTypeImpl.instance);
2295 } 2322 }
2296 } 2323 }
2297 2324
2298 void _doInvokeMethod() { 2325 void _doInvokeMethod() {
2299 int numNamed = unlinkedConst.ints[intPtr++]; 2326 int numNamed = unlinkedConst.ints[intPtr++];
2300 int numPositional = unlinkedConst.ints[intPtr++]; 2327 int numPositional = unlinkedConst.ints[intPtr++];
2301 List<String> namedArgNames = _getNextStrings(numNamed); 2328 List<String> namedArgNames = _getNextStrings(numNamed);
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2855 DartType _returnType; 2882 DartType _returnType;
2856 2883
2857 FunctionTypeAliasElementForLink(this.enclosingElement, this._unlinkedTypedef); 2884 FunctionTypeAliasElementForLink(this.enclosingElement, this._unlinkedTypedef);
2858 2885
2859 @override 2886 @override
2860 DartType get asStaticType { 2887 DartType get asStaticType {
2861 return enclosingElement.enclosingElement._linker.typeProvider.typeType; 2888 return enclosingElement.enclosingElement._linker.typeProvider.typeType;
2862 } 2889 }
2863 2890
2864 @override 2891 @override
2892 ContextForLink get context => enclosingElement.context;
2893
2894 @override
2865 TypeParameterizedElementMixin get enclosingTypeParameterContext => null; 2895 TypeParameterizedElementMixin get enclosingTypeParameterContext => null;
2866 2896
2867 @override 2897 @override
2868 CompilationUnitElementInBuildUnit get enclosingUnit => enclosingElement; 2898 CompilationUnitElementInBuildUnit get enclosingUnit => enclosingElement;
2869 2899
2870 @override 2900 @override
2871 String get identifier => _unlinkedTypedef.name; 2901 String get identifier => _unlinkedTypedef.name;
2872 2902
2873 @override 2903 @override
2874 List<int> get implicitFunctionTypeIndices => const <int>[]; 2904 List<int> get implicitFunctionTypeIndices => const <int>[];
(...skipping 21 matching lines...) Expand all
2896 List<UnlinkedTypeParam> get unlinkedTypeParams => 2926 List<UnlinkedTypeParam> get unlinkedTypeParams =>
2897 _unlinkedTypedef.typeParameters; 2927 _unlinkedTypedef.typeParameters;
2898 2928
2899 @override 2929 @override
2900 DartType buildType( 2930 DartType buildType(
2901 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { 2931 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) {
2902 int numTypeParameters = _unlinkedTypedef.typeParameters.length; 2932 int numTypeParameters = _unlinkedTypedef.typeParameters.length;
2903 if (numTypeParameters != 0) { 2933 if (numTypeParameters != 0) {
2904 List<DartType> typeArguments = new List<DartType>(numTypeParameters); 2934 List<DartType> typeArguments = new List<DartType>(numTypeParameters);
2905 for (int i = 0; i < numTypeParameters; i++) { 2935 for (int i = 0; i < numTypeParameters; i++) {
2906 typeArguments[i] = getTypeArgument(i); 2936 typeArguments[i] = getTypeArgument(i) ?? computeDefaultTypeArgument(i);
2907 } 2937 }
2908 return new FunctionTypeImpl.elementWithNameAndArgs( 2938 return new FunctionTypeImpl.elementWithNameAndArgs(
2909 this, name, typeArguments, true); 2939 this, name, typeArguments, true);
2910 } else { 2940 } else {
2911 return _type ??= new FunctionTypeImpl.forTypedef(this); 2941 return _type ??= new FunctionTypeImpl.forTypedef(this);
2912 } 2942 }
2913 } 2943 }
2914 2944
2915 @override 2945 @override
2916 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 2946 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
3362 final bool strongMode; 3392 final bool strongMode;
3363 3393
3364 LibraryElementForLink _coreLibrary; 3394 LibraryElementForLink _coreLibrary;
3365 LibraryElementForLink _asyncLibrary; 3395 LibraryElementForLink _asyncLibrary;
3366 TypeProviderForLink _typeProvider; 3396 TypeProviderForLink _typeProvider;
3367 TypeSystem _typeSystem; 3397 TypeSystem _typeSystem;
3368 SpecialTypeElementForLink _voidElement; 3398 SpecialTypeElementForLink _voidElement;
3369 SpecialTypeElementForLink _dynamicElement; 3399 SpecialTypeElementForLink _dynamicElement;
3370 SpecialTypeElementForLink _bottomElement; 3400 SpecialTypeElementForLink _bottomElement;
3371 ContextForLink _context; 3401 ContextForLink _context;
3402 AnalysisOptionsForLink _analysisOptions;
3372 3403
3373 Linker(Map<String, LinkedLibraryBuilder> linkedLibraries, this.getDependency, 3404 Linker(Map<String, LinkedLibraryBuilder> linkedLibraries, this.getDependency,
3374 this.getUnit, this.strongMode) { 3405 this.getUnit, this.strongMode) {
3375 // Create elements for the libraries to be linked. The rest of 3406 // Create elements for the libraries to be linked. The rest of
3376 // the element model will be created on demand. 3407 // the element model will be created on demand.
3377 linkedLibraries 3408 linkedLibraries
3378 .forEach((String absoluteUri, LinkedLibraryBuilder linkedLibrary) { 3409 .forEach((String absoluteUri, LinkedLibraryBuilder linkedLibrary) {
3379 Uri uri = Uri.parse(absoluteUri); 3410 Uri uri = Uri.parse(absoluteUri);
3380 _librariesInBuildUnit.add(_libraries[uri] = 3411 _librariesInBuildUnit.add(_libraries[uri] =
3381 new LibraryElementInBuildUnit(this, uri, linkedLibrary)); 3412 new LibraryElementInBuildUnit(this, uri, linkedLibrary));
3382 }); 3413 });
3383 } 3414 }
3384 3415
3385 /** 3416 /**
3417 * Get an instance of [AnalysisOptions] for use during linking.
3418 */
3419 AnalysisOptionsForLink get analysisOptions =>
3420 _analysisOptions ??= new AnalysisOptionsForLink(this);
3421
3422 /**
3386 * Get the library element for `dart:async`. 3423 * Get the library element for `dart:async`.
3387 */ 3424 */
3388 LibraryElementForLink get asyncLibrary => 3425 LibraryElementForLink get asyncLibrary =>
3389 _asyncLibrary ??= getLibrary(Uri.parse('dart:async')); 3426 _asyncLibrary ??= getLibrary(Uri.parse('dart:async'));
3390 3427
3391 /** 3428 /**
3392 * Get the element representing the "bottom" type. 3429 * Get the element representing the "bottom" type.
3393 */ 3430 */
3394 SpecialTypeElementForLink get bottomElement => _bottomElement ??= 3431 SpecialTypeElementForLink get bottomElement => _bottomElement ??=
3395 new SpecialTypeElementForLink(this, BottomTypeImpl.instance); 3432 new SpecialTypeElementForLink(this, BottomTypeImpl.instance);
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 * If this element can be used in a getter context as a type inference 4126 * If this element can be used in a getter context as a type inference
4090 * dependency, return the [TypeInferenceNode] for the inferred type. 4127 * dependency, return the [TypeInferenceNode] for the inferred type.
4091 * Otherwise return `null`. 4128 * Otherwise return `null`.
4092 */ 4129 */
4093 TypeInferenceNode get asTypeInferenceNode => null; 4130 TypeInferenceNode get asTypeInferenceNode => null;
4094 4131
4095 /** 4132 /**
4096 * Return the type indicated by this element when it is used in a 4133 * Return the type indicated by this element when it is used in a
4097 * type instantiation context. If this element can't legally be 4134 * type instantiation context. If this element can't legally be
4098 * instantiated as a type, return the dynamic type. 4135 * instantiated as a type, return the dynamic type.
4136 *
4137 * If the type is parameterized, [getTypeArgument] will be called to retrieve
4138 * the type parameters. It should return `null` for unspecified type
4139 * parameters.
4099 */ 4140 */
4100 DartType buildType(DartType getTypeArgument(int i), 4141 DartType buildType(DartType getTypeArgument(int i),
4101 List<int> implicitFunctionTypeIndices) => 4142 List<int> implicitFunctionTypeIndices) =>
4102 DynamicTypeImpl.instance; 4143 DynamicTypeImpl.instance;
4103 4144
4104 /** 4145 /**
4105 * If this element contains other named elements, return the 4146 * If this element contains other named elements, return the
4106 * contained element having the given [name]. If this element can't 4147 * contained element having the given [name]. If this element can't
4107 * contain other named elements, or it doesn't contain an element 4148 * contain other named elements, or it doesn't contain an element
4108 * with the given name, return the singleton of 4149 * with the given name, return the singleton of
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
4662 * there are no type parameters in scope. 4703 * there are no type parameters in scope.
4663 */ 4704 */
4664 TypeParameterizedElementMixin get _typeParameterContext; 4705 TypeParameterizedElementMixin get _typeParameterContext;
4665 4706
4666 @override 4707 @override
4667 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 4708 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
4668 4709
4669 @override 4710 @override
4670 String toString() => '$enclosingElement.$name'; 4711 String toString() => '$enclosingElement.$name';
4671 } 4712 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698