-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
InstanceOf and raw types #155
Labels
enhancement
New feature or request
Comments
we could add another |
dmfs
added a commit
that referenced
this issue
Dec 28, 2023
This provides a Quality similar to `istanceOf` but also taking `Quality`s of subclasses of the given class. This is unsafe because there is no guarantee that the testee is actually of that subtype, but it may be required if the testee is a generic class.
dmfs
added a commit
that referenced
this issue
Dec 28, 2023
This provides a Quality similar to `istanceOf` but also taking `Quality`s of subclasses of the given class. This is unsafe because there is no guarantee that the testee is actually of that subtype, but it may be required if the testee is a generic class. It solves issues like described in hamcrest/JavaHamcrest#388
dmfs
added a commit
that referenced
this issue
Dec 28, 2023
This provides a Quality similar to `istanceOf` but also taking `Quality`s of subclasses of the given class. This is unsafe because there is no guarantee that the testee is actually of that subtype, but it may be required if the testee is a generic class. It solves issues like described in hamcrest/JavaHamcrest#388
dmfs
added a commit
that referenced
this issue
Dec 28, 2023
This provides a Quality similar to `istanceOf` but also taking `Quality`s of subclasses of the given class. This is unsafe because there is no guarantee that the testee is actually of that subtype, but it may be required if the testee is a generic class. It solves issues like described in hamcrest/JavaHamcrest#388
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In theory Confidence should be able to support something like hamcrest/JavaHamcrest#388, like this:
The problem, however, is, that
instanceOf
does not play well with raw types but we can't pass aClass
instance of a generic type (because there is no such thing). The problem is that a genericMap
type is never a supertype of a raw type.Changing the
InstanceOf
constructor fromto
indeed fixes the issue because you can now pass a
Quality
for any subtype ofV
but that's not really type safe anymore because there is no guarantee that the tested instance is indeed aQ
.This would compile now (it doesn't without this change) but the test would fail with a
ClassCastException
This needs to be considered carefully because it's not possible to achieve both, supporting
instanceOf
with raw types and type safe casting, at the same time.The text was updated successfully, but these errors were encountered: