Skip to content

Fix 2403: Tweak places where we look for new definition #2414

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 1 commit into from
May 29, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 11, 2017

Given a sequence of nested scope (inner to outer), typedIdent has to
decide when to look for definitions. Originally his was the last
scope before the owner changes. A recent fix changed it to the first
scope after the owner changed. But that is wrong for package scopes
because for them we first have to analyze any nested imports before
considering the package scope.

This commit fixes the problem by treating package scopes specially.
Also, the ambiguous import message was improved.

I verified that squants compiles with this PR.

Given a sequence of nested scope (inner to outer), typedIdent has to
decode when to look for definitions. Originally his was the lawas packagst
scope before the owner changes. A recent fix changed it to the first
scope after the owner changed. But that is wrong for package scopes
because for them we first have to analyze any neted imports before
considering the package scope.

This commit fixes the problem by treating package scopes specially.
Also, the ambiguous import message was improved.
@odersky odersky requested a review from olafurpg May 11, 2017 20:18
Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍 I can confirm this fixes #2403. Thank you!

@smarter
Copy link
Member

smarter commented May 11, 2017

Originally his was the lawas packagst

Looks like the commit message got a bit mangled here. Also, wow, the scoping rules are more complicated than I thought!

@@ -2,7 +2,7 @@ package bar { object bippy extends (Double => String) { def apply(x: Double): St
package object println { def bippy(x: Int, y: Int, z: Int) = "(Int, Int, Int)" }
object Test {
def main(args: Array[String]): Unit = {
println(bar.bippy(5.5)) // error
println(bar.bippy(5.5))
Copy link
Member

@smarter smarter May 11, 2017

Choose a reason for hiding this comment

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

Isn't it concerning that this is now different from what scalac does? Is there some more subtlety in the way definitions are looked up that we're missing?

@smarter
Copy link
Member

smarter commented May 11, 2017

I think this PR could benefit from some test cases to have some concrete examples of the rules, and also to compare with what scalac does.

@olafurpg
Copy link
Contributor

Any update on this PR? I'd like to revert the changes in squants and scalatest to work around this change.

@odersky odersky closed this May 29, 2017
@felixmulder felixmulder merged commit 2ba509d into scala:master May 29, 2017
@allanrenucci allanrenucci deleted the fix-#2403b branch December 14, 2017 19:18
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.

4 participants