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

Don't generate a super accessor for an inline method call #17598

Merged
merged 2 commits into from
Jun 6, 2023

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 26, 2023

Inline methods cannot be overridden, so they don't need super accessors.

Fixes #17584

Inline methods cannot be overridden, so they don't need super accessors.

Fixes scala#17584
nicolasstucki

This comment was marked as outdated.

@nicolasstucki
Copy link
Contributor

There is another similar case that fails

import language.experimental.erasedDefinitions
trait A:
  erased def g = 1
trait B extends A:
  erased def f = super.g
class C extends B

val needAccessor = name.isTermName && (
val needAccessor =
name.isTermName // Types don't need super accessors
&& !sym.isInlineMethod && ( // Inline methods can't be overridden, don't need superaccessors
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
&& !sym.isInlineMethod && ( // Inline methods can't be overridden, don't need superaccessors
&& !sym.isEffectivelyErased
&& !sym.isInlineMethod && ( // Inline methods can't be overridden, don't need superaccessors

@nicolasstucki
Copy link
Contributor

It would also be good to add this example where the inline method is retained

trait T:
  def g = 2
trait A extends T:
  inline override def g = 1
trait B extends A:
  def f = super.g
class C extends B

@main def Test =
  val c = C()
  assert(c.f == 1)

@odersky odersky assigned nicolasstucki and unassigned odersky Jun 5, 2023
@nicolasstucki nicolasstucki merged commit 58127a3 into scala:main Jun 6, 2023
@nicolasstucki nicolasstucki deleted the fix-17584 branch June 6, 2023 07:48
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
Kordyjan added a commit that referenced this pull request Nov 21, 2023
…to LTS (#18974)

Backports #17598 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
@Kordyjan Kordyjan modified the milestones: 3.4.0, 3.3.2 Dec 14, 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.

call to inline method on super trait fails
3 participants