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

Ktlint autoformat fails with KtOperationReferenceExpression cannot be cast to LeafPsiElement #205

Closed
vanniktech opened this issue May 3, 2018 · 3 comments

Comments

@vanniktech
Copy link
Contributor

This is the stacktrace I'm getting with 0.23.0:

com.github.shyiko.ktlint.core.RuleExecutionException: java.lang.ClassCastException: org.jetbrains.kotlin.psi.KtOperationReferenceExpression cannot be cast to org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
        at com.github.shyiko.ktlint.core.KtLint$format$1.invoke(KtLint.kt:345)
        at com.github.shyiko.ktlint.core.KtLint$format$1.invoke(KtLint.kt:36)
        at com.github.shyiko.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:207)
        at com.github.shyiko.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:36)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:487)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
        at com.github.shyiko.ktlint.core.KtLint.access$visit(KtLint.kt:36)
        at com.github.shyiko.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:206)
        at com.github.shyiko.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:36)
        at com.github.shyiko.ktlint.core.KtLint.format(KtLint.kt:328)
        at com.github.shyiko.ktlint.core.KtLint.format(KtLint.kt:279)
        at com.github.shyiko.ktlint.Main.format(Main.kt:639)
        at com.github.shyiko.ktlint.Main.access$format(Main.kt:84)
        at com.github.shyiko.ktlint.Main$main$2.invoke(Main.kt:286)
        at com.github.shyiko.ktlint.Main$main$5$1.call(Main.kt:334)
        at com.github.shyiko.ktlint.Main$main$5$1.call(Main.kt:84)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: org.jetbrains.kotlin.psi.KtOperationReferenceExpression cannot be cast to org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
        at com.github.shyiko.ktlint.ruleset.standard.PackageKt.nextLeaf(package.kt:14)
        at com.github.shyiko.ktlint.ruleset.standard.IndentationRule.previousIndentSize(IndentationRule.kt:67)
        at com.github.shyiko.ktlint.ruleset.standard.IndentationRule.visit(IndentationRule.kt:34)
        at com.github.shyiko.ktlint.core.KtLint$format$1.invoke(KtLint.kt:333)
        ... 29 more

Unfortunately I can't share the source code and can't break it down to a minimal example.

shyiko added a commit that referenced this issue May 3, 2018
@shyiko
Copy link
Collaborator

shyiko commented May 3, 2018

Hey Niklas. Can you please try latest 0.0.0-SNAPSHOT?

@vanniktech
Copy link
Contributor Author

Yup it no longer crashes. Hence will close.

@shyiko
Copy link
Collaborator

shyiko commented May 4, 2018

0.23.1 deployed to Maven Central.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants