Skip to content

Refine criterion when we can skip an asSeenFrom #10982

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
Jan 6, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 3, 2021

Fixes #9352

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1063,7 +1063,16 @@ object Denotations {
info.asSeenFrom(pre, owner),
if (symbol.is(Opaque) || this.prefix != NoPrefix) pre else this.prefix)

if (!owner.membersNeedAsSeenFrom(pre) || symbol.is(NonMember)) this
// Tt could happen that we see the symbol with prefix `this` as a member a different class
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Tt could happen that we see the symbol with prefix `this` as a member a different class
// It could happen that we see the symbol with prefix `this` as a member of a different class

Copy link
Contributor

Choose a reason for hiding this comment

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

We have similar logic in Types.scala:

    private def infoDependsOnPrefix(symd: SymDenotation, prefix: Type)(using Context): Boolean =
      symd.maybeOwner.membersNeedAsSeenFrom(prefix) && !symd.is(NonMember)

I'm wondering if it is worth creating a method to abstract the logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting observation! This looked promising at first, but in the end I found no way to improve over the status quo. The problem is that the code in Types only works for SymDenotations, whereas the more complicated logic in Denotations works also for SingleDenotations and it's difficult to break it out.

@odersky odersky merged commit ce61070 into scala:master Jan 6, 2021
@odersky odersky deleted the fix-#9352 branch January 6, 2021 12:35
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

Trait 'self=>' type inheritance problem
3 participants