Skip to content

Fix #1757: Be more careful about positions of type variable binders #1764

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

Merged
merged 3 commits into from
Dec 10, 2016

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 1, 2016

We interpolate a type variable if the current tree contains the type variable's
binding tree. Previously, this was the application owning the variable. However,
sometimes that tree is transformed so that the containment test fails, and
type variables are instantiated too late (in the case of #1757 this was never).

We fix this by

  • setting the binding tree to the type tree that first contains the type variable
  • making sure that tree is never copied literally anywhere else.

It's a tricky dance, but I believe we got it right now.

Fixes #1757. Review by @smarter ?

We interpolate a type variable if the current tree contains the type variables
binding tree. Previously, this was the application owning the variable. However,
sometimes this tree is transformed so that the containment test fails, and
type variables are instantiated too late (in the case of scala#1757 this was never).

We fix this by

 - setting the binding tree to the type tree that first contains the type variable
 - making sure that tree is never copied literally anywhere else.

It's a tricky dance, but I believe we got it right now.
// Note: It is important that the type arguments `targs` are passed in new trees
// instead of being spliced in literally. Otherwise, a type argument to a default
// method could be constructed as the definition site of the type variable for
// that default constructor. This would interpolate type variables too early,
Copy link
Member

Choose a reason for hiding this comment

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

I'm having trouble following this explanation, could you illustrate it with an example?

@odersky odersky merged commit d900813 into scala:master Dec 10, 2016
@allanrenucci allanrenucci deleted the fix-#1757 branch December 14, 2017 16:59
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.

crash on compilable code: assertion failed: orphan poly parameter: PolyParam(T)
2 participants