-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #6199: Use a skolemized prefix in asSeenFrom when needed #6454
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
Conversation
5b454e3
to
c768382
Compare
f556249
to
3c75623
Compare
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
def accessibleDenot(pre: Type, name: Name, sig: Signature) = { | ||
val d = pre.member(name).atSignature(sig) | ||
def accessibleDenot(qualType: Type, name: Name, sig: Signature) = { | ||
val pre = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name) |
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'm not super happy with having to recompute whether the prefix needs to be skolemized in the unpickler, but I don't really see a way around it. Maybe asSeenFrom should behave differently when unpickling a tree, but how do you even know if the type on which asSeenFrom is called comes from a tree being unpickled ? And even if we manage to allow unstable prefixes when unpickling, is that really sound when combined with inlining ?
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/6454/ to see the changes. Benchmarks is based on merging with master (61ea245) |
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/6454/ to see the changes. Benchmarks is based on merging with master (61ea245) |
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.
Otherwise LGTM
Prior to scala@91ee02f, unstable prefixes appearing in selection types were handled in a two-pass approach which can be summarized as: 1. Type the selection with the unstable prefix, if this prefix appears in a position where it cannot be widened away, mark it with a special annotation. 2. If the result of the selection contains this annotation, retype it after having wrapped its prefix in a skolem. This got replaced by the use of an `ApproximatingTypeMap` which can always construct a valid (but potentially approximated) type for the selection. Most of the time this is all we need but there are some cases where skolemizing the prefix is still useful as witnessed by the tests added in this commit. They are now handled by unconditionally skolemizing unstable prefixes. To avoid any potential performance impact from this, we teach `asSeenFrom` to always widen these prefixes first and only make use of the skolem to avoid returning an approximation. Since this almost never occurs (it happens only once when compiling Dotty) this means we incur almost no extra cost (the skolem itself still needs to be allocated unconditionally in advance, this cannot be delegated to `asSeenFrom` because it's supposed to be an idempotent operation and each skolem is unique).
3c75623
to
502c7c9
Compare
These are no longer needed thanks to scala/scala3#6454
…make the CI compile the tests with Dotty too (#1088) * Fix the Dotty build stacktracerJVM and coreJVM were using different versions of dotty, so `++0.16.0-RC3; coreJVM/compile` failed (it worked if you did "++0.16.0-RC3!`, which is what the CI does). * Make compileJVM compile the tests too That way, compileJVM is used by the CI to test Dotty, so this ensures that the tests compile with Dotty. * Avoid passing the same option twice to Dotty This is already set in `extraOptions`. * Remove some Dotty workarounds These are no longer needed thanks to scala/scala3#6454
Prior to
91ee02f,
unstable prefixes appearing in selection types were handled in a
two-pass approach which can be summarized as:
in a position where it cannot be widened away, mark it with a special
annotation.
after having wrapped its prefix in a skolem.
This got replaced by the use of an
ApproximatingTypeMap
which canalways construct a valid (but potentially approximated) type for the
selection.
Most of the time this is all we need but there are some cases where
skolemizing the prefix is still useful as witnessed by the tests added
in this commit. They are now handled by unconditionally skolemizing
unstable prefixes.
To avoid any potential performance impact from this, we teach
asSeenFrom
to always widen these prefixes first and only make use ofthe skolem to avoid returning an approximation. Since this almost never
occurs (it happens only once when compiling Dotty) this means we incur
almost no extra cost (the skolem itself still needs to be allocated
unconditionally in advance, this cannot be delegated to
asSeenFrom
because it's supposed to be an idempotent operation and each skolem is
unique).