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

SI-6187 Make partial functions re-typable #2011

Closed
wants to merge 1 commit into from

Conversation

retronym
Copy link
Member

  • 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.

Review by @adriaanm / @xeno-by

I'm using typedCase now, based on your prior review. The asInstanceOf is also gone.

@ghost ghost assigned adriaanm Jan 29, 2013
@retronym
Copy link
Member Author

Sigh...

@retronym retronym closed this Jan 29, 2013
 - `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`.
@retronym retronym reopened this Jan 30, 2013
@retronym
Copy link
Member Author

Review by @xeno-by @adriaanm

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower(resTp)?

Copy link
Member Author

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

@adriaanm
Copy link
Contributor

adriaanm commented Feb 6, 2013

BUILDLOG?

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 13201539)
pr-rangepos-per-commit:

pr-checkin-per-commit:

@JamesIry
Copy link
Contributor

JamesIry commented Feb 7, 2013

@adriaanm and/or @xeno-by I think this PR is still waiting on review approval

@xeno-by
Copy link
Member

xeno-by commented Feb 7, 2013

Unfortunately, I know close to nothing about patmat, so I don't feel entitled for rubberstamping here

@adriaanm
Copy link
Contributor

adriaanm commented Feb 7, 2013

rebasing and reviewing

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