question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prefixing @EpoxyAttribute variable with "is" causes compile error

See original GitHub issue

Not sure what’s going on here.

I’m creating my models in Kotlin and have an attribute as follows @EpoxyAttribute var isChildComment: Boolean = false

This causes a compile error in the generated class error: isChildComment() in VideoCommentModel_ cannot override isChildComment() in VideoCommentModel public boolean isChildComment() { ^ overridden method is final

If I change the attribute to the following, the compile error is resolved @EpoxyAttribute var childComment: Boolean = false or @EpoxyAttribute var ischildComment: Boolean = false

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
elihartcommented, Jun 29, 2018

In your original version the equivalent bytecode is

public abstract class Test extends EpoxyModel {
   @EpoxyAttribute
   private boolean isChildComment;

   public final boolean isChildComment() {
      return this.isChildComment;
   }

   public final void setChildComment(boolean var1) {
      this.isChildComment = var1;
   }
}

kotlin makes the getter final

Epoxy’s generated model creates a getter for each attribute though, which calls the original model’s getter. In this case epoxy’s generated method has the same name for the getter, which is only the case for booleans.

the bytecode with jvm field is

public abstract class Test extends EpoxyModel {
   @JvmField
   @EpoxyAttribute
   public boolean isChildComment;
}

so the field is accessed directly.

you can explore the generated kotlin bytecode and the generated epoxy model code to understand it better.

Whether it’s a bug or not, well, epoxy could be changed to not generate a getter if one already exists, but it’s not a high priority

4reactions
ghostcommented, Jun 27, 2018

If you add @JvmField to the field, that error should go away.

For some reason, we have issues with boolean values and epoxy attribute as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

detox build fails on mac, nvm not compatible with the "PREFIX ...
It used to set the $PREFIX env variable for no reason. Now it is fixed, see: https://github.com/npm/cli/issues/2398.
Read more >
Multiple SCSS packages (Bootstrap & Fontawesome) compile ...
it's always an “Undefined variable” error. I can't get my head around it. Any ideas?
Read more >
Java Examples for java.lang.annotation.Target - Javatips.net
This java examples will help you to understand the usage of java.lang.annotation.Target. These source code samples are taken from different open source ...
Read more >
Fixing React Native build error nvm is not compatible with the ...
Fixing React Native build error nvm is not compatible with the “PREFIX” environment variable. While building base of the React Native app ...
Read more >
Download Diff File - Gogs: Go Git Service
+ +Code generated by the Protocol Buffer compiler is owned by the owner +of the ... + work stoppage, computer failure or malfunction,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found