Skip to content

Conversation

liufengyun
Copy link
Contributor

Handle super accessors in initialization checker

@liufengyun liufengyun marked this pull request as ready for review July 19, 2022 06:25
@liufengyun liufengyun requested a review from olhotak July 19, 2022 06:55
Copy link
Contributor

@olhotak olhotak 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.

def foo(): Int = m

class N extends A with B:
override def foo(): Int = 10 * super.foo()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this test have an additional field to ensure that this def foo is not considered to be called during initialization (like the n field in the other test)?

// Note that a parameterized trait may only get parameters from the class that extends the trait.
// A trait may not supply constructor arguments to another trait.
if !klass.is(Flags.Trait) then
for parent <- klass.parentSyms if parent.hasSource do doPromote(parent.asClass, klass, isHotSegment)
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 it OK to remove this? We don't need to promote super-trait segments? Is it because it is duplicated by the promotion of mixins below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, with the changes we avoid some duplicate check (with cache they are not expensive though):

trait A

class B extends A

class C extends B with A

@liufengyun liufengyun merged commit 56e9a93 into scala:main Jul 19, 2022
@liufengyun liufengyun deleted the init-super-accessor branch July 19, 2022 20:17
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 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.

3 participants