| Index: pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
|
| diff --git a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
|
| index a401e0585eb1de672ccca32915527e929a9f714e..bfd4df4dd30bf82afc72503e1aad3f2f206649c0 100644
|
| --- a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
|
| @@ -4,11 +4,9 @@
|
|
|
| import '../common.dart';
|
| import '../common_elements.dart' show CommonElements;
|
| -import '../common/names.dart' show Identifiers, Names, Selectors;
|
| -import '../elements/elements.dart';
|
| +import '../common/names.dart' show Identifiers, Selectors;
|
| import '../elements/entities.dart';
|
| import '../types/types.dart';
|
| -import '../tree/tree.dart';
|
|
|
| /**
|
| * Categorizes `noSuchMethod` implementations.
|
| @@ -74,6 +72,8 @@ class NoSuchMethodRegistry {
|
|
|
| NoSuchMethodRegistry(this._commonElements, this._resolver);
|
|
|
| + NoSuchMethodResolver get internalResolverForTesting => _resolver;
|
| +
|
| bool get hasThrowingNoSuchMethod => throwingImpls.isNotEmpty;
|
| bool get hasComplexNoSuchMethod => otherImpls.isNotEmpty;
|
|
|
| @@ -206,85 +206,3 @@ abstract class NoSuchMethodResolver {
|
| /// Returns the `noSuchMethod` that [method] overrides.
|
| FunctionEntity getSuperNoSuchMethod(FunctionEntity method);
|
| }
|
| -
|
| -/// AST-based implementation of [NoSuchMethodResolver].
|
| -class NoSuchMethodResolverImpl implements NoSuchMethodResolver {
|
| - bool hasForwardingSyntax(MethodElement element) {
|
| - // At this point we know that this is signature-compatible with
|
| - // Object.noSuchMethod, but it may have more than one argument as long as
|
| - // it only has one required argument.
|
| - if (!element.hasResolvedAst) {
|
| - // TODO(johnniwinther): Why do we see unresolved elements here?
|
| - return false;
|
| - }
|
| - ResolvedAst resolvedAst = element.resolvedAst;
|
| - if (resolvedAst.kind != ResolvedAstKind.PARSED) {
|
| - return false;
|
| - }
|
| - String param = element.parameters.first.name;
|
| - Statement body = resolvedAst.body;
|
| - Expression expr;
|
| - if (body is Return && body.isArrowBody) {
|
| - expr = body.expression;
|
| - } else if (body is Block &&
|
| - !body.statements.isEmpty &&
|
| - body.statements.nodes.tail.isEmpty) {
|
| - Statement stmt = body.statements.nodes.head;
|
| - if (stmt is Return && stmt.hasExpression) {
|
| - expr = stmt.expression;
|
| - }
|
| - }
|
| - if (expr is Send && expr.isTypeCast) {
|
| - Send sendExpr = expr;
|
| - var typeAnnotation = sendExpr.typeAnnotationFromIsCheckOrCast;
|
| - var typeName = typeAnnotation.asNominalTypeAnnotation()?.typeName;
|
| - if (typeName is Identifier && typeName.source == "dynamic") {
|
| - expr = sendExpr.receiver;
|
| - }
|
| - }
|
| - if (expr is Send &&
|
| - expr.isSuperCall &&
|
| - expr.selector is Identifier &&
|
| - (expr.selector as Identifier).source == Identifiers.noSuchMethod_) {
|
| - var arg = expr.arguments.head;
|
| - if (expr.arguments.tail.isEmpty &&
|
| - arg is Send &&
|
| - arg.argumentsNode == null &&
|
| - arg.receiver == null &&
|
| - arg.selector is Identifier &&
|
| - arg.selector.source == param) {
|
| - return true;
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - bool hasThrowingSyntax(MethodElement element) {
|
| - if (!element.hasResolvedAst) {
|
| - // TODO(johnniwinther): Why do we see unresolved elements here?
|
| - return false;
|
| - }
|
| - ResolvedAst resolvedAst = element.resolvedAst;
|
| - if (resolvedAst.kind != ResolvedAstKind.PARSED) {
|
| - return false;
|
| - }
|
| - Statement body = resolvedAst.body;
|
| - if (body is Return && body.isArrowBody) {
|
| - if (body.expression is Throw) {
|
| - return true;
|
| - }
|
| - } else if (body is Block &&
|
| - !body.statements.isEmpty &&
|
| - body.statements.nodes.tail.isEmpty) {
|
| - if (body.statements.nodes.head is ExpressionStatement) {
|
| - ExpressionStatement stmt = body.statements.nodes.head;
|
| - return stmt.expression is Throw;
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - MethodElement getSuperNoSuchMethod(MethodElement method) {
|
| - return method.enclosingClass.lookupSuperByName(Names.noSuchMethod_);
|
| - }
|
| -}
|
|
|