Skip to content

Fix/#655 eta expansion #674

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 4 commits into from
Jun 21, 2015
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 19, 2015

Review by @lrytz or @retronym. Based on #673, so only the second commit is new.

odersky added 2 commits June 19, 2015 18:31
Factor out isValueSubClass into separate method. Will probably come in handly
elsewhere, and makes the code easier to understand.
Failure to do a widen caused by-name parameters to go undetected.
@@ -601,6 +601,19 @@ object Types {
ctx.typeComparer.isSameType(this, that)
}

/** Is this type a primitive value type which can be widened to the primitive value type `to`? */
Copy link
Member

Choose a reason for hiding this comment

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

typo to -> that

@lrytz
Copy link
Member

lrytz commented Jun 19, 2015

lgtm

@retronym
Copy link
Member

In the test case, what was the too-narrow type that needed widening? Sharing that sort of detail makes review easier (and comes in handy when looking back at the history of this code.)

@retronym
Copy link
Member

I just traced this:

methType=TermRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,<empty>)),Test$)),foo)
methType.show=(str: => String)(i: Int)Test.Result(Test.foo)
methType.widen.show=(str: => String)(i: Int)Test.Result

After looking at the surrounding code, I would suggest that this widening should be done by the caller to liftArgs. This would be consistent with the way that adaptInterpolated/adapt passes the widened type as the argument for the methType parameter of etaExpand.

@odersky
Copy link
Contributor Author

odersky commented Jun 19, 2015

It was a TermRef. Stupid mistake, easy to make.

On Fri, Jun 19, 2015 at 10:46 PM, Jason Zaugg notifications@github.com
wrote:

In the test case, what was the too-narrow type that needed widening?
Sharing that sort of detail makes review easier (and comes in handy when
looking back at the history of this code.)


Reply to this email directly or view it on GitHub
#674 (comment).

Martin Odersky
EPFL

@retronym
Copy link
Member

I see. In scalac we don't have to widen, because tree's have a symbol member to bind references to defintions, whereas dotc represents this with a NamedType instead.

@odersky
Copy link
Contributor Author

odersky commented Jun 19, 2015

@retronym I don't think there's a fixed convention whether we do widen in the caller or callee. The way it is in EtaExpansion is DRYer. If we move to caller, we have to duplicate the operation in the two callers to liftArgs.

@retronym
Copy link
Member

In that case, the paramaeter name of methType is misleading.

@odersky
Copy link
Contributor Author

odersky commented Jun 19, 2015

@retronym Good point.

odersky added a commit that referenced this pull request Jun 21, 2015
@odersky odersky merged commit a654d20 into scala:master Jun 21, 2015
@allanrenucci allanrenucci deleted the fix/#655-eta-expansion branch December 14, 2017 19:21
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.

3 participants