Skip to content

operator get with lambda: incorrect error #2675

@Jolanrensen

Description

@Jolanrensen

Expected Behavior

Given:

class DB {
    operator fun <T> get(query: DB.() -> T): T = TODO()
}

val db = DB()
val query = db[{ 123 }]

so, an operator get function with a lambda argument inside, KtLint should be happy with this notation. It is accepted by IntelliJ.

Observed Behavior

We get a linting error:
Lint error > [standard:curly-spacing] Missing spacing before "{".

If I run the formatter instead it performs a fix and reverts it again:
Format fixed > [standard:curly-spacing] Missing spacing before "{"

Format fixed > [standard:square-brackets-spacing] Unexpected spacing after '['

Steps to Reproduce

See the example above.

Your Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions