-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Apply box adaptation when checking overrides #16479
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
f16bb13
to
d24451f
Compare
5a5d767
to
97008df
Compare
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. Let's discuss the changes in baseType when I am back next week.
case tp: CachedType => btrCache.contains(tp) | ||
case _ => false | ||
def record(tp: CachedType, baseTp: Type) = { | ||
if (Stats.monitored) { | ||
Stats.record("basetype cache entries") | ||
if (!baseTp.exists) Stats.record("basetype cache NoTypes") | ||
} | ||
if (!tp.isProvisional) | ||
if (!tp.isProvisional && !tp.isEventuallyCapturingType && !Setup.isDuringSetup) |
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.
We should try to optimize this better. I am worried that (1) the tests here and one line 2143 are too expensive and (2) that we end up caching not enough types, which will also make computation slow.
Why do we need Does to exclude EventuallyCapturingType
s? Maybe excluding CapturingType
s is enough? That would have the advantage that all other phases except CheckCaptures could cache types with capture annotations.
Maybe there could be a method isUncachable
in CapturingType
s companion object that does these tests?
def isUncachable(tp: Type)(using Context) = ...
Then we'd not have to burden SymDenotations with more details about capture checking.
@@ -290,8 +297,11 @@ object RefChecks { | |||
* TODO check that classes are not overridden | |||
* TODO This still needs to be cleaned up; the current version is a straight port of what was there | |||
* before, but it looks too complicated and method bodies are far too large. | |||
* | |||
* @param makeOverridePairsChecker A function for creating a OverridePairsChecker instance |
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 think we might be able to streamline this, maybe by moving checkOverrides into OverridingPairsChecker. But we can do that later after this PR is merged.
- make OverridingPairsChecker extensible, with the method for comparing subtype being abstract, and extend it with the box-adapt-enabled subtyping in CC - delay override checking after checking captures - delegate captured references of methods to the class
- disable caching during Setup - never cache capturing types
adefc4a
to
4038b4b
Compare
test performance please |
performance test scheduled: 124 job(s) in queue, 1 running. |
Performance test finished successfully: Visit https://dotty-bench.epfl.ch/16479/ to see the changes. Benchmarks is based on merging with main (4fa0715) |
4038b4b
to
5a97700
Compare
5a97700
to
9dd4f52
Compare
From the test results it seems that this PR won't slow the compiler down. I just force pushed to fix one typo in the comments. Shall we get it merged? @odersky |
Yes, ready to merge. |
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.
Looks good now!
In this PR, we allow box adaptation when checking the compatibility of overriding pairs in capture checking phase. For example, it allows the following code to compile:
The
foo
andbar
inB
are both valid overrides, since the types inB
andA[{io} C]
is compatible with box adaptation.