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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 2100493002: Allow for library access to `@protected` protected members (linter#254). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge branch 'master' into protected 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/generated/hint_code_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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.generated.resolver; 5 library analyzer.src.generated.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 element.isProtected) { 746 element.isProtected) {
747 return true; 747 return true;
748 } 748 }
749 return false; 749 return false;
750 } 750 }
751 751
752 bool inCommentReference(SimpleIdentifier identifier) => 752 bool inCommentReference(SimpleIdentifier identifier) =>
753 identifier.getAncestor((AstNode node) => node is CommentReference) != 753 identifier.getAncestor((AstNode node) => node is CommentReference) !=
754 null; 754 null;
755 755
756 bool inCurrentLibrary(Element element) =>
757 element.library == _currentLibrary;
758
756 Element element = identifier.bestElement; 759 Element element = identifier.bestElement;
757 if (isProtected(element) && !inCommentReference(identifier)) { 760 if (isProtected(element) &&
761 !inCurrentLibrary(element) &&
762 !inCommentReference(identifier)) {
758 ClassElement definingClass = element.enclosingElement; 763 ClassElement definingClass = element.enclosingElement;
759 ClassDeclaration accessingClass = 764 ClassDeclaration accessingClass =
760 identifier.getAncestor((AstNode node) => node is ClassDeclaration); 765 identifier.getAncestor((AstNode node) => node is ClassDeclaration);
761 if (accessingClass == null || 766 if (accessingClass == null ||
762 !_hasTypeOrSuperType(accessingClass.element, definingClass.type)) { 767 !_hasTypeOrSuperType(accessingClass.element, definingClass.type)) {
763 _errorReporter.reportErrorForNode( 768 _errorReporter.reportErrorForNode(
764 HintCode.INVALID_USE_OF_PROTECTED_MEMBER, 769 HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
765 identifier, 770 identifier,
766 [identifier.name.toString(), definingClass.name]); 771 [identifier.name.toString(), definingClass.name]);
767 } 772 }
(...skipping 10250 matching lines...) Expand 10 before | Expand all | Expand 10 after
11018 return null; 11023 return null;
11019 } 11024 }
11020 if (identical(node.staticElement, variable)) { 11025 if (identical(node.staticElement, variable)) {
11021 if (node.inSetterContext()) { 11026 if (node.inSetterContext()) {
11022 result = true; 11027 result = true;
11023 } 11028 }
11024 } 11029 }
11025 return null; 11030 return null;
11026 } 11031 }
11027 } 11032 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/hint_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698