-
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
Fix GADT-related memory leak #3233
Conversation
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/3233/ to see the changes. Benchmarks is based on merging with master (96b0ae4) |
@@ -532,7 +532,7 @@ object Contexts { | |||
moreProperties = Map.empty | |||
typeComparer = new TypeComparer(this) | |||
searchHistory = new SearchHistory(0, Map()) | |||
gadt = new GADTMap(SimpleMap.Empty) | |||
gadt = new GADTMap(SimpleMap.Empty) // EmptyGADTMap |
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
?
@@ -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 comment
The 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 comment
The 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
type Tree[T >: Null <: Type]
You are still allowed to write
case x: Tree[_]
(which translates to)
case x: (_: 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.
I am going to refine & explain the logic better
@@ -256,7 +256,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTrans | |||
case tree @ Annotated(annotated, annot) => | |||
cpy.Annotated(tree)(transform(annotated), transformAnnot(annot)) | |||
case tree: AppliedTypeTree => | |||
Checking.checkAppliedType(tree) | |||
Checking.checkAppliedType(tree, boundsCheck = !ctx.mode.is(Mode.Pattern)) |
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.
Now I'm confusing about why we would write this instead of if (!ctx.mode.is(Mode.Pattern)) Checking.checkAppliedType(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.
Because checkAppliedType also does other things besides bounds checking.
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.
If -Xprompt is set, pause a dotty.tools.dotc.Bench task between compiler runs. This is useful for, e.g. taking a memory snapshot at a predictable time.
We no longer convert GADT bounds into normal bounds since scala#3233 was merged.
We no longer convert GADT bounds into normal bounds since scala#3233 was merged.
We no longer convert GADT bounds into normal bounds since scala#3233 was merged.
We no longer convert GADT bounds into normal bounds since scala#3233 was merged.
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.