Skip to content

Failed to format with new Explicit Backing Fields #531

@MayoBytes

Description

@MayoBytes

Was working on changing all the shared & state flows in our project to use K2 the new experimental "Explicit Backing Fields" and my ktfmt pre-commit hook failed with:

[ktfmt] Failed to format file: /path/to/file.kt (reason = 40:5: error: did not generate token "field")

This is the code using the backing fields that ktfmt is failing on:

private var time = Clock.System.now()

val stateFlow: StateFlow<Instant>
    field = MutableStateFlow(time)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions