Skip to content

Conversation

@ambushwork
Copy link
Member

What does this PR do?

The Kotlin compiler plugin relies on Kotlin-embeddable for Intermediate Representation phase,
when plugin is running in the host application during the compilation, the Kotlin version from Android Gradle Tool will override the one in plugin during the runtime.

For example, if the Android Gradle Tool version is "8.8.2", the kotlin "1.9.24" version from it will be actually used during the runtime of the plugin despite "2.0.20" is declared in the plugin project. And since it's a major version change, it leads some binary compatibility issue which makes build failed.

The main idea of this PR is to check the known broken API version, by checking function signature, visibility, etc.. to instantiate it by reflection if we find it's not compatible with the compilation version.

Here is a list of breaking APIs:

Usage Version 1.9 Version 2.0
IrDeclarationOrigin.FAKE_OVERRIDE object of an interface companion object property of an interface
IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA object of an interface companion object property of an interface
IrDeclarationOrigin.DEFINED object of an interface companion object property of an interface
IrFunctionExpressionImpl a class constructor top level function
IrValueParameterSymbolImpl class constructor with one argument class constructor with several arguments
IrSimpleFunctionSymbolImpl class constructor with one argument class constructor with several arguments

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 59.09091% with 18 lines in your changes missing coverage. Please review.

Project coverage is 76.96%. Comparing base (2b62ffc) to head (8770031).

Files with missing lines Patch % Lines
...main/kotlin/com/datadog/gradle/plugin/kcp/IrExt.kt 59.09% 13 Missing and 5 partials ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##             feature/kotlin-compiler-plugin     #345      +/-   ##
====================================================================
- Coverage                             77.87%   76.96%   -0.91%     
+ Complexity                              352      351       -1     
====================================================================
  Files                                    42       42              
  Lines                                  1374     1402      +28     
  Branches                                163      170       +7     
====================================================================
+ Hits                                   1070     1079       +9     
- Misses                                  214      227      +13     
- Partials                                 90       96       +6     
Files with missing lines Coverage Δ
...main/kotlin/com/datadog/gradle/plugin/kcp/IrExt.kt 78.72% <59.09%> (-18.25%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ambushwork ambushwork marked this pull request as ready for review March 26, 2025 17:47
@ambushwork ambushwork requested review from a team as code owners March 26, 2025 17:47
@ambushwork ambushwork requested a review from 0xnm March 27, 2025 13:01
@ambushwork ambushwork merged commit e6b9910 into feature/kotlin-compiler-plugin Mar 27, 2025
13 checks passed
@ambushwork ambushwork deleted the yl/kcp/kotlin-1.9-back-compact branch March 27, 2025 14:41
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.

4 participants