Skip to content

Invariant Union? #1574

Answered by erictraut
treykeown asked this question in Q&A
Jan 11, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

There's no way to specify an "exact type" in any typing construct. From a type theory standpoint, any subclass of Foo is also a Foo.

One potential solution is to mark Foo as @final which would prevent any subclasses from being defined.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@treykeown
Comment options

@erictraut
Comment options

Answer selected by treykeown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants