Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline method sometimes fails with string interpolation #52340

Closed
bwilkerson opened this issue May 10, 2023 · 2 comments
Closed

Inline method sometimes fails with string interpolation #52340

bwilkerson opened this issue May 10, 2023 · 2 comments
Assignees
Labels
analyzer-refactoring area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request

Comments

@bwilkerson
Copy link
Member

Inline method doesn't work well when a parameter is referenced in a string interpolation. For example, given

List<String> f() {
  return [
    g('x'),
    g(3.toString()),
  ];
}
String g(String s) {
  return 'f($s)';
}

Iinlining both invocations of the method g produces

List<String> f() {
  return [
    'f($'x')',
    'f($3.toString())',
  ];
}
String g(String s) {
    return 'f($s)';
}

The interpolation of the parameter needs to be enclosed in a braces unless the replacement is a simple identifier.

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-refactoring labels May 10, 2023
@bwilkerson
Copy link
Member Author

@scheglov

@pq pq added the P3 A lower priority bug or feature request label May 10, 2023
@scheglov scheglov self-assigned this May 10, 2023
@scheglov
Copy link
Contributor

copybara-service bot pushed a commit that referenced this issue May 10, 2023
…rameters.

Bug: #52340
Change-Id: Ic8d74778e62b3bee2152bf921fbb48d2febd3701
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302641
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-refactoring area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants