| Index: pkg/compiler/lib/src/js/js.dart
|
| diff --git a/pkg/compiler/lib/src/js/js.dart b/pkg/compiler/lib/src/js/js.dart
|
| index 1a08cfbeb0798072ea178fd3993b134183c5c718..3a9fd2ea8e599045266b3d5a1060191852a1c0b8 100644
|
| --- a/pkg/compiler/lib/src/js/js.dart
|
| +++ b/pkg/compiler/lib/src/js/js.dart
|
| @@ -162,4 +162,27 @@ class UnparsedNode extends DeferredString
|
|
|
| @override
|
| String get value => _literal.value;
|
| -}
|
| +}
|
| +
|
| +/// Returns `true` if [template] will immediately give a TypeError if the first
|
| +/// placeholder is `null` or `undefined`.
|
| +bool isNullGuardOnFirstArgument(Template template) {
|
| + // We look for a template of the form
|
| + //
|
| + // #.something
|
| + // #.something()
|
| + //
|
| + Node node = template.ast;
|
| + if (node is Call) {
|
| + Call call = node;
|
| + node = call.target;
|
| + }
|
| + if (node is PropertyAccess) {
|
| + PropertyAccess access = node;
|
| + if (access.receiver is InterpolatedExpression) {
|
| + InterpolatedExpression hole = access.receiver;
|
| + return hole.isPositional && hole.nameOrPosition == 0;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
|
|