Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonObjectBuilder.to method shadows to function from stdlib #627

Closed
anti-social opened this issue Dec 15, 2019 · 1 comment
Closed

JsonObjectBuilder.to method shadows to function from stdlib #627

anti-social opened this issue Dec 15, 2019 · 1 comment
Assignees

Comments

@anti-social
Copy link

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.

@anti-social anti-social changed the title JsonObjectBuilder.to method shadows to function from stdlib JsonObjectBuilder.to method shadows to function from stdlib Dec 15, 2019
@sandwwraith
Copy link
Member

Related: #462 , #418

Seems 'classic' DSL (with to and unaryPlus) for json was a mistake, after all.
cc @qwwdfsad

@qwwdfsad qwwdfsad self-assigned this Dec 16, 2019
qwwdfsad added a commit that referenced this issue Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants