Skip to content

Fix #3736: Fix owner checking logic #3739

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
Jan 4, 2018
Merged

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@smarter
Copy link
Member

smarter commented Jan 3, 2018

LGTM but I'd like @odersky to double-check this one.

@odersky
Copy link
Contributor

odersky commented Jan 3, 2018

It's not possible to remove the test as in the original PR because otherwise e.g.

import foo.dynamic

would also count. The logic of hasImport needs to be changed instead.

smarter
smarter previously requested changes Jan 4, 2018
@@ -292,16 +292,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
if (!sym.exists || (sym eq defn.LanguageModuleClass)) ""
else toPrefix(sym.owner) + sym.name + "."
def featureName = toPrefix(owner) + feature
def hasImport(implicit ctx: Context): Boolean = {
if (ctx.importInfo == null || (ctx.importInfo.site.widen.typeSymbol ne owner)) false
else if (ctx.importInfo.excluded.contains(feature)) false
Copy link
Member

Choose a reason for hiding this comment

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

Previously, we stopped and returned false for an unimported feature, but we now continue looking up the chain for an import, this breaks the last three errors in the neg test https://github.com/lampepfl/dotty/blob/master/tests/neg/dynamicNoImport.scala

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, indeed, the logic is quite subtle here (and it was not documented either).

@nicolasstucki nicolasstucki changed the title Fix #3736: Remove importInfo site check Fix #3736: Fix owner checking logic Jan 4, 2018
@nicolasstucki nicolasstucki dismissed smarter’s stale review January 4, 2018 10:34

Reimplemented fix without removing the importInfo owner check

@nicolasstucki
Copy link
Contributor Author

@smarter @odersky I reimplemented the fix, added an import foo.dynamic test case and all tests pass.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

This is almost right, but the comment says that renamed features still count as import. In the logic here they are counted as un-imports.

@nicolasstucki nicolasstucki assigned smarter and unassigned odersky Jan 4, 2018
@nicolasstucki nicolasstucki requested a review from smarter January 4, 2018 12:07
@smarter smarter merged commit f821a82 into scala:master Jan 4, 2018
@allanrenucci allanrenucci deleted the fix-#3736 branch January 4, 2018 13:41
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.

5 participants