Move generic information to a state memory #1715
Merged
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.
Description
The initial issue occurred since we used to have path-independent generics: if during the analysis we discover, that our class is a subclass of another one, and now we might have other generic info (including a number of type arguments), we would take into account generic information for a random path and apply it for each of them.
During implementation I discovered that there are more problems, e.g., if we have several consecutive generic info in one jimple instruction that should be applied for the same object, the latest one will override the earlier one even if it consists of less information.
Moreover, there was an error with retrieving generic type info with upper type bounds, because of which we created type storage with the wrong
leastCommonType. It could cause an error duringsetorgetoperations forRangeModifiableArraysince it uses only aleastCommonTypeto construct type storage for an object it works with. Because of that, in fact, we didn't use generic types in many situations.Fixes #1668
Type of Change
How Has This Been Tested?
Regression and integration tests
They are the same as automatic tests. But it can be checked using the ContestEstimator: there are no errors for the example from issue #1668
Automated Testing
org.utbot.examples.types.PathDependentGenericsExampleTest#testPathDependentGenericsorg.utbot.examples.types.PathDependentGenericsExampleTest#testFunctionWithSeveralTypeConstraintsForTheSameObjectManual Scenario
There are no specific manual scenarios.
Checklist: