Java: Improve finding best type for models and lifting. #16374
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.
In this PR
The idea with the lifting logic is to make models as general as possible.
Assume that
B <: A
(B
is a subtype ofA
orB
is an implementation ofA
) and assume that we havemethods
B.M
andA.M
whereB.M
is an override or implementation ofA.M
. In case the model generator finds a summary modelS
forB.M
we lift the model toA.M
(that is, we assume thatA.M
exhibits the same flow asB.M
as this is perceived as a part of the override/implementation contract).The old logic
superImpl
withliftedImpl
, which gives us a unique best callable to lift a model to (maybe the callable itself), if it is relevant to make a model for the callable.Furthermore, we now only lift models to callables that are also in source. It seems a bit of stretch that if one implements an interface from an imported package and flow is identified for a method then we lift to the callable in the imported package (we could risk getting very odd models for stuff in the Java SDK).
As a test the models for the Java SDK were re-generated and it appears that
internal
were not generated.AbstractStringBuilder
(which is package internal) will be only lifted to the relevant public endpoints.