Skip to content

JsonObjectBuilder.to method shadows to function from stdlib #627

@anti-social

Description

@anti-social

Recently I encountered such a problem. Imagine we have a function like follow:

fun prepareRequest(alias: String): JsonObject {
    return json {
        "alias" to alias
    }
}

Then I did small refactoring:

fun prepareRequest(alias: Alias): JsonObject {
    return json {
        "alias" to alias
        // Fix:
        // "alias" to alias.name
    }
}

And suddenly method to became https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/to.html which result is just lost. The compiler is silent.

Possibly it is worth to rename JsonObjectBuilder.to extension method or make json object construction more explicit.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions