Skip to content

Commit 9fe67b8

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Add @trackedInternal marker.
Change-Id: Idabe772d7de2d1a0f3a9d0a2ea71cc3050bb8c3a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448225 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 19794aa commit 9fe67b8

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4637,6 +4637,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
46374637
List<ConstructorElementImpl> _constructors = _Sentinel.constructorElement;
46384638

46394639
/// This callback is set during mixins inference to handle reentrant calls.
4640+
@trackedInternal
46404641
List<InterfaceTypeImpl>? Function(InterfaceElementImpl)?
46414642
mixinInferenceCallback;
46424643

pkg/analyzer/lib/src/fine/annotations.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ const trackedIncludedInId = _TrackedIncludedInId();
6565
/// class.
6666
const trackedIndirectly = _TrackedIndirectly();
6767

68+
/// Annotation for methods that used internally while building elements,
69+
/// but are not supposed to be used by any client.
70+
///
71+
/// Such methods of course are never API, and potential clients could only
72+
/// be other parts of the analyzer itself.
73+
const trackedInternal = _TrackedInternal();
74+
6875
final class _ElementClass {
6976
const _ElementClass();
7077
}
@@ -89,6 +96,10 @@ final class _TrackedIndirectly extends _TrackedKind {
8996
const _TrackedIndirectly();
9097
}
9198

99+
final class _TrackedInternal extends _TrackedKind {
100+
const _TrackedInternal();
101+
}
102+
92103
/// Superclass for all specific kinds of tracking annotations.
93104
sealed class _TrackedKind {
94105
const _TrackedKind();

pkg/linter/lib/src/rules/analyzer_element_model_tracking.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class _Visitor extends SimpleAstVisitor<void> {
105105
annotation.element.isTrackedDirectlyExpensive ||
106106
annotation.element.isTrackedDirectlyOpaque ||
107107
annotation.element.isTrackedIncludedInId ||
108-
annotation.element.isTrackedIndirectly) {
108+
annotation.element.isTrackedIndirectly ||
109+
annotation.element.isTrackedInternal) {
109110
if (hasRequired) {
110111
_reportMoreThanOne(annotation);
111112
}
@@ -133,7 +134,8 @@ class _Visitor extends SimpleAstVisitor<void> {
133134
annotation.element.isTrackedDirectlyExpensive ||
134135
annotation.element.isTrackedDirectlyOpaque ||
135136
annotation.element.isTrackedIncludedInId ||
136-
annotation.element.isTrackedIndirectly) {
137+
annotation.element.isTrackedIndirectly ||
138+
annotation.element.isTrackedInternal) {
137139
if (hasRequired) {
138140
_reportMoreThanOne(annotation);
139141
}
@@ -193,7 +195,8 @@ extension on ElementAnnotation {
193195
isTrackedDirectlyExpensive ||
194196
isTrackedDirectlyOpaque ||
195197
isTrackedIncludedInId ||
196-
isTrackedIndirectly;
198+
isTrackedIndirectly ||
199+
isTrackedInternal;
197200

198201
bool get isElementClass => _isAnnotation('elementClass');
199202

@@ -208,6 +211,8 @@ extension on ElementAnnotation {
208211

209212
bool get isTrackedIndirectly => _isAnnotation('trackedIndirectly');
210213

214+
bool get isTrackedInternal => _isAnnotation('trackedInternal');
215+
211216
bool _isAnnotation(String name) {
212217
if (element case GetterElement element) {
213218
return element.name == name &&

pkg/linter/test/rules/analyzer_element_model_tracking_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,18 @@ class A {
262262
''');
263263
}
264264

265+
test_public_instancePublic_getter_trackedInternal() async {
266+
await assertNoDiagnostics(r'''
267+
import 'package:analyzer/src/fine/annotations.dart';
268+
269+
@elementClass
270+
class A {
271+
@trackedInternal
272+
int get foo => 0;
273+
}
274+
''');
275+
}
276+
265277
test_public_instancePublic_method_noAnnotation() async {
266278
await assertDiagnostics(
267279
r'''
@@ -374,6 +386,18 @@ class A {
374386
''');
375387
}
376388

389+
test_public_instancePublic_method_trackedInternal() async {
390+
await assertNoDiagnostics(r'''
391+
import 'package:analyzer/src/fine/annotations.dart';
392+
393+
@elementClass
394+
class A {
395+
@trackedInternal
396+
int foo() => 0;
397+
}
398+
''');
399+
}
400+
377401
test_public_staticPrivate_field_trackedIncludedInId() async {
378402
await assertDiagnostics(
379403
r'''

0 commit comments

Comments
 (0)