Repository navigation
Weaken subtyping assertion for invokevirtual of an interface method - #14886
Merged
0xdaryl merged 1 commit intoApr 9, 2022
Merged
Conversation
We don't necessarily know that callSiteClass is a subtype of the _receiverClass, which may have been refined to a more specific interface. In particular, the following situation can arise: - This call site is calling callSiteClass.callee(), and callSiteClass inherits callee() from an interface defInterface, so the callee method appears to be defInterface.callee(). - The receiver comes from somewhere in the calling context with signature subInterface, which is a sub-interface of defInterface. - _receiverClass is refined from defInterface to subInterface based on the calling context. - callSiteClass implements defInterface but not subInterface. We know for certain that it implements defInterface because it inherits the callee from there. The assertion now checks this less specific typing relationship instead of checking against _receiverClass. - Actual receivers are most likely to be instances of subclasses of callSiteClass that do implement subInterface. They might also be instances of callSiteClass but not subInterface (e.g. instances of exactly callSiteClass), which can happen despite the signature because signatures are unreliable when they name interface types. When this happens, callSiteClass is not a refinement of _receiverClass (i.e. of subInterface), but it is a better refinement of defInterface. It's fine to go on and replace _receiverClass, since effectively that's just forgetting the earlier refinement and then refining again with callSiteClass instead.
lmgray
approved these changes
Apr 8, 2022
There was a problem hiding this comment.
I can vouch for the fix as far as the original problem I reported is concerned -- using a test fix from @jdmpapin , I looped our previously failing build 100+ times with no failures -- previously, this build would fail consistently every 3-5 builds
Contributor
|
Jenkins test sanity.functional,extended.functional all jdk11,jdk17 |
0xdaryl
approved these changes
Apr 9, 2022
Contributor
|
Please create a 0.32 release PR for this fix as well. |
Contributor
Author
|
Opened #14898 for 0.32 |
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.
We don't necessarily know that
callSiteClassis a subtype of the_receiverClass, which may have been refined to a more specific interface. In particular, the following situation can arise:This call site is calling
callSiteClass.callee(), andcallSiteClassinheritscallee()from an interfacedefInterface, so the callee method appears to bedefInterface.callee().The receiver comes from somewhere in the calling context with signature
subInterface, which is a sub-interface ofdefInterface._receiverClassis refined fromdefInterfacetosubInterfacebased on the calling context.callSiteClassimplementsdefInterfacebut notsubInterface. We know for certain that it implementsdefInterfacebecause it inherits the callee from there. The assertion now checks this less specific typing relationship instead of checking against_receiverClass.Actual receivers are most likely to be instances of subclasses of
callSiteClassthat do implementsubInterface. They might also be instances ofcallSiteClassbut notsubInterface(e.g. instances of exactlycallSiteClass), which can happen despite the signature because signatures are unreliable when they name interface types.When this happens,
callSiteClassis not a refinement of_receiverClass(i.e. ofsubInterface), but it is a better refinement ofdefInterface. It's fine to go on and replace_receiverClass, since effectively that's just forgetting the earlier refinement and then refining again withcallSiteClassinstead.Fixes #14526