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

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

Issue 2014893004: In AST-based type inference, use function elements rather than variable elements. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 compilationUnit._storeLinkedType( 1965 compilationUnit._storeLinkedType(
1966 _unlinkedExecutable.inferredReturnTypeSlot, inferredReturnType, this); 1966 _unlinkedExecutable.inferredReturnTypeSlot, inferredReturnType, this);
1967 } 1967 }
1968 for (ParameterElementForLink parameterElement in parameters) { 1968 for (ParameterElementForLink parameterElement in parameters) {
1969 parameterElement.link(compilationUnit); 1969 parameterElement.link(compilationUnit);
1970 } 1970 }
1971 } 1971 }
1972 } 1972 }
1973 1973
1974 class ExprTypeComputer { 1974 class ExprTypeComputer {
1975 VariableElementForLink variable; 1975 final FunctionElementForLink_Local function;
1976 FunctionElementForLink_Initializer initializer; 1976 final CompilationUnitElementForLink unit;
1977 CompilationUnitElementForLink unit; 1977 final LibraryElementForLink library;
1978 LibraryElementForLink library; 1978 final Linker linker;
1979 Linker linker; 1979 final TypeProvider typeProvider;
1980 TypeProvider typeProvider; 1980 final UnlinkedConst unlinkedConst;
1981 UnlinkedConst unlinkedConst;
1982 1981
1983 final List<DartType> stack = <DartType>[]; 1982 final List<DartType> stack = <DartType>[];
1984 int intPtr = 0; 1983 int intPtr = 0;
1985 int refPtr = 0; 1984 int refPtr = 0;
1986 int strPtr = 0; 1985 int strPtr = 0;
1987 int assignmentOperatorPtr = 0; 1986 int assignmentOperatorPtr = 0;
1988 1987
1989 ExprTypeComputer(VariableElementForLink variableElement) { 1988 factory ExprTypeComputer(FunctionElementForLink_Local functionElement) {
1990 this.variable = variableElement; 1989 CompilationUnitElementForLink unit = functionElement.compilationUnit;
1991 initializer = variableElement.initializer; 1990 LibraryElementForLink library = unit.enclosingElement;
1992 unit = variableElement.compilationUnit; 1991 Linker linker = library._linker;
1993 library = unit.enclosingElement; 1992 TypeProvider typeProvider = linker.typeProvider;
1994 linker = library._linker; 1993 UnlinkedConst unlinkedConst = functionElement._unlinkedExecutable.bodyExpr;
1995 typeProvider = linker.typeProvider; 1994 return new ExprTypeComputer._(
1996 unlinkedConst = variableElement.unlinkedVariable.initializer?.bodyExpr; 1995 functionElement, unit, library, linker, typeProvider, unlinkedConst);
1997 } 1996 }
1998 1997
1998 ExprTypeComputer._(this.function, this.unit, this.library, this.linker,
1999 this.typeProvider, this.unlinkedConst);
2000
1999 DartType compute() { 2001 DartType compute() {
2002 if (unlinkedConst == null) {
2003 // No function body was stored for this function, so we can't infer its
2004 // return type. Assume `dynamic`.
2005 return DynamicTypeImpl.instance;
2006 }
2000 // Perform RPN evaluation of the constant, using a stack of inferred types. 2007 // Perform RPN evaluation of the constant, using a stack of inferred types.
2001 for (UnlinkedConstOperation operation in unlinkedConst.operations) { 2008 for (UnlinkedConstOperation operation in unlinkedConst.operations) {
2002 switch (operation) { 2009 switch (operation) {
2003 case UnlinkedConstOperation.pushInt: 2010 case UnlinkedConstOperation.pushInt:
2004 intPtr++; 2011 intPtr++;
2005 stack.add(typeProvider.intType); 2012 stack.add(typeProvider.intType);
2006 break; 2013 break;
2007 case UnlinkedConstOperation.pushLongInt: 2014 case UnlinkedConstOperation.pushLongInt:
2008 int numInts = _getNextInt(); 2015 int numInts = _getNextInt();
2009 intPtr += numInts; 2016 intPtr += numInts;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 refPtr++; 2158 refPtr++;
2152 stack.add(typeProvider.boolType); 2159 stack.add(typeProvider.boolType);
2153 break; 2160 break;
2154 case UnlinkedConstOperation.throwException: 2161 case UnlinkedConstOperation.throwException:
2155 stack.removeLast(); 2162 stack.removeLast();
2156 stack.add(BottomTypeImpl.instance); 2163 stack.add(BottomTypeImpl.instance);
2157 break; 2164 break;
2158 case UnlinkedConstOperation.pushLocalFunctionReference: 2165 case UnlinkedConstOperation.pushLocalFunctionReference:
2159 int popCount = _getNextInt(); 2166 int popCount = _getNextInt();
2160 assert(popCount == 0); // TODO(paulberry): handle the nonzero case. 2167 assert(popCount == 0); // TODO(paulberry): handle the nonzero case.
2161 stack.add(initializer.functions[_getNextInt()].type); 2168 stack.add(function.functions[_getNextInt()].type);
2162 break; 2169 break;
2163 default: 2170 default:
2164 // TODO(paulberry): implement. 2171 // TODO(paulberry): implement.
2165 throw new UnimplementedError('$operation'); 2172 throw new UnimplementedError('$operation');
2166 } 2173 }
2167 } 2174 }
2168 assert(intPtr == unlinkedConst.ints.length); 2175 assert(intPtr == unlinkedConst.ints.length);
2169 assert(refPtr == unlinkedConst.references.length); 2176 assert(refPtr == unlinkedConst.references.length);
2170 assert(strPtr == unlinkedConst.strings.length); 2177 assert(strPtr == unlinkedConst.strings.length);
2171 assert(assignmentOperatorPtr == unlinkedConst.assignmentOperators.length); 2178 assert(assignmentOperatorPtr == unlinkedConst.assignmentOperators.length);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 strPtr += numNamed; 2315 strPtr += numNamed;
2309 EntityRef ref = _getNextRef(); 2316 EntityRef ref = _getNextRef();
2310 ConstructorElementForLink element = 2317 ConstructorElementForLink element =
2311 unit.resolveRef(ref.reference).asConstructor; 2318 unit.resolveRef(ref.reference).asConstructor;
2312 if (element != null) { 2319 if (element != null) {
2313 ClassElementForLink_Class enclosingClass = element.enclosingClass; 2320 ClassElementForLink_Class enclosingClass = element.enclosingClass;
2314 stack.add(enclosingClass.buildType((int i) { 2321 stack.add(enclosingClass.buildType((int i) {
2315 // Type argument explicitly specified. 2322 // Type argument explicitly specified.
2316 if (i < ref.typeArguments.length) { 2323 if (i < ref.typeArguments.length) {
2317 return unit.resolveTypeRef( 2324 return unit.resolveTypeRef(
2318 ref.typeArguments[i], variable._typeParameterContext); 2325 ref.typeArguments[i], function.typeParameterContext);
2319 } else { 2326 } else {
2320 return null; 2327 return null;
2321 } 2328 }
2322 }, const [])); 2329 }, const []));
2323 } else { 2330 } else {
2324 stack.add(DynamicTypeImpl.instance); 2331 stack.add(DynamicTypeImpl.instance);
2325 } 2332 }
2326 } 2333 }
2327 2334
2328 void _doInvokeMethod() { 2335 void _doInvokeMethod() {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 List<String> _getNextStrings(int n) { 2448 List<String> _getNextStrings(int n) {
2442 List<String> result = new List<String>(n); 2449 List<String> result = new List<String>(n);
2443 for (int i = 0; i < n; i++) { 2450 for (int i = 0; i < n; i++) {
2444 result[i] = _getNextString(); 2451 result[i] = _getNextString();
2445 } 2452 }
2446 return result; 2453 return result;
2447 } 2454 }
2448 2455
2449 DartType _getNextTypeRef() { 2456 DartType _getNextTypeRef() {
2450 EntityRef ref = _getNextRef(); 2457 EntityRef ref = _getNextRef();
2451 return unit.resolveTypeRef(ref, variable._typeParameterContext); 2458 return unit.resolveTypeRef(ref, function.typeParameterContext);
2452 } 2459 }
2453 2460
2454 /** 2461 /**
2455 * Return the type of the property with the given [propertyName] in the 2462 * Return the type of the property with the given [propertyName] in the
2456 * given [targetType]. May return `dynamic` if the property cannot be 2463 * given [targetType]. May return `dynamic` if the property cannot be
2457 * resolved. 2464 * resolved.
2458 */ 2465 */
2459 DartType _getPropertyType(DartType targetType, String propertyName) { 2466 DartType _getPropertyType(DartType targetType, String propertyName) {
2460 return targetType is InterfaceType 2467 return targetType is InterfaceType
2461 ? targetType 2468 ? targetType
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 List<TypeParameterElement> get typeParameters => const []; 2758 List<TypeParameterElement> get typeParameters => const [];
2752 2759
2753 @override 2760 @override
2754 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 2761 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
2755 } 2762 }
2756 2763
2757 /** 2764 /**
2758 * Element representing the initializer expression of a variable. 2765 * Element representing the initializer expression of a variable.
2759 */ 2766 */
2760 class FunctionElementForLink_Initializer extends Object 2767 class FunctionElementForLink_Initializer extends Object
2761 with ReferenceableElementForLink 2768 with ReferenceableElementForLink, TypeParameterizedElementMixin
2762 implements FunctionElementForLink_Local { 2769 implements FunctionElementForLink_Local {
2763 /** 2770 /**
2764 * The variable for which this element is the initializer. 2771 * The variable for which this element is the initializer.
2765 */ 2772 */
2766 final VariableElementForLink _variable; 2773 final VariableElementForLink _variable;
2767 2774
2768 List<FunctionElementForLink_Local_NonSynthetic> _functions; 2775 List<FunctionElementForLink_Local_NonSynthetic> _functions;
2769 2776
2770 FunctionElementForLink_Initializer(this._variable); 2777 FunctionElementForLink_Initializer(this._variable);
2771 2778
2772 @override 2779 @override
2780 CompilationUnitElementForLink get compilationUnit =>
2781 _variable.compilationUnit;
2782
2783 @override
2773 VariableElementForLink get enclosingElement => _variable; 2784 VariableElementForLink get enclosingElement => _variable;
2774 2785
2775 TypeParameterizedElementMixin get enclosingTypeParameterContext => 2786 TypeParameterizedElementMixin get enclosingTypeParameterContext =>
2776 _variable.enclosingElement is ClassElementForLink 2787 _variable.enclosingElement is ClassElementForLink
2777 ? _variable.enclosingElement 2788 ? _variable.enclosingElement
2778 : null; 2789 : null;
2779 2790
2780 @override 2791 @override
2792 CompilationUnitElementForLink get enclosingUnit => _variable.compilationUnit;
2793
2794 @override
2781 List<FunctionElementForLink_Local_NonSynthetic> get functions => 2795 List<FunctionElementForLink_Local_NonSynthetic> get functions =>
2782 _functions ??= _variable.unlinkedVariable.initializer.localFunctions 2796 _functions ??= _variable.unlinkedVariable.initializer.localFunctions
2783 .map((UnlinkedExecutable ex) => 2797 .map((UnlinkedExecutable ex) =>
2784 new FunctionElementForLink_Local_NonSynthetic( 2798 new FunctionElementForLink_Local_NonSynthetic(
2785 _variable.compilationUnit, this, ex)) 2799 _variable.compilationUnit, this, ex))
2786 .toList(); 2800 .toList();
2787 2801
2788 @override 2802 @override
2789 DartType get returnType { 2803 DartType get returnType {
2790 // If this is a variable whose type needs inferring, infer it. 2804 // If this is a variable whose type needs inferring, infer it.
2791 if (_variable.hasImplicitType) { 2805 if (_variable.hasImplicitType) {
2792 return _variable.inferredType; 2806 return _variable.inferredType;
2793 } else { 2807 } else {
2794 // There's no reason linking should need to access the type of 2808 // There's no reason linking should need to access the type of
2795 // this FunctionElement, since the variable doesn't need its 2809 // this FunctionElement, since the variable doesn't need its
2796 // type inferred. 2810 // type inferred.
2797 assert(false); 2811 assert(false);
2798 // But for robustness, return the dynamic type. 2812 // But for robustness, return the dynamic type.
2799 return DynamicTypeImpl.instance; 2813 return DynamicTypeImpl.instance;
2800 } 2814 }
2801 } 2815 }
2802 2816
2803 @override 2817 @override
2804 void set returnType(DartType newType) { 2818 void set returnType(DartType newType) {
2805 // InstanceMemberInferrer stores the new type both here and on the variable 2819 // InstanceMemberInferrer stores the new type both here and on the variable
2806 // element. We don't need to record both values, so we ignore it here. 2820 // element. We don't need to record both values, so we ignore it here.
2807 } 2821 }
2808 2822
2809 @override 2823 @override
2810 int get typeParameterNestingLevel => 2824 TypeParameterizedElementMixin get typeParameterContext => this;
2811 enclosingTypeParameterContext?.typeParameterNestingLevel ?? 0;
2812 2825
2813 List<TypeParameterElement> get typeParameters => const []; 2826 @override
2827 List<UnlinkedTypeParam> get unlinkedTypeParams => const [];
2828
2829 @override
2830 bool get _hasTypeBeenInferred => _variable._inferredType != null;
2831
2832 @override
2833 UnlinkedExecutable get _unlinkedExecutable =>
2834 _variable.unlinkedVariable.initializer;
2814 2835
2815 @override 2836 @override
2816 FunctionElementForLink_Local getLocalFunction(int index) { 2837 FunctionElementForLink_Local getLocalFunction(int index) {
2817 List<FunctionElementForLink_Local_NonSynthetic> functions = this.functions; 2838 List<FunctionElementForLink_Local_NonSynthetic> functions = this.functions;
2818 return index < functions.length ? functions[index] : null; 2839 return index < functions.length ? functions[index] : null;
2819 } 2840 }
2820 2841
2821 @override 2842 @override
2822 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 2843 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
2844
2845 @override
2846 void _setInferredType(DartType type) {
2847 assert(!_hasTypeBeenInferred);
2848 _variable._inferredType = type;
2849 }
2823 } 2850 }
2824 2851
2825 /** 2852 /**
2826 * Element representing a local function (possibly a closure). 2853 * Element representing a local function (possibly a closure).
2827 */ 2854 */
2828 abstract class FunctionElementForLink_Local 2855 abstract class FunctionElementForLink_Local
2829 implements 2856 implements
2830 ExecutableElementForLink, 2857 ExecutableElementForLink,
2831 FunctionElementImpl, 2858 FunctionElementImpl,
2832 ReferenceableElementForLink {} 2859 ReferenceableElementForLink {
2860 /**
2861 * Indicates whether type inference has completed for this function.
2862 */
2863 bool get _hasTypeBeenInferred;
2864
2865 /**
2866 * Stores the given [type] as the inferred return type for this function.
2867 * Should only be called if [_hasTypeBeenInferred] is `false`.
2868 */
2869 void _setInferredType(DartType type);
2870 }
2833 2871
2834 /** 2872 /**
2835 * Element representing a local function (possibly a closure) inside another 2873 * Element representing a local function (possibly a closure) inside another
2836 * executable. 2874 * executable.
2837 */ 2875 */
2838 class FunctionElementForLink_Local_NonSynthetic extends ExecutableElementForLink 2876 class FunctionElementForLink_Local_NonSynthetic extends ExecutableElementForLink
2839 with ReferenceableElementForLink 2877 with ReferenceableElementForLink
2840 implements FunctionElementForLink_Local { 2878 implements FunctionElementForLink_Local {
2841 @override 2879 @override
2842 final ExecutableElementForLink enclosingElement; 2880 final ExecutableElementForLink enclosingElement;
2843 2881
2844 FunctionElementForLink_Local_NonSynthetic( 2882 FunctionElementForLink_Local_NonSynthetic(
2845 CompilationUnitElementForLink compilationUnit, 2883 CompilationUnitElementForLink compilationUnit,
2846 this.enclosingElement, 2884 this.enclosingElement,
2847 UnlinkedExecutable unlinkedExecutable) 2885 UnlinkedExecutable unlinkedExecutable)
2848 : super(compilationUnit, unlinkedExecutable); 2886 : super(compilationUnit, unlinkedExecutable);
2849 2887
2850 @override 2888 @override
2851 TypeParameterizedElementMixin get enclosingTypeParameterContext => 2889 TypeParameterizedElementMixin get enclosingTypeParameterContext =>
2852 enclosingElement; 2890 enclosingElement;
2853 2891
2854 @override 2892 @override
2893 bool get _hasTypeBeenInferred {
2894 // TODO(paulberry): add logic to infer types of nonsynthetic functions.
2895 return true;
2896 }
2897
2898 @override
2855 DartType buildType( 2899 DartType buildType(
2856 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { 2900 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) {
2857 assert(implicitFunctionTypeIndices.isEmpty); 2901 assert(implicitFunctionTypeIndices.isEmpty);
2858 return type; 2902 return type;
2859 } 2903 }
2860 2904
2861 @override 2905 @override
2862 FunctionElementForLink_Local getLocalFunction(int index) { 2906 FunctionElementForLink_Local getLocalFunction(int index) {
2863 // TODO(paulberry): implement. 2907 // TODO(paulberry): implement.
2864 throw new UnimplementedError(); 2908 throw new UnimplementedError();
2865 } 2909 }
2866 2910
2867 @override 2911 @override
2868 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 2912 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
2913
2914 @override
2915 void _setInferredType(DartType type) {
2916 // TODO(paulberry): add logic to infer types of nonsynthetic functions.
2917 throw new UnimplementedError();
2918 }
2869 } 2919 }
2870 2920
2871 /** 2921 /**
2872 * Element representing a typedef resynthesized from a summary during linking. 2922 * Element representing a typedef resynthesized from a summary during linking.
2873 */ 2923 */
2874 class FunctionTypeAliasElementForLink extends Object 2924 class FunctionTypeAliasElementForLink extends Object
2875 with 2925 with
2876 TypeParameterizedElementMixin, 2926 TypeParameterizedElementMixin,
2877 ParameterParentElementForLink, 2927 ParameterParentElementForLink,
2878 ReferenceableElementForLink 2928 ReferenceableElementForLink
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4312 } 4362 }
4313 } 4363 }
4314 } 4364 }
4315 4365
4316 /** 4366 /**
4317 * Specialization of [Node] used to construct the type inference dependency 4367 * Specialization of [Node] used to construct the type inference dependency
4318 * graph. 4368 * graph.
4319 */ 4369 */
4320 class TypeInferenceNode extends Node<TypeInferenceNode> { 4370 class TypeInferenceNode extends Node<TypeInferenceNode> {
4321 /** 4371 /**
4322 * The [FieldElement] or [TopLevelVariableElement] to which this 4372 * The [FunctionElementForLink_Local] to which this node refers.
4323 * node refers.
4324 */ 4373 */
4325 final VariableElementForLink variableElement; 4374 final FunctionElementForLink_Local functionElement;
4326 4375
4327 TypeInferenceNode(this.variableElement); 4376 TypeInferenceNode(this.functionElement);
4328 4377
4329 @override 4378 @override
4330 bool get isEvaluated => variableElement._inferredType != null; 4379 bool get isEvaluated => functionElement._hasTypeBeenInferred;
4331 4380
4332 /** 4381 /**
4333 * Collect the type inference dependencies in [unlinkedExecutable] (which 4382 * Collect the type inference dependencies in [unlinkedExecutable] (which
4334 * should be interpreted relative to [compilationUnit]) and store them in 4383 * should be interpreted relative to [compilationUnit]) and store them in
4335 * [dependencies]. 4384 * [dependencies].
4336 */ 4385 */
4337 void collectDependencies( 4386 void collectDependencies(
4338 List<TypeInferenceNode> dependencies, 4387 List<TypeInferenceNode> dependencies,
4339 UnlinkedExecutable unlinkedExecutable, 4388 UnlinkedExecutable unlinkedExecutable,
4340 CompilationUnitElementForLink compilationUnit) { 4389 CompilationUnitElementForLink compilationUnit) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4413 break; 4462 break;
4414 } 4463 }
4415 } 4464 }
4416 assert(refPtr == unlinkedConst.references.length); 4465 assert(refPtr == unlinkedConst.references.length);
4417 assert(intPtr == unlinkedConst.ints.length); 4466 assert(intPtr == unlinkedConst.ints.length);
4418 } 4467 }
4419 4468
4420 @override 4469 @override
4421 List<TypeInferenceNode> computeDependencies() { 4470 List<TypeInferenceNode> computeDependencies() {
4422 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[]; 4471 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[];
4423 collectDependencies( 4472 collectDependencies(dependencies, functionElement._unlinkedExecutable,
4424 dependencies, 4473 functionElement.compilationUnit);
4425 variableElement.unlinkedVariable.initializer,
4426 variableElement.compilationUnit);
4427 return dependencies; 4474 return dependencies;
4428 } 4475 }
4429 4476
4430 void evaluate(bool inCycle) { 4477 void evaluate(bool inCycle) {
4431 if (inCycle) { 4478 if (inCycle) {
4432 variableElement._inferredType = DynamicTypeImpl.instance; 4479 functionElement._setInferredType(DynamicTypeImpl.instance);
4433 } else { 4480 } else {
4434 variableElement._inferredType = 4481 functionElement
4435 new ExprTypeComputer(variableElement).compute(); 4482 ._setInferredType(new ExprTypeComputer(functionElement).compute());
4436 } 4483 }
4437 } 4484 }
4438 4485
4439 @override 4486 @override
4440 String toString() => 'TypeInferenceNode($variableElement)'; 4487 String toString() => 'TypeInferenceNode($functionElement)';
4441 } 4488 }
4442 4489
4443 class TypeProviderForLink implements TypeProvider { 4490 class TypeProviderForLink implements TypeProvider {
4444 final Linker _linker; 4491 final Linker _linker;
4445 4492
4446 InterfaceType _boolType; 4493 InterfaceType _boolType;
4447 InterfaceType _deprecatedType; 4494 InterfaceType _deprecatedType;
4448 InterfaceType _doubleType; 4495 InterfaceType _doubleType;
4449 InterfaceType _functionType; 4496 InterfaceType _functionType;
4450 InterfaceType _futureDynamicType; 4497 InterfaceType _futureDynamicType;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 /** 4680 /**
4634 * The compilation unit in which this variable appears. 4681 * The compilation unit in which this variable appears.
4635 */ 4682 */
4636 final CompilationUnitElementForLink compilationUnit; 4683 final CompilationUnitElementForLink compilationUnit;
4637 4684
4638 VariableElementForLink(this.unlinkedVariable, this.compilationUnit) { 4685 VariableElementForLink(this.unlinkedVariable, this.compilationUnit) {
4639 if (compilationUnit.isInBuildUnit && 4686 if (compilationUnit.isInBuildUnit &&
4640 unlinkedVariable.initializer?.bodyExpr != null) { 4687 unlinkedVariable.initializer?.bodyExpr != null) {
4641 _constNode = new ConstVariableNode(this); 4688 _constNode = new ConstVariableNode(this);
4642 if (unlinkedVariable.type == null) { 4689 if (unlinkedVariable.type == null) {
4643 _typeInferenceNode = new TypeInferenceNode(this); 4690 _typeInferenceNode = new TypeInferenceNode(initializer);
4644 } 4691 }
4645 } 4692 }
4646 } 4693 }
4647 4694
4648 /** 4695 /**
4649 * If the variable has an explicitly declared return type, return it. 4696 * If the variable has an explicitly declared return type, return it.
4650 * Otherwise return `null`. 4697 * Otherwise return `null`.
4651 */ 4698 */
4652 DartType get declaredType { 4699 DartType get declaredType {
4653 if (unlinkedVariable.type == null) { 4700 if (unlinkedVariable.type == null) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
4746 * there are no type parameters in scope. 4793 * there are no type parameters in scope.
4747 */ 4794 */
4748 TypeParameterizedElementMixin get _typeParameterContext; 4795 TypeParameterizedElementMixin get _typeParameterContext;
4749 4796
4750 @override 4797 @override
4751 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 4798 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
4752 4799
4753 @override 4800 @override
4754 String toString() => '$enclosingElement.$name'; 4801 String toString() => '$enclosingElement.$name';
4755 } 4802 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698