Skip to content

Inline method should wrap string interpolations with {} when necessary #57019

@stereotype441

Description

@stereotype441

Starting with the following code:

class C {
  final List<String> myList;

  C(this.myList);

  String get _first => myList.first;

  test() => 'The first entry is $_first';
}

main() {
  print(C(['x']).test()); // prints `The first entry is x`
}

Active the "inline method" refactoring on the method _first.

Expected result:

class C {
  final List<String> myList;

  C(this.myList);

  test() => 'The first entry is ${myList.first}';
}

main() {
  print(C(['x']).test()); // prints `The first entry is x`
}

Observed result:

class C {
  final List<String> myList;

  C(this.myList);

  test() => 'The first entry is $myList.first';
}

main() {
  print(C(['x']).test()); // prints `The first entry is [x].first`
}

Metadata

Metadata

Assignees

Labels

P3A lower priority bug or feature requestdevexp-refactoringIssues with analysis server refactoringsdevexp-serverIssues related to some aspect of the analysis serverlegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions