-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JVM IR: handle JvmStatic in object as module phase
This allows to get rid of the situation where a JvmStatic function in object can be seen in different states in different lowerings: unlowered with a dispatch receiver parameter, declaration is lowered but calls are not, and both declaration and calls are lowered. Now it works like this: 1) JvmStatic functions in objects coming from dependencies are always loaded as lowered, without the extra dispatch receiver parameter. In psi2ir this is done via JVM-specific extension; in fir2ir it's done in place (but probably should be extracted to extension too). 2) Functions from sources are created as unlowered by both psi2ir and fir2ir, and are lowered in a module-wide phase at the beginning of JvmLower. 3) Calls to all JvmStatic functions from objects (from sources and dependencies) are lowered in the same phase at the beginning of JvmLower. This ensures that all lowerings after the module-wide phase `jvmStaticInObjectPhase`, which include all per-file phases, see all JvmStatic functions in objects without the additional dispatch receiver parameter, and calls do not have dispatch receiver either. The only issue with this approach is that function/property reference representation in reflection needs to have that dispatch receiver parameter, and that is achieved via a hack in those lowerings, which seems not too out of place anyway, given that they're handled specially in kotlin-reflect as well.
- Loading branch information
Showing
13 changed files
with
104 additions
and
129 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.