Skip to content

[Code] should be string interpolated to the code string #57064

@cedvdb

Description

@cedvdb

Currently using Code in an interpolated String will result in Instance of.. . In the context of macros, a more sensible option would be to override Code.toString() so string interpolatation returns a string that represents the actual code.

Use case:

Using strings is more readable than arrays in some cases. I wanted to do

RawCode.fromString('$valueReference.toIso8601String()')

but had to do:

RawCode.fromParts([valueReference, '.toIso8601String()']);

In place like here https://github.com/dart-lang/sdk/pull/57063/files#diff-e10def922b15028782e7fdcf395c5acab6f0cc2e86c1696a3e936eb775396d7aR638

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-pkgUsed for miscellaneous pkg/ packages not associated with specific area- teams.feature-macrosImplementation of the macros featurepkg-macrosThe experimental package:_macros librarytype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions