2

I have simple getter and setter for a boolean field in Java interface:

public interface Interface1 {
    void setValue1(boolean value);
    boolean getValue1();
}

When trying to implement that as a property in a class in Kotlin:

class Class1: Interface1 {
    var value1 = false
} 

I get the compilation error:

Class 'Class1' is not abstract and does not implement abstract member public abstract fun setValue1(value: Boolean): Unit defined in com.example.Interface1.

So only the getter is overridden. Is it possible to fix that without implementing the both getter and setter manually, without kotlin "sugar"?

1 Answer 1

2

https://youtrack.jetbrains.com/issue/KT-6653 says

This is a rather deep issue, unfortunately. It's unlikely that we'll ever make it work the way you'd like

and this stance doesn't seem to have changed since 2015.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for the answer Alexey! I was afraid it is like that, just hoped that I'm wrong...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.