Skip to content
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

Fix the tparam bounds of exported inherited classes #18647

Merged
merged 6 commits into from
Feb 26, 2024

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Oct 4, 2023

When trying to export M2.F, seeing M1#F from the prefix M2 doesn't
change the bounds of F's T type parameter, which still refers to
M1.this.A, rather than M2.A. So, we run asSeenFrom against that info,
when eta-expanding the class into a hk type lambda.

@dwijnand dwijnand linked an issue Oct 4, 2023 that may be closed by this pull request
@dwijnand dwijnand force-pushed the export-nested-class branch from 68905c1 to b44edb5 Compare October 6, 2023 08:56
@dwijnand dwijnand marked this pull request as ready for review October 6, 2023 12:41
@dwijnand dwijnand force-pushed the export-nested-class branch from 6276d6e to 640e6c8 Compare October 12, 2023 10:47
@dwijnand dwijnand requested a review from odersky October 12, 2023 17:11
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.

Otherwise LGTM

compiler/src/dotty/tools/dotc/typer/Namer.scala Outdated Show resolved Hide resolved
@odersky odersky assigned dwijnand and unassigned odersky Nov 10, 2023
@dwijnand dwijnand force-pushed the export-nested-class branch from 640e6c8 to b0f9e16 Compare November 13, 2023 11:44
@dwijnand dwijnand requested a review from odersky November 27, 2023 15:12
@dwijnand dwijnand assigned odersky and unassigned dwijnand Nov 27, 2023
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.

The changes by themselves look good.

But now I wonder: what about the other uses of etaExpand? Do any of them also need as seen from?

What is the argument that we sometimes should do an asf and at other times not?

@odersky odersky assigned dwijnand and unassigned odersky Nov 28, 2023
@dwijnand dwijnand force-pushed the export-nested-class branch 2 times, most recently from 5d07e66 to 0b78b8e Compare November 30, 2023 16:37
@dwijnand dwijnand requested a review from odersky November 30, 2023 21:54
@dwijnand dwijnand assigned odersky and unassigned dwijnand Dec 1, 2023
@@ -1193,7 +1193,7 @@ class CompletionSuite extends BaseCompletionSuite:
| val x = Bar[M](new Foo[Int]{})
| x.bar.m@@
|""".stripMargin,
"""|map[B](f: A => B): Foo[B]
"""|map[B](f: Int => B): Foo[B]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the test changed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we've fixed the prefix, using x.bar : Foo[Int] instead of Foo[A].

compiler/src/dotty/tools/dotc/core/TypeApplications.scala Outdated Show resolved Hide resolved
@odersky odersky assigned dwijnand and unassigned odersky Jan 17, 2024
@dwijnand dwijnand force-pushed the export-nested-class branch from 0b78b8e to 846c9c6 Compare January 22, 2024 17:08
@dwijnand dwijnand assigned odersky and unassigned dwijnand Jan 23, 2024
@odersky
Copy link
Contributor

odersky commented Feb 24, 2024

Sorry for not coming back to this earlier. LGTM now. This should be merged after rebase.

@odersky odersky assigned dwijnand and unassigned odersky Feb 24, 2024
When trying to export M2.F, seeing M1#F from the prefix M2 doesn't
change the bounds of F's T type parameter, which still refers to
M1.this.A, rather than M2.A.  So, we run asSeenFrom against that info,
when eta-expanding the class into a hk type lambda.
When looking at the info of the type parameters of a TypeRef, make sure
to honour the reference's prefix.
@dwijnand dwijnand force-pushed the export-nested-class branch from 846c9c6 to c9220c2 Compare February 24, 2024 18:06
@dwijnand dwijnand enabled auto-merge February 24, 2024 18:07
@dwijnand dwijnand force-pushed the export-nested-class branch from c9220c2 to 000de84 Compare February 26, 2024 20:54
@dwijnand dwijnand merged commit 5a884bc into scala:main Feb 26, 2024
17 checks passed
@dwijnand dwijnand deleted the export-nested-class branch February 27, 2024 14:07
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
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.

Bounded type parameters with export
3 participants