Skip to content
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

Improve smartmatching against Mu/Any/Junction #3614

Merged
merged 2 commits into from May 13, 2020

Conversation

Kaiepi
Copy link
Contributor

@Kaiepi Kaiepi commented Apr 10, 2020

This allows any instance to typecheck against any type object by giving Mu an ACCEPTS candidate for Mu. This alone breaks smartmatching with junctions, though. To fix this, rather than implicitly autothreading junctions with an Any:U candidate, threading of junctions is now explicitly handled from a Mu:U candidate. While it's not strictly necessary for this to reside in Mu, this allows any(Mu, Any) ~~ Mu to return True instead of False, which I feel is more correct. A bonus to doing all this is smartmatching with junctions is now around twice as fast, and there should be a speedup of some form for all smartmatches since some ACCEPTS candidates in Mu, Any, and Junction are no longer necessary!

Passes make test and make spectest.

Smartmatching of Mu.new against Mu itself would throw before. This fixes
that, but causes problems with smartmatching with junctions.
The last commit breaks smartmatching for junctions. While the compiler
could handle their threading when smartmatching, this would break any
existing code that has ACCEPTS candidates for junctions. Giving it a
default ACCEPTS candidate allows existing code to work again.

While not strictly necessary for this to work, this also moves handling
of junction smartmatching from Any to Mu. This allows `any(Mu, Any) ~~
Mu` to return `True` instead of `False`.
@lizmat lizmat requested a review from jnthn April 10, 2020 17:44
@lizmat lizmat merged commit f059408 into rakudo:master May 13, 2020
@lizmat
Copy link
Contributor

lizmat commented May 13, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants