airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView

Home Page:https://goo.gl/eIK82p

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error: incompatible types: Function1<CAP#1,Unit> cannot be converted to

mobilekosmos opened this issue · comments

error: incompatible types: Function1<CAP#1,Unit> cannot be converted to Function1<? super Pair<? extends PredefinedDateRange,? extends DayOfWeek>,Unit>
super.onPredefinedRangeSelected = onPredefinedRangeSelected;
^
where CAP#1 is a fresh type-variable:
CAP#1 extends Object super: Pair<PredefinedDateRange,DayOfWeek> from capture of ? super Pair<PredefinedDateRange,DayOfWeek>
1 error

This code is causing it:

@EpoxyModelClass
abstract class FilterDateDynamicItemModel :
    ViewBindingKotlinModel<ItemFilterDateDynamicBinding>(R.layout.item_filter_date_dynamic) {

    @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
    lateinit var onPredefinedRangeSelected: (Pair<FilterData.PredefinedDateRange, java.time.DayOfWeek?>) -> Unit

enum class PredefinedDateRange(val stringResId: Int) {

Any idea how to solve this?

This was working before updating the epoxy lib to the latest version.

I believe I may be running into the same issue after upgrading to 5.1.3. This issue is not present on 5.1.1.

I have made a repository with the minimal amount of code necessary to reproduce the issue:
https://github.com/stephen-mojo/epoxy-issue-repro

When you attempt to build this project, you get the following error:

/epoxy-issue-repro/app/build/generated/ksp/debug/java/com/example/epoxyissuerepro/MyEpoxyModel_.java:146: error: incompatible types: List<CAP#1> cannot be converted to List<MyEnum>
    return myEnums;
           ^
  where CAP#1 is a fresh type-variable:
    CAP#1 extends MyEnum from capture of ? extends MyEnum

It appears that the generated subclass for the EpoxyModel changes between the two versions.

In 5.1.1 (works):

...

@NonNull
public List<MyEnum> myEnums() {
  return super.getMyEnums();
}

...

In 5.1.3 (does not work):

...

@NonNull
public List<MyEnum> myEnums() {
  return myEnums;
}

...