-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix handling of special implicit searches for ClassTag, quoted.Type, Eq #4436
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 handling of special implicit searches for ClassTag, quoted.Type, Eq #4436
Conversation
Based on #4435 |
They did not work if the searched-for type was an uninstantiated TypeVar that had the class as an upper bound. Getting them to work is surprisingly subtle.
ddbd04e
to
4d95963
Compare
Roll the functionality of contextualBaseType into baseType itself.
test performance please |
performance test scheduled: 1 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/4436/ to see the changes. Benchmarks is based on merging with master (dfab5e5) |
test performance please |
performance test scheduled: 1 job(s) in queue, 1 running. |
The previous logic tended to test things several times, which made it harder to understand and possibly less efficient. We now combine the cachability decisions in the main `recur` method of `baseTypeOf`.
test performance please |
performance test scheduled: 1 job(s) in queue, 1 running. |
When testing on typer/*.scala, the differences are as follows: Cache all Only cache successful Total basetypes 386K 386K Full computations in recur 85K 397K Cache entries created 72K 46K
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/4436/ to see the changes. Benchmarks is based on merging with master (d0f7846) |
test performance please |
performance test scheduled: 1 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/4436/ to see the changes. Benchmarks is based on merging with master (d0f7846) |
So this ended up rewriting |
@smarter, can we get this in? It would make the Tasty extractors somewhat nicer to write. |
Sure, I'll review this today. |
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.
LGTM
val base = formalValue.baseType(cls) | ||
if (base <:< formalValue) { | ||
// With the subtype test we enforce that the searched type `formalValue` is of the right form | ||
handler(base).orElse(ifNot) |
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.
In synthesizedClassTag
there's a call to fullyDefinedType
, I wonder if we should move this around here to do this consistently for all handlers.
@nicolasstucki Enjoy ClassTags! |
They did not work if the searched-for type was an uninstantiated TypeVar that
had the class as an upper bound. Getting them to work is surprisingly subtle.