Skip to content

Support subclass safety overrides#2289

Merged
bulldozer-bot[bot] merged 3 commits intodevelopfrom
ckozak/support_subclass_safety_overrides
Jun 7, 2022
Merged

Support subclass safety overrides#2289
bulldozer-bot[bot] merged 3 commits intodevelopfrom
ckozak/support_subclass_safety_overrides

Conversation

@carterkozak
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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.

4 participants