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

Upgrade Kotlin to v2.0 #3594

Merged
merged 6 commits into from
Oct 10, 2024
Merged

Upgrade Kotlin to v2.0 #3594

merged 6 commits into from
Oct 10, 2024

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Oct 3, 2024

Content

  • Upgrade Kotlin to v2.0.20.
  • Change deprecated gradle configs.
  • Use the setupAnvil() method in some gradle modules that added the anvil plugin manually instead.
  • Fix deprecations and lint issues.
  • Add LambdaSuspendRecorder since Kotlin 2.0+ differentiates between a () -> Unit lambda and a suspend () -> Unit so we need a special one for suspend lambdas.

Motivation and context

Keeping the dev env up to date.

Tests

Let's keep an eye on the CI.

The app runs fine when built locally.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https:/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

@jmartinesp jmartinesp added the PR-Dependencies Pull requests that update a dependency file label Oct 3, 2024
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.82%. Comparing base (ff08a97) to head (1347770).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...screens/createaccount/WebViewMessageInterceptor.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3594      +/-   ##
===========================================
+ Coverage    82.77%   82.82%   +0.05%     
===========================================
  Files         1747     1747              
  Lines        41391    41742     +351     
  Branches      5015     5102      +87     
===========================================
+ Hits         34261    34573     +312     
+ Misses        5358     5355       -3     
- Partials      1772     1814      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp
Copy link
Member Author

Depends on element-hq/matrix-rich-text-editor#24 to build without warnings.

Copy link
Contributor

github-actions bot commented Oct 4, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/EPh5rW

@jmartinesp jmartinesp marked this pull request as ready for review October 4, 2024 19:08
@jmartinesp jmartinesp requested a review from a team as a code owner October 4, 2024 19:08
@jmartinesp jmartinesp requested review from bmarty and removed request for a team October 4, 2024 19:08
@jmartinesp
Copy link
Member Author

I believe this is ready to test now.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 2 non-blocking remarks.

/**
* A recorder that can be used to record the parameters of a suspend lambda invocation.
*/
abstract class LambdaSuspendRecorder internal constructor(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not add all those classes and fun, but rather fix the lambda type so that they do not expect a suspend qualifier.

Worth case we can use runBlocking in the lambda body (this are tests, not production code) if this is calling a suspend fun. There is only one case like this AFAICT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. At first I though it wouldn't be possible since I was getting other errors related to NoSuchMethodError but it seems like using runBlocking properly does help.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Let me check why it was necessary to add return runBlocking { block() } in all the Lambda*Recorder classes. Since block does not suspend, I do not see how it helps. I was thinking about adding it on demand at the call site.

@@ -117,4 +117,8 @@

<!-- Compose -->
<issue id="UnnecessaryComposedModifier" severity="error" />

<!-- There seems to be an issue with this check, it flags lots of false positives. -->
<!-- TODO: check again in the near future. -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listOf(value(MobileScreen.ScreenName.RoomCall)),
listOf(value(MobileScreen.ScreenName.RoomCall))
)
analyticsLambda.assertions().isCalledOnce().with(value(MobileScreen.ScreenName.RoomCall))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that this "bug" is fixed. Do you have any idea why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to be honest. I originally changed this code some time ago 😓 .

tools/lint/lint.xml Outdated Show resolved Hide resolved
Co-authored-by: Benoit Marty <[email protected]>
Copy link

sonarcloud bot commented Oct 10, 2024

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 10, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 10, 2024
@jmartinesp jmartinesp enabled auto-merge (squash) October 10, 2024 08:15
@jmartinesp jmartinesp merged commit 366db47 into develop Oct 10, 2024
29 of 30 checks passed
@jmartinesp jmartinesp deleted the misc/jme/kotlin-2.0 branch October 10, 2024 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants