-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Using ktlint - f remove wrong semi colon #281
Comments
Hi @Mathieu-Heuzey. Any chance you can provide a complete example? Thanks. |
Here is my first class with my companion object
Here is my extension function
Then, when i run "ktlint -F", my semicolon after my companion object will be removed, and without it it does not compile. Is that clear for you or you need more than an example ? |
Thank you. That's all I need. I'll have a fix shortly. As temporary workaround please use:
(for future reference (looks like kotlin compiler bug)): $ cat FirstClass.kt
class FirstClass(private val param: String) {
// Needed to add more properties as extension function outside of it
companion object;
private var toto: Boolean = false
}
fun FirstClass.Companion.create(c: Context) {
return
}
class Context
$ ktlint FirstClass.kt
/tmp/FirstClass.kt:4:21: Unnecessary semicolon
$ kotlinc FirstClass.kt
$ ktlint -F FirstClass.kt
$ kotlinc FirstClass.kt
FirstClass.kt:9:16: error: unresolved reference: Companion
fun FirstClass.Companion.create(c: Context) {
^ |
thanks i will try the fix ! |
Fixed in 0.29.0. |
Hello guys, i had an issue using the command "ktlint -f".
I have a kotlin class declaring a companion object like this "companion object;", I needed it to add more properties as extension function outside of it .
but when i use the command "ktlint -f" the semi colon is removed, and the my project does not compile because the companion object is not found anymore.
The text was updated successfully, but these errors were encountered: