-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix GADT-related memory leak #3233
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There was a confusion which led to the wrong gadt map being used for pattern-bound variables if there was no other GADT variable in the enclosing method. This led to the outermost gadt map in the initial context being populated with type bounds which never went away.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,17 +54,9 @@ import reporting.diagnostic.messages.SuperCallsNotAllowedInline | |
* mini-phase or subfunction of a macro phase equally well. But taken by themselves | ||
* they do not warrant their own group of miniphases before pickling. | ||
*/ | ||
class PostTyper extends MacroTransform with SymTransformer { thisTransformer => | ||
|
||
|
||
class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTransformer => | ||
import tpd._ | ||
|
||
def transformSym(ref: SymDenotation)(implicit ctx: Context): SymDenotation = { | ||
if (ref.is(BindDefinedType) && ctx.gadt.bounds.contains(ref.symbol)) { | ||
ref.copySymDenotation(info = ctx.gadt.bounds.apply(ref.symbol) & ref.info) | ||
} else ref | ||
} | ||
|
||
/** the following two members override abstract members in Transform */ | ||
override def phaseName: String = "posttyper" | ||
|
||
|
@@ -289,6 +281,8 @@ class PostTyper extends MacroTransform with SymTransformer { thisTransformer => | |
case _ => | ||
} | ||
super.transform(tree) | ||
case Typed(Ident(nme.WILDCARD), _) => | ||
tree // skip checking pattern type | ||
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. Why? 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. Because type bounds in a pattern need not conform to selector bounds. I.e. you have
You are still allowed to write
(which translates to)
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 am going to refine & explain the logic better |
||
case tree => | ||
super.transform(tree) | ||
} | ||
|
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.
Was this supposed to be
= EmptyGADTMap
?