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

Unified Diff: pkg/compiler/lib/src/native/resolver.dart

Issue 2998543002: Handle js interop members in impact computation. (Closed)
Patch Set: Updated cf. comments. Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/native/behavior.dart ('k') | pkg/compiler/lib/src/resolution/resolution_strategy.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/native/resolver.dart
diff --git a/pkg/compiler/lib/src/native/resolver.dart b/pkg/compiler/lib/src/native/resolver.dart
index 885efca56e7be0f8a54c8bf8c274ec87bcaef7d5..0e51017aad971c7502603ce4acc15e5131e5bf9a 100644
--- a/pkg/compiler/lib/src/native/resolver.dart
+++ b/pkg/compiler/lib/src/native/resolver.dart
@@ -607,20 +607,37 @@ class ResolutionNativeClassFinder extends BaseNativeClassFinder {
}
}
+/// Returns `true` if [value] is named annotation based on [annotationClass].
+bool isAnnotation(
+ Spannable spannable, ConstantValue value, ClassEntity annotationClass) {
+ if (!value.isConstructedObject) return null;
+ ConstructedConstantValue constructedObject = value;
+ return constructedObject.type.element == annotationClass;
+}
+
/// Extracts the name if [value] is a named annotation based on
/// [annotationClass], otherwise returns `null`.
String readAnnotationName(
- Spannable spannable, ConstantValue value, ClassEntity annotationClass) {
+ Spannable spannable, ConstantValue value, ClassEntity annotationClass,
+ {String defaultValue}) {
if (!value.isConstructedObject) return null;
ConstructedConstantValue constructedObject = value;
if (constructedObject.type.element != annotationClass) return null;
Iterable<ConstantValue> fields = constructedObject.fields.values;
// TODO(sra): Better validation of the constant.
- if (fields.length != 1 || fields.single is! StringConstantValue) {
+ if (fields.length != 1) {
failedAt(
spannable, 'Annotations needs one string: ${value.toStructuredText()}');
+ return null;
+ } else if (fields.single is StringConstantValue) {
+ StringConstantValue specStringConstant = fields.single;
+ return specStringConstant.primitiveValue;
+ } else if (defaultValue != null && fields.single is NullConstantValue) {
+ return defaultValue;
+ } else {
+ failedAt(
+ spannable, 'Annotations needs one string: ${value.toStructuredText()}');
+ return null;
}
- StringConstantValue specStringConstant = fields.single;
- return specStringConstant.primitiveValue;
}
« no previous file with comments | « pkg/compiler/lib/src/native/behavior.dart ('k') | pkg/compiler/lib/src/resolution/resolution_strategy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698