inferTypeVariables: insert Anys in Map when applicable#22
Merged
Conversation
Member
Author
|
After a bit of testing, I realized these errors come from attempting to infer type variables from:
These situations are all solved (well, the tests will fail until we solve the |
7449576 to
d90442c
Compare
This situation comes up often when calling something along the lines of:
ops.op("name").inType(Double.class).apply()
which creates an OpRef looking for a
Function<Double, Object>
Suppose the Op we wanted to match was a
Function<I, Iterable<O>>
(Disregard how bad of a Function typing this is)
MatchingUtils.inferTypeVariables() did not put the O in its
typeMappings, which throws IAEs later on. This is specifically because
Object IS NOT a superType of Iterable (and therefore I do not think this
problem can occur with any type other than Object??).
This problem is solved by adding Anys whenever an Object is found.
This is a better option going forward, and we now do not have to mess with the Eclipse formatter.
This test focuses on the assignment Function<Double, Object> <- Function<T, List<T>> where T extends Number This is ONLY safely assignable, since this is not compile-time safe.
This test should be differentiated from the no output tests within OpBuilderTest in that tests within this class are more complex. The no-output tests within OpBuilderTest merely ensure that a) the methods continue to exist and b) that basic functionality is available. This class tests more complicated functionality contingent on no output (which is currently limited to ensuring ParameterizedType outputs do not cause error when no output is specified)
Interfaces and Classes (without type variables) will face a similar problem as Objects (which was earlier solved)
d90442c to
dee9d1b
Compare
Member
Author
|
@ctrueden I just rebased this over |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes scijava/scijava#49
TODO:
Finish testing
Any.equals()for testing purposes, however we must decide the semantics. When should twoAnys be considered equal? Are there cases when otherObjects (that are notAnys) should be considered equal?Types can this scenario occur?Objectis special in thatTypes.getExactSuperTypewill returnnull(notObject) for a callTypes.getExactSuperType(i, Object.class)for any interfacei(sinceObjectis not a supertype ofi).Clean
inferTypeVariables(ParameterizedType type, ...)