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

Fix enum switch for Kotlin 1.7.10 #457

Closed
wants to merge 1 commit into from

Conversation

bounty1342
Copy link

Describe the bug

Compilation issue with Kotlin 1.7.10.
/builds/projet-root/.pub-cache/hosted/pub.dartlang.org/device_calendar-4.2.0/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt: (772, 9): 'when' expression must be exhaustive, add necessary 'DAILY', 'HOURLY', 'MINUTELY', 'SECONDLY' branches or 'else' branch instead
[282](https://gitlab.socrate.vsct.fr/projet-root/-/jobs/14970613#L282)FAILURE: Build failed with an exception.

Actual code

       when (rfcRecurrenceRule.freq) {
            Freq.WEEKLY, Freq.MONTHLY, Freq.YEARLY -> {
                recurrenceRule.daysOfWeek = rfcRecurrenceRule.byDayPart?.mapNotNull {
                    DayOfWeek.values().find { dayOfWeek -> dayOfWeek.ordinal == it.weekday.ordinal }
                }?.toMutableList()
            }
        }

Proposed correction code

       when (rfcRecurrenceRule.freq) {
            Freq.WEEKLY, Freq.MONTHLY, Freq.YEARLY -> {
                recurrenceRule.daysOfWeek = rfcRecurrenceRule.byDayPart?.mapNotNull {
                    DayOfWeek.values().find { dayOfWeek -> dayOfWeek.ordinal == it.weekday.ordinal }
                }?.toMutableList()
            }
            else -> null
        }

Let me know if you need more information.

Regards

@IVLIVS-III
Copy link
Contributor

The code change itself looks good.
Could you please open an identical PR to the develop-branch instead? develop is the main/master branch of this project.

@bounty1342
Copy link
Author

Apparently something you fix in the develop branch already :

    val frequency = when (rfcRecurrenceRule.freq) {
        RruleFreq.YEARLY -> RruleFreq.YEARLY
        RruleFreq.MONTHLY -> RruleFreq.MONTHLY
        RruleFreq.WEEKLY -> RruleFreq.WEEKLY
        RruleFreq.DAILY -> RruleFreq.DAILY
        else -> null
    } ?: return null
    //Avoid handling HOURLY/MINUTELY/SECONDLY frequencies for now

Do you have any ETA for a new release or maybe push the fix on release ?
I can also use the fork in the meantime ;)

@IVLIVS-III
Copy link
Contributor

Unfortunately, I cannot give an ETA for the new release.
See #445 which tracks the progress. Looks like the only thing blocking a new release at the moment is achieving a bit more compatibility with the RecurrenceRule implementation of versions < 5.0.

Personally, I'm most likely not able to put enough work into this project to push the (pre-)release within two / three weeks. Early December I could have more time, no promises tho.

@thomassth
Copy link
Contributor

Closing this since apparently it's fixed

Also this is submitted to the wrong branch. Please submit PR to develop instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants