Skip to content

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Dec 29, 2025

In some specific cases, jsii generates some fancy types for unions. For example, in static functions only, it will generate the following signature:

public static void method(java.util.Map<java.lang.String, ? extends java.lang.Object> arg) {
//                                                        ^^^^ check this out!
}

I'm not sure what the value is of doing this; I suspect it doesn't actually provide any additional typing value.

However, I do know that when we combine this with union validation, which generates the following code:

for (final Entry<String, Object> __item_fc3b34: arg.entrySet()) {
  // ...
}

It leads to a compilation failure, because apparently ? extends Object is not assignable to Object (I feel like it should be, but who am I to argue with the Java compiler? I'm sure there are good reasons for it to be this way).

Rather than remove the ? extends Object type from the signature, which I'm not sure what it's for, I'm adjusting the type checker to:

for (final Entry<String, ? extends Object> __item_fc3b34: arg.entrySet()) {
  // ...
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…reak compilation

In some specific cases, jsii generates some fancy types for unions. For example,
in static functions only, it will generate the following signature:

```java
public static void method(java.util.Map<java.lang.String, ? extends java.lang.Object> arg) {
//                                                        ^^^^ check this out!
}
```

I'm not sure what the value is of doing this; I suspect it doesn't
actually provide any additional typing value.

However, I *do* know that when we combine this with union validation,
which generates the following code:

```java
for (final Entry<String, Object> __item_fc3b34: arg.entrySet()) {
  // ...
}
```

It leads to a compilation failure, because apparently `? extends Object`
is not assignable to `Object` (I feel like it should be, but who am I to
argue with the Java compiler? I'm sure there are good reasons for it to
be this way).

Rather than remove the `? extends Object` type from the signature, which
I'm not sure what it's for, I'm adjusting the type checker to:

```java
for (final Entry<String, ? extends Object> __item_fc3b34: arg.entrySet()) {
  // ...
}
@rix0rrr rix0rrr requested a review from a team December 29, 2025 15:36
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 29, 2025
@mergify
Copy link
Contributor

mergify bot commented Dec 29, 2025

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Dec 29, 2025
@mergify
Copy link
Contributor

mergify bot commented Dec 29, 2025

Merging (with squash)...

@mergify mergify bot added the queued label Dec 29, 2025
@mergify
Copy link
Contributor

mergify bot commented Dec 29, 2025

Merge Queue Status

✅ The pull request has been merged at 781b480

This pull request spent 31 minutes 52 seconds in the queue, including 31 minutes 43 seconds running CI.
The checks were run in-place.

Required conditions to merge

@mergify
Copy link
Contributor

mergify bot commented Dec 29, 2025

Merging (with squash)...

@mergify mergify bot merged commit 2970397 into main Dec 29, 2025
35 checks passed
@mergify mergify bot deleted the huijbers/generics-args branch December 29, 2025 16:40
@mergify mergify bot removed pr/ready-to-merge This PR is ready to be merged. queued labels Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants