-
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
Support implicit scope augmentation for Mirror #6879
Support implicit scope augmentation for Mirror #6879
Conversation
a2ed239
to
b26f555
Compare
Rebased. |
.refinedWith(tpnme.MirroredMonoType, TypeAlias(monoType)) | ||
.refinedWith(tpnme.MirroredType, TypeAlias(mirroredType)) | ||
.refinedWith(tpnme.MirroredLabel, TypeAlias(ConstantType(Constant(label.toString)))) | ||
|
||
extras.foldLeft(m) { case (m, (tpnme, tpe)) => m.refinedWith(tpnme, tpe) } |
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.
Would it make sense to just do formal & m
?
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'll have a look ...
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.
Yes, it makes sense, and simplifies things significantly. Good call :-)
Any additional type members will contribute to the implicit scope of any searches involving the type of the summoned Mirror. Typically such types will be the singleton types of objects containing implicit extension methods for the Mirror, or other related implicit definitions. Pass through all extra refinements
0bfc9d2
to
f6d4ddb
Compare
Rebased for #6886. |
the[SomeClass & Mirror.ProductOf[ISB]] gives me,
which I think is what we want. |
Some neg tests exercising this and other weird combinations (e.g. refining with a def) would be nice |
Added check rejecting methodic refinements and some neg tests. |
@smarter done. |
if (!checkFormal(formal)) EmptyTree | ||
else | ||
formal.member(tpnme.MirroredType).info match { | ||
case TypeBounds(mirroredType, _) if checkFormal(formal) => mirrorFor(mirroredType) |
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.
checkFormal(formal)
is always true here
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 don't think that can be the case. It being false for formals
which include def/val definitions is what's responsible for the (intended) neg test failures.
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.
But it just got tested in line 968, so to reach the else part, it must be true.
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.
Oh! Yes, sorry ... I completely missed the redundant guard there. Removed.
@odersky I think this is ready to merge now. |
Mirrors
can now be materialized with additional type member refinements. Any additional type members will contribute to the implicit scope of any searches involving the type of the summonedMirror
. Typically such types will be the singleton types of objects containing implicit extension methods for theMirror
, or other related implicit definitions.Given,
then requested type (
formal
in the code) will be,and the core synthesized mirror type will be,
The result of intersecting these two is then,
That's the refined type that we'll get for the mirror as a given argument, so if we have an object
Other
containing extension methods like so,they will be found because the contents of
Other
is included in the implicit scope for the extension method search via the parts of the refined type of the mirror.