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
SI-6187 Make partial functions re-typable #2011
Conversation
Sigh... |
- `New(tpe)` doesn't survive a `resetAttrs` / typecheck; use a name instead. - Abandon the tree attachment that passed the default case from `typer` to `patmat`; this tree eluded the attribute reset performed in the macro. Instead, add it to the match. Apart from making the tree re-typable, it also exposes the true code structure to macros, which is important if they need to perform other code transformations. - Install original trees on the declared types of the parameters of the `applyOrElse` method to ensure that references to them within the method pick up the correct type parameter skolems upon retypechecking. - Propagate `TypeTree#original` through `copyAttrs`, which is called during tree duplication / `TreeCopiers`. Without this, the original trees that we installed were not visible anymore during `ResetAttrs`. We are not able to reify partial functions yet -- the particular sticking point is reification of the parentage which is only available in the `ClassInfoType`.
@@ -2706,7 +2709,7 @@ trait Typers extends Modes with Adaptations with Tags { | |||
val x = mkParam(methodSym, A1.tpe) | |||
|
|||
// applyOrElse's default parameter: | |||
val B1 = methodSym newTypeParameter (newTypeName("B1")) setInfo TypeBounds.empty //lower(resTp) | |||
val B1 = methodSym newTypeParameter (newTypeName("B1")) setInfo TypeBounds.empty |
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.
lower(resTp)
?
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.
Looking at this again, I see that comment was succinctly noting that this type will be patched a few lines below.
B1 setInfo TypeBounds.lower(matchResTp) // patch info
BUILDLOG? |
(kitty-note-to-self: ignore 13201539) pr-checkin-per-commit: |
Unfortunately, I know close to nothing about patmat, so I don't feel entitled for rubberstamping here |
rebasing and reviewing |
New(tpe)
doesn't survive aresetAttrs
/ typecheck; usea name instead.
case from
typer
topatmat
; this tree eluded theattribute reset performed in the macro. Instead, add it
to the match. Apart from making the tree re-typable, it
also exposes the true code structure to macros, which
is important if they need to perform other code
transformations.
parameters of the
applyOrElse
method to ensure thatreferences to them within the method pick up the correct
type parameter skolems upon retypechecking.
TypeTree#original
throughcopyAttrs
,which is called during tree duplication /
TreeCopiers
.Without this, the original trees that we installed were
not visible anymore during
ResetAttrs
.We are not able to reify partial functions yet -- the
particular sticking point is reification of the parentage
which is only available in the
ClassInfoType
.Review by @adriaanm / @xeno-by
I'm using
typedCase
now, based on your prior review. TheasInstanceOf
is also gone.