mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:49:43 +00:00
[vm/kernel/aot] Fix recognition of native methods after annotations are constant evaluated
This change fixes findNativeName() in package:kernel/transformations/treeshaker to handle constant evaluated Dart annotations. This function is used from TFA and kernel tree shaker. This change is a prerequisite for enabling constant evaluation of annotations. Change-Id: I40f91cce6b34f0e262db7ae6f0fd98303acbf133 Reviewed-on: https://dart-review.googlesource.com/57401 Reviewed-by: Samir Jindel <sjindel@google.com> Commit-Queue: Samir Jindel <sjindel@google.com>
This commit is contained in:
parent
753d95453c
commit
fb4f887eff
|
@ -1265,6 +1265,16 @@ String findNativeName(Member procedure) {
|
|||
assert(annotation.arguments.positional.length == 1);
|
||||
return (annotation.arguments.positional[0] as StringLiteral).value;
|
||||
}
|
||||
} else if (annotation is ConstantExpression) {
|
||||
final constant = annotation.constant;
|
||||
if (constant is InstanceConstant) {
|
||||
final Class klass = constant.klass;
|
||||
if (klass.name == 'ExternalName' &&
|
||||
klass.enclosingLibrary.importUri.toString() == 'dart:_internal') {
|
||||
assert(constant.fieldValues.length == 1);
|
||||
return (constant.fieldValues.values.single as StringConstant).value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue