8000 Missing support for context parameters on properties · Issue #518 · facebook/ktfmt · GitHub
[go: up one dir, main page]

Skip to content
Missing support for context parameters on properties #518
@koljakube

Description

@koljakube

Hello!

While introducing context parameters in my code, I noticed that ktfmt is not able to handle them on properties (at least properties in classes/interfaces, global scope seems to work for some reason).

Two possible errors are raised:

0

context(Unit)
val someOuterProp: String get() = ""

This is fine.
I use Unit for simplicity's sake, but "real" interfaces exhibit the same behavior.

1

Simple property with context parameter:

interface SomeInterface {
    context(Unit)
    val someInnerProp: String get() = ""
}

error: expected token: 'context'; generated val instead

2

interface BaseInterface {
    context(Unit)
    open val someInnerProp: String get() = ""
}

interface SomeInterface {
    context(Unit)
    override val someInnerProp: String get() = ""
}

Both of them can, in isolation, cause this:

error: did not generate token "context"


A related issue I could find is #471, but that pertains to methods, not properties.
If I read the KEEP correctly, these cases should be legal, albeit experimental, Kotlin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0