licensee icon indicating copy to clipboard operation
licensee copied to clipboard

Eliminate redundant synthetic overloads in LicenseeExtension

Open Goooler opened this issue 2 months ago • 15 comments


  • [x] CHANGELOG.md's "Unreleased" section has been updated, if applicable.

Goooler avatar Oct 23 '25 02:10 Goooler

This doesn't seem safe, nor desired. For one, it breaks binary compatibility if on the VERY rare chance someone has compiled their own plugin against our API. But aside from that, it exposes multiple overloads of the same functions to Kotlin when it really only should ever see one.

JakeWharton avatar Oct 23 '25 02:10 JakeWharton

Going to preemptively close. Let me know if you have a different take.

JakeWharton avatar Oct 23 '25 16:10 JakeWharton

it breaks binary compatibility if on the VERY rare chance someone has compiled their own plugin against our API

I tested the case, it's binary compatible for code written in Java and Kotlin, which implements LicenseeExtension. BTW, it allows users to override the six functions marked as @JvmSynthetic before, if they want.

it exposes multiple overloads of the same functions to Kotlin when it really only should ever see one

it doesn't change the number of overloads for Kotlin.

image
METHODS:

   old │ new │ diff       
  ─────┼─────┼────────────
   754 │ 746 │ -8 (+0 -8) 
  
  - app.cash.licensee.LicenseeExtension allowDependency$default(LicenseeExtension, String, String, String, Action, int, Object)
  - app.cash.licensee.LicenseeExtension allowDependency$default(LicenseeExtension, Provider, Action, int, Object)
  - app.cash.licensee.LicenseeExtension allowDependency$lambda$2(LicenseeExtension$AllowDependencyOptions)
  - app.cash.licensee.LicenseeExtension allowDependency$lambda$3(LicenseeExtension$AllowDependencyOptions)
  - app.cash.licensee.LicenseeExtension allowUrl$default(LicenseeExtension, String, Action, int, Object)
  - app.cash.licensee.LicenseeExtension allowUrl$lambda$1(LicenseeExtension$AllowUrlOptions)
  - app.cash.licensee.LicenseeExtension ignoreDependencies$default(LicenseeExtension, String, String, Action, int, Object)
  - app.cash.licensee.LicenseeExtension ignoreDependencies$lambda$2(LicenseeExtension$IgnoreDependencyOptions)

Goooler avatar Oct 24 '25 09:10 Goooler

Kotlin should not be seeing the functions which don't have the Action.

JakeWharton avatar Oct 24 '25 11:10 JakeWharton

And it will be binary incompatible if a Kotlin caller is invoking one of the functions without specifying an Action, as their code will link against the $default version of the function which has now been removed.

JakeWharton avatar Oct 24 '25 11:10 JakeWharton

Kotlin should not be seeing the functions which don't have the Action.

Actually, they can see the functions without the PR or not.

And it will be binary incompatible if a Kotlin caller is invoking one of the functions without specifying an Action

I can't reproduce, is there something missing?

image

Goooler avatar Oct 27 '25 04:10 Goooler

Your script is being recompiled–that's testing source compatibility. For binary compatibility you need to compile a class against the old API and then try to run it with the new API.

JakeWharton avatar Oct 27 '25 13:10 JakeWharton

image

I tried, and it works for both.

Goooler avatar Oct 27 '25 14:10 Goooler

Okay I tried and it seems like we just were lucky here in that Kotlin will always link against the non-default function where possible. I originally meant to hide the other variants from being visible from Kotlin, too.

I think we want to use @JvmOverloads, though, as that will retain binary compatibility while also only presenting a single function to Kotlin.

JakeWharton avatar Nov 07 '25 15:11 JakeWharton

@JvmOverloads is good, but can't be used in interfaces.

Goooler avatar Nov 07 '25 15:11 Goooler

We could switch to an abstract class. I can't remember if they work there. Nor can I remember if that's binary compatible.

JakeWharton avatar Nov 07 '25 16:11 JakeWharton

It will break binary compatible if an interfere extends LicenseeExtension. I would address the convertion into a followup.

Goooler avatar Nov 07 '25 16:11 Goooler

Yeah I'm not concerned about that. No one should be extending it.

JakeWharton avatar Nov 07 '25 16:11 JakeWharton

It's a really busy week. Haven't forgotten about this, though.

JakeWharton avatar Nov 20 '25 02:11 JakeWharton

I see, just rebase for the format conflicts.

Goooler avatar Nov 20 '25 02:11 Goooler