-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Keep language imports around longer #14364
Changes from 1 commit
b1aee82
1bc6cb9
9c668f3
7608bb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,15 @@ import StdNames.nme | |
import ast.tpd | ||
import SymUtils._ | ||
import config.Feature | ||
import Decorators.* | ||
|
||
/** This phase makes all erased term members of classes private so that they cannot | ||
* conflict with non-erased members. This is needed so that subsequent phases like | ||
* ResolveSuper that inspect class members work correctly. | ||
* The phase also replaces all expressions that appear in an erased context by | ||
* default values. This is necessary so that subsequent checking phases such | ||
* as IsInstanceOfChecker don't give false negatives. | ||
* Finally, the phase drops (language-) imports. | ||
*/ | ||
class PruneErasedDefs extends MiniPhase with SymTransformer { thisTransform => | ||
import tpd._ | ||
|
@@ -54,10 +56,18 @@ class PruneErasedDefs extends MiniPhase with SymTransformer { thisTransform => | |
checkErasedInExperimental(tree.symbol) | ||
tree | ||
|
||
override def transformOther(tree: Tree)(using Context): Tree = tree match | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about making a separate miniphase for this but it's probably not worth the overhead of boilerplate. If we want to move the dropping of imports, we can easily split it out into a separate miniphase later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that was my thinking also. |
||
case tree: Import => EmptyTree | ||
case _ => tree | ||
|
||
def checkErasedInExperimental(sym: Symbol)(using Context): Unit = | ||
// Make an exception for Scala 2 experimental macros to allow dual Scala 2/3 macros under non experimental mode | ||
if sym.is(Erased, butNot = Macro) && sym != defn.Compiletime_erasedValue && !sym.isInExperimentalScope then | ||
Feature.checkExperimentalFeature("erased", sym.sourcePos) | ||
|
||
override def checkPostCondition(tree: Tree)(using Context): Unit = tree match | ||
case _: tpd.Import => assert(false, i"illegal tree: $tree") | ||
case _ => | ||
} | ||
|
||
object PruneErasedDefs { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add this for
MacroTransform
as well? I need the import information inPostTyper
to fix #14319.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let's do that.