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

Add support for Kotlin Value Classes #2806

Closed
mp911de opened this issue Mar 29, 2023 · 3 comments
Closed

Add support for Kotlin Value Classes #2806

mp911de opened this issue Mar 29, 2023 · 3 comments
Assignees
Labels
in: kotlin Kotlin support status: duplicate A duplicate of another issue type: enhancement A general enhancement

Comments

@mp911de
Copy link
Member

mp911de commented Mar 29, 2023

Right now, we do not detect constructors and constructor arguments for classes that use Kotlin value classes because they do not use typically a defaulting mask.

Also, a lot from the inline classes mashup happens in the sense of rewritten property names, rewritten copy method name. Additionally, nullability infers boxing of value classes so for nullable components, Kotlin boxes values in inline classes and then unboxes these:

public final class KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass {
   @NotNull
   private final String id;

   private KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass(String id) {
      this.id = id;
   }

   // $FF: synthetic method
   public KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass(KotlinClassGeneratingEntityInstantiatorUnitTests.MyNullableInlineClass var1, int var2, DefaultConstructorMarker var3) {
      if ((var2 & 1) != 0) {
         var1 = MyNullableInlineClass.box-impl(MyNullableInlineClass.constructor-impl("foo"));
      }

      this(var1.unbox-impl(), (DefaultConstructorMarker)null);
   }

   @NotNull
   public final String getId_MYsf4WQ/* $FF was: getId-MYsf4WQ*/() {
      return this.id;
   }

   @NotNull
   public final String component1_MYsf4WQ/* $FF was: component1-MYsf4WQ*/() {
      return this.id;
   }

   @NotNull
   public final KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass copy_jv4avjM/* $FF was: copy-jv4avjM*/(@NotNull String id) {
      return new KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass(id, (DefaultConstructorMarker)null);
   }

   // $FF: synthetic method
   public static KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass copy_jv4avjM$default/* $FF was: copy-jv4avjM$default*/(KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass var0, KotlinClassGeneratingEntityInstantiatorUnitTests.MyNullableInlineClass var1, int var2, Object var3) {
      if ((var2 & 1) != 0) {
         var1 = MyNullableInlineClass.box-impl(var0.id);
      }

      return var0.copy-jv4avjM(var1.unbox-impl());
   }

   @NotNull
   public String toString() {
      // …
   }

   public int hashCode() {
      // …
   }

   public boolean equals(@Nullable Object other) {
      // …
   }

   // $FF: synthetic method
   public KotlinClassGeneratingEntityInstantiatorUnitTests$WithMyNullableInlineClass(String id, DefaultConstructorMarker $constructor_marker) {
      this(id);
   }
}
@mp911de
Copy link
Member Author

mp911de commented Mar 29, 2023

See also #1947

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 29, 2023
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 30, 2023
@mp911de mp911de self-assigned this Mar 30, 2023
@mp911de mp911de added the status: pending-design-work Needs design work before any code can be developed label Mar 30, 2023
@mp911de
Copy link
Member Author

mp911de commented Mar 30, 2023

Branch at https://github.com/spring-projects/spring-data-commons/tree/issue/2806

@mp911de mp911de linked a pull request Jun 22, 2023 that will close this issue
@mp911de mp911de added in: kotlin Kotlin support and removed status: pending-design-work Needs design work before any code can be developed labels Jun 28, 2023
@mp911de mp911de changed the title Add support for Kotlin value classes Add support for Kotlin Value Classes Jun 28, 2023
@mp911de mp911de added the status: duplicate A duplicate of another issue label Jun 28, 2023
@mp911de
Copy link
Member Author

mp911de commented Jun 28, 2023

Closing as duplicate of #1947, which handles mangling, wrapping, instantiation, and property access.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
@mp911de mp911de removed a link to a pull request Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: kotlin Kotlin support status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants