Skip to content

Convert Getter to Method doesn't work for extensions #3846

Closed

Description

@Merrit

Describe the bug
Using the refactor feature to convert a getter to a method doesn't work if said getter is part of an extension.

To Reproduce
Steps to reproduce the behavior:

  1. Add a getter to an extension
  2. Right click getter name -> Refactor -> Convert Getter to Method

Expected behavior
Getter should be changed to a method.

Example:

enum Category {
  metal,
  wood,
  glass,
}

extension ExtraEnumFuntionality on Category {
  String get someValue => 'returnValue'; // FAIL
}

class SomeClass {
  String get aValue => 'aReturnValue'; // SUCCESS
}

extension ExtraClassFunctionality on SomeClass {
  String get someValue => 'returnValue'; // FAIL
}

Versions (please complete the following information):

  • VS Code version: 1.64.2
  • Dart extension version: 3.34.0
  • Dart/Flutter SDK version: Flutter 2.11.0-0.1.pre, Dart 2.17.0

Activity

  1. added this to the v3.36.0 milestone on Feb 28, 2022
  2. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Feb 28, 2022
  3. DanTup commented on Feb 28, 2022

    @DanTup
    Member

    Thanks! I have a fix for review at https://dart-review.googlesource.com/c/sdk/+/234600/. The change is in the Dart SDK so would ship with an upcoming Dart/Flutter SDK rather than a Dart-Code release. I'll keep this issue open until the change has passed review and landed.

    Thanks!

  4. DanTup commented on Feb 28, 2022

    @DanTup
    Member

    The fix has landed in dart-lang/sdk@0359628.

  5. Merrit commented on Feb 28, 2022

    @Merrit
    Author

    Well that was quick! Thank you :)

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 bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions