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

Custom function with entity property of same name fails in version 2.3.4 #720

Closed
dreamcatcha opened this issue Jun 12, 2019 · 4 comments

Comments

@dreamcatcha
Copy link

commented Jun 12, 2019

Issue Basics

  • ObjectBox version 2.3.4
  • Reproducibility: always

Reproducing the bug

In an entity I have a property,

private Integer isVerified = 0;

with the following getter and setter and custom method of the same name

public Integer getIsVerified() {
    return isVerified;
}

public Boolean isVerified() {
    return isVerified == 1;
}

public void setIsVerified(Integer isVerified) {
    this.isVerified = isVerified;
}

Before the latest version 2.3.4 I have no problem with this code but in the latest I get this error;

error: incompatible types: Boolean cannot be converted to Integer

If I remove the IsVerified() function it works but I want to know how to still use it in the latest version

Cheers

@greenrobot-team

This comment has been minimized.

Copy link
Collaborator

commented Jun 18, 2019

This is due to extended Kotlin support. In Kotlin any property prefixed with is will have an is getter. So if ObjectBox finds one it will try to use that one.

See #658 and https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html#properties

Maybe we can improve this by checking for the return type as well.

-Uwe

@greenrobot-team greenrobot-team added the bug label Jun 18, 2019
@greenrobot-team greenrobot-team self-assigned this Jun 18, 2019
@dreamcatcha

This comment has been minimized.

Copy link
Author

commented Jun 18, 2019

Ah ok, I don't use kotlin in my app, but it would be good to do the return checking

Cheers

@greenrobot-team greenrobot-team added this to the 2.4.0 milestone Jul 15, 2019
@greenrobot-team

This comment has been minimized.

Copy link
Collaborator

commented Sep 16, 2019

This was fixed internally (the return type of the getter is now considered as well) and will be available with the next update.

Thanks again.

@greenrobot

This comment has been minimized.

Copy link
Member

commented Oct 3, 2019

This is also part of the just released version '2.4.0-RC' - would be great if you could give it a try and report back. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.