Skip to content

Fix #6286: Fix ElimOpaque transformation #6298

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

Merged
merged 5 commits into from
Apr 13, 2019
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 12, 2019

SymTransformers used to transform only SymDenotations. But that does not work for
ElimOpaque, where we also have to transform SingleDenotations that refer to opaque
helpers.

odersky added 2 commits April 12, 2019 12:18
SymTransformers used to transform only SymDenotations. But that does not work for
ElimOpaque, where we also have to transform SingleDenotations that refer to opaque
helpers.
@@ -60,11 +60,14 @@ object DenotTransformers {
/** A transformer that only transforms SymDenotations */
trait SymTransformer extends DenotTransformer {

/** Tramsform the info of a denotation that is not a Symdenotation */
def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call it transformNonSymInfo to avoid confusion. Or perhaps just make ElimOpaque a regular DenotTransformer, we can always add another kind of Transformer later if we find more uses for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for transformNonSymInfo. I think it's better to leave it there to make it clear that something has to be done if a SymTranformer also changes the infos of symbols.

def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation

def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = ref match {
case ref: SymDenotation => transformSym(ref)
case _ => ref
case _ => ref.derivedSingleDenotation(ref.symbol, transformInfo(ref.info, ref.symbol))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't derivedSingleDenotation going to force the info of the ref?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah in fact ref.info on that line does that more directly :). That means we're suddenly forcing all infos of non-sym SingleDenotations which doesn't sound ideal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Let's make it a DenotTransformer instead.

@odersky
Copy link
Contributor Author

odersky commented Apr 13, 2019

#6287 is also fixed by this PR

@odersky odersky merged commit c3e88b7 into scala:master Apr 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants