mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Mark private classes which are annotated with @JS as used
Work towards https://github.com/dart-lang/sdk/issues/52835 Change-Id: I300928dbfcfd819e4a9f20030cb46e2048f504e7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313287 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
185aa1f36f
commit
dea256c9fc
|
@ -70,6 +70,13 @@ class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitClassDeclaration(ClassDeclaration node) {
|
||||
var element = node.declaredElement;
|
||||
if (element != null) {
|
||||
if (element.hasJS) {
|
||||
usedElements.addElement(element);
|
||||
}
|
||||
}
|
||||
|
||||
var enclosingClassOld = _enclosingClass;
|
||||
try {
|
||||
_enclosingClass = node.declaredElement;
|
||||
|
|
|
@ -84,6 +84,28 @@ void f(Object p) {
|
|||
''');
|
||||
}
|
||||
|
||||
test_class_isUsed_jsAnnotation() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'js', rootPath: '$workspaceRootPath/js'),
|
||||
);
|
||||
|
||||
newFile('$workspaceRootPath/js/lib/js.dart', r'''
|
||||
library _js_annotations;
|
||||
|
||||
class JS {
|
||||
const JS();
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode(r'''
|
||||
import 'package:js/js.dart';
|
||||
|
||||
@JS()
|
||||
class _A {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_class_notUsed_isExpression_typeArgument() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class _A {}
|
||||
|
|
Loading…
Reference in a new issue