[vm/kernel] Make call site annotator transformation more robust
Currently we can't rely on getStaticType due to various issues with
Kernel AST - so we just wrap the invocation in try-catch and swallow
the exception if any.
Fixes https://github.com/dart-lang/sdk/issues/34463
R=alexmarkov@google.com
Change-Id: I48af952c4df4e124a895f0e1b9bf50a50b94a047
Reviewed-on: https://dart-review.googlesource.com/75221
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
diff --git a/pkg/vm/lib/transformations/call_site_annotator.dart b/pkg/vm/lib/transformations/call_site_annotator.dart
index c2ca324..66f1cfe 100644
--- a/pkg/vm/lib/transformations/call_site_annotator.dart
+++ b/pkg/vm/lib/transformations/call_site_annotator.dart
@@ -54,13 +54,23 @@
env.thisType = null;
}
+ void annotateWithType(TreeNode node, Expression receiver) {
+ try {
+ _metadata.mapping[node] = new CallSiteAttributesMetadata(
+ receiverType: receiver.getStaticType(env));
+ } catch (e) {
+ // TODO(dartbug.com/34496) Currently getStaticType is unreliable due to
+ // various issues with AST welltypedness. As a workaround we just
+ // swallow the exception.
+ }
+ }
+
@override
visitPropertySet(PropertySet node) {
super.visitPropertySet(node);
if (hasGenericCovariantParameters(node.interfaceTarget)) {
- _metadata.mapping[node] = new CallSiteAttributesMetadata(
- receiverType: node.receiver.getStaticType(env));
+ annotateWithType(node, node.receiver);
}
}
@@ -72,8 +82,7 @@
// or not it's a statically-checked call.
if (node.name.name == 'call' ||
hasGenericCovariantParameters(node.interfaceTarget)) {
- _metadata.mapping[node] = new CallSiteAttributesMetadata(
- receiverType: node.receiver.getStaticType(env));
+ annotateWithType(node, node.receiver);
}
}