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

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

Issue 2644543005: Element model support for covariant (Closed)
Patch Set: Created 3 years, 11 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 3841 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 @override 3852 @override
3853 bool get inheritsCovariant => _inheritsCovariant; 3853 bool get inheritsCovariant => _inheritsCovariant;
3854 3854
3855 @override 3855 @override
3856 void set inheritsCovariant(bool value) { 3856 void set inheritsCovariant(bool value) {
3857 _inheritsCovariant = value; 3857 _inheritsCovariant = value;
3858 } 3858 }
3859 3859
3860 @override 3860 @override
3861 bool get isCovariant { 3861 bool get isCovariant {
3862 if (inheritsCovariant) { 3862 if (isExplicitlyCovariant || inheritsCovariant) {
3863 return true; 3863 return true;
3864 } 3864 }
3865 for (UnlinkedExpr annotation in _unlinkedParam.annotations) { 3865 for (UnlinkedExpr annotation in _unlinkedParam.annotations) {
3866 if (annotation.operations.length == 1 && 3866 if (annotation.operations.length == 1 &&
3867 annotation.operations[0] == UnlinkedExprOperation.pushReference) { 3867 annotation.operations[0] == UnlinkedExprOperation.pushReference) {
3868 ReferenceableElementForLink element = 3868 ReferenceableElementForLink element =
3869 this.compilationUnit.resolveRef(annotation.references[0].reference); 3869 this.compilationUnit.resolveRef(annotation.references[0].reference);
3870 if (element is PropertyAccessorElementForLink && 3870 if (element is PropertyAccessorElementForLink &&
3871 element.name == 'checked' && 3871 element.name == 'checked' &&
3872 element.library.name == 'meta') { 3872 element.library.name == 'meta') {
3873 return true; 3873 return true;
3874 } 3874 }
3875 } 3875 }
3876 } 3876 }
3877 return false; 3877 return false;
3878 } 3878 }
3879 3879
3880 @override 3880 @override
3881 bool get isExplicitlyCovariant => _unlinkedParam.isExplicitlyCovariant;
3882
3883 @override
3881 String get name => _unlinkedParam.name; 3884 String get name => _unlinkedParam.name;
3882 3885
3883 @override 3886 @override
3884 ParameterKind get parameterKind { 3887 ParameterKind get parameterKind {
3885 switch (_unlinkedParam.kind) { 3888 switch (_unlinkedParam.kind) {
3886 case UnlinkedParamKind.required: 3889 case UnlinkedParamKind.required:
3887 return ParameterKind.REQUIRED; 3890 return ParameterKind.REQUIRED;
3888 case UnlinkedParamKind.positional: 3891 case UnlinkedParamKind.positional:
3889 return ParameterKind.POSITIONAL; 3892 return ParameterKind.POSITIONAL;
3890 case UnlinkedParamKind.named: 3893 case UnlinkedParamKind.named:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3948 class ParameterElementForLink_VariableSetter implements ParameterElementImpl { 3951 class ParameterElementForLink_VariableSetter implements ParameterElementImpl {
3949 @override 3952 @override
3950 final PropertyAccessorElementForLink_Variable enclosingElement; 3953 final PropertyAccessorElementForLink_Variable enclosingElement;
3951 3954
3952 @override 3955 @override
3953 bool inheritsCovariant = false; 3956 bool inheritsCovariant = false;
3954 3957
3955 ParameterElementForLink_VariableSetter(this.enclosingElement); 3958 ParameterElementForLink_VariableSetter(this.enclosingElement);
3956 3959
3957 @override 3960 @override
3958 bool get isCovariant => false; 3961 bool get isCovariant => isExplicitlyCovariant || inheritsCovariant;
3962
3963 @override
3964 bool get isExplicitlyCovariant => enclosingElement.variable.isCovariant;
3959 3965
3960 @override 3966 @override
3961 bool get isSynthetic => true; 3967 bool get isSynthetic => true;
3962 3968
3963 @override 3969 @override
3964 String get name => 'x'; 3970 String get name => 'x';
3965 3971
3966 @override 3972 @override
3967 ParameterKind get parameterKind => ParameterKind.REQUIRED; 3973 ParameterKind get parameterKind => ParameterKind.REQUIRED;
3968 3974
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
4902 if (unlinkedVariable.initializer == null) { 4908 if (unlinkedVariable.initializer == null) {
4903 return null; 4909 return null;
4904 } else { 4910 } else {
4905 return _initializer ??= new FunctionElementForLink_Initializer(this); 4911 return _initializer ??= new FunctionElementForLink_Initializer(this);
4906 } 4912 }
4907 } 4913 }
4908 4914
4909 @override 4915 @override
4910 bool get isConst => unlinkedVariable.isConst; 4916 bool get isConst => unlinkedVariable.isConst;
4911 4917
4918 /**
4919 * Return `true` if this variable is a field that was explicitly marked as
4920 * being covariant (in the setter's parameter).
4921 */
4922 bool get isCovariant => unlinkedVariable.isCovariant;
4923
4912 @override 4924 @override
4913 bool get isFinal => unlinkedVariable.isFinal; 4925 bool get isFinal => unlinkedVariable.isFinal;
4914 4926
4915 @override 4927 @override
4916 bool get isStatic; 4928 bool get isStatic;
4917 4929
4918 @override 4930 @override
4919 bool get isSynthetic => false; 4931 bool get isSynthetic => false;
4920 4932
4921 @override 4933 @override
(...skipping 27 matching lines...) Expand all
4949 * there are no type parameters in scope. 4961 * there are no type parameters in scope.
4950 */ 4962 */
4951 TypeParameterizedElementMixin get _typeParameterContext; 4963 TypeParameterizedElementMixin get _typeParameterContext;
4952 4964
4953 @override 4965 @override
4954 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 4966 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
4955 4967
4956 @override 4968 @override
4957 String toString() => '$enclosingElement.$name'; 4969 String toString() => '$enclosingElement.$name';
4958 } 4970 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698