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

Support subclass safety overrides #2289

Merged
merged 3 commits into from
Jun 7, 2022

Conversation

carterkozak
Copy link
Contributor

@carterkozak carterkozak commented Jun 6, 2022

Before this PR

Casting from an unsafe-annotated interface to a safe-annotated interface produced UNSAFE data.

After this PR

==COMMIT_MSG==
Trust type safety on cast results, based on validation that occurred when the type was created.
==COMMIT_MSG==

Possible downsides?

The behavior this allows breaks several of our assumptions, and may cause issues elsewhere.

However there are cases where this is reasonable that don't break any assumptions, for instance:

void arbitraryObjectConsumer(@Unsafe Object input) {
    if (input instanceof SafeType) {
        // this is absolutely safe, the inputs to `arbitraryObjectConsumer` are just known
        // to allow unsafe values, they aren't required to be unsafe. All values of a safe type
        // MUST be safe.
        SafeType safe = (SafeType) input;
    }
}

@changelog-app
Copy link

changelog-app bot commented Jun 6, 2022

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Trust type safety on cast results, based on validation that occurred when the type was created.

Check the box to generate changelog(s)

  • Generate changelog entry

@carterkozak carterkozak requested a review from fawind June 6, 2022 16:06
@carterkozak carterkozak marked this pull request as ready for review June 6, 2022 16:07
@bulldozer-bot bulldozer-bot bot merged commit ef30ba4 into develop Jun 7, 2022
@bulldozer-bot bulldozer-bot bot deleted the ckozak/support_subclass_safety_overrides branch June 7, 2022 10:15
@svc-autorelease
Copy link
Collaborator

Released 4.141.0

This was referenced Jun 7, 2022
bulldozer-bot bot pushed a commit to palantir/witchcraft-api that referenced this pull request Jun 7, 2022
###### _excavator_ is a bot for automating changes across repositories.

Changes produced by the roomba/latest-baseline-oss check.

# Release Notes
## 4.141.0
| Type | Description | Link |
| ---- | ----------- | ---- |
| Improvement | Trust type safety on cast results, based on validation that occurred when the type was created. | palantir/gradle-baseline#2289 |



To enable or disable this check, please contact the maintainers of Excavator.
This was referenced Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants