Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make language imports available after Typer #14346

Closed
olhotak opened this issue Jan 25, 2022 · 1 comment · Fixed by #14364
Closed

make language imports available after Typer #14346

olhotak opened this issue Jan 25, 2022 · 1 comment · Fixed by #14364

Comments

@olhotak
Copy link
Contributor

olhotak commented Jan 25, 2022

In #14319 and #13976, we need a way to know whether we are in unsafe nulls mode in later phases after Typer. I discussed with @odersky and we came up with a general approach to make language imports available in later phases.

  1. Modify FirstTransform to keep language imports.
  2. In MegaPhase, clone and modify mapInline (called from transformStats) so that it can pass a context to the op. When this new mapInline sees an import, it should create importContext to pass to later stats. mapInline is performance sensitive so this has to be done carefully.

If we do the above in general, for the specific case of unsafe nulls, the existing handling in setImportInfo will automatically set the Mode.SafeNulls flag accordingly.

@odersky
Copy link
Contributor

odersky commented Jan 26, 2022

I can take care of this.

@odersky odersky self-assigned this Jan 26, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 26, 2022
Some phases might need to know what language imports are active. Concretely, uner
explicit nulls, the exhaustivity checks for patterns need to know that. We therefore
keep language imports until phase PruneErasedDefs. Other imports are dropped in
FirstTransform, as before.

The handling of statements in MegaPhase was changed so that imports now are visible
in the context for transforming the following statements.

Fixes scala#14346
Xavientois pushed a commit to Xavientois/dotty that referenced this issue Feb 2, 2022
Some phases might need to know what language imports are active. Concretely, uner
explicit nulls, the exhaustivity checks for patterns need to know that. We therefore
keep language imports until phase PruneErasedDefs. Other imports are dropped in
FirstTransform, as before.

The handling of statements in MegaPhase was changed so that imports now are visible
in the context for transforming the following statements.

Fixes scala#14346
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Some phases might need to know what language imports are active. Concretely, uner
explicit nulls, the exhaustivity checks for patterns need to know that. We therefore
keep language imports until phase PruneErasedDefs. Other imports are dropped in
FirstTransform, as before.

The handling of statements in MegaPhase was changed so that imports now are visible
in the context for transforming the following statements.

Fixes scala#14346
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants