Files
sdk/pkg/analyzer/test
Martin Kamleithner 579cbd80bd Add missing visit() methods in ExitDetectors for pattern assignments
I have run into a crash in the Analyzer when running `dart fix` on a
Flutter project.

minimal repro:

    import 'package:flutter/widgets.dart';

    void patternIssue(BuildContext context) {
      if (true) {
        final (string: string) = (string: "");
      }
      context.toString();
    }

If one runs `dart fix --dry-run` on this file, it will throw

    Computing fixes in exit_detector_bug (dry run)...
    An unexpected error was encountered by the Analysis Server.
    Please file an issue at https://github.com/dart-
    lang/sdk/issues/new/choose with the following details:

    Internal error: Exception while using a UseBuildContextSynchronously
    to visit a MethodInvocationImpl in ExpressionStatementImpl in
    BlockImpl in BlockFunctionBodyImpl in FunctionExpressionImpl in
    FunctionDeclarationImpl in CompilationUnitImpl
    Bad state: Missing a visit method for a node of type
    PatternVariableDeclarationStatementImpl

I tracked this down to ExitDetector not having implementations for
various visit methods related to patterns.

I added these implementations and added a test.

R=cstefantsova@google.com

Change-Id: I7c090b261e9ceb53d9b50d0a931bffcec772f8d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419040
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Martin Kamleithner <martin.kamleithner@gmail.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-04 10:26:40 -07:00
..
2025-03-18 09:19:00 -07:00
2025-03-31 15:37:13 -07:00