Skip to content

Extract Method extracts to non-static method in static context #4564

Closed

Description

@mosuem

Describe the bug
Given a method

static String test = getNameBy((v) => v.toString());

when calling Extract Method on the inner lambda, it extracts to

static String test = getNameBy(newMethod);
String newMethod(v) => v.toString();

which then gives the implicit_this_reference_in_initializer error. It should instead extract to

static String test = getNameBy(newMethod);
static String newMethod(v) => v.toString();

Please complete the following information:
Dart SDK version: 3.1.0-39.0.dev (dev) (Mon Apr 24 18:53:55 2023 -0700) on "linux_x64"

Version: 1.78.0
Commit: 252e5463d60e63238250799aef7375787f68b4ee
Date: 2023-05-03T20:09:46.685Z
Electron: 22.4.8
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 6.1.20-2rodete1-amd64
Sandboxed: No

Dart-Code v3.65.20230520 Pre-Release

Activity

  1. added this to the v3.72.0 milestone on Jul 27, 2023
  2. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Jul 27, 2023
  3. DanTup commented on Aug 2, 2023

    @DanTup
    Member
  4. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Aug 2, 2023
  5. DanTup commented on Aug 3, 2023

    @DanTup
    Member

    Fixed by dart-lang/sdk@02c99b4, will ship in a future SDK release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions