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

Scala 2.13.0-RC1 - method without override modifier rejected when overridden both earlier and later in trait linearisation #11495

Closed
Sciss opened this issue Apr 20, 2019 · 6 comments
Milestone

Comments

@Sciss
Copy link

Sciss commented Apr 20, 2019

I think this is a bug:

trait Basic {
  def numFrames: Long
}

trait Readable extends Basic {
  def numFrames: Long = ??? // doesn't matter for bug report
}
    
trait Writable extends Basic {
  override final def numFrames: Long = ??? // doesn't matter for bug report
}

trait Bidi extends Readable with Writable  // writable beats readable
  
trait WritableFileLike extends Writable

trait BidiFileLike extends WritableFileLike with Bidi // compiles up to 2.13.0-M5, not RC1

Note that in the linearisation order, Writable is last and thus should "eliminate" its first occurrence in WritableFileLike, which I guess triggers the error in 2.13.0-RC1:

[error] final override def numFrames: Long (defined in trait Writable)
[error]   with def numFrames: Long (defined in trait Readable)
[error] trait BidiFileLike extends WritableFileLike with Bidi
[error]       ^
@smarter
Copy link
Member

smarter commented Apr 20, 2019

Note that in the linearisation order, Writable is last and thus should "eliminate" its first occurrence in WritableFileLike

No, for linearization order the first occurence is the important one, see https://www.scala-lang.org/files/archive/spec/2.12/05-classes-and-objects.html#class-linearization. I think 2.13.0-RC1 is doing the right thing.

@SethTisue SethTisue added this to the 2.13.0-RC2 milestone Apr 20, 2019
@Sciss
Copy link
Author

Sciss commented Apr 20, 2019

I can actually remove the final qualifier, the problem stays. If I add override also to the Readable trait, it compiles. So not sure, if it was "wrong" interpretation of the spec before 2.13.0-RC1 or not (and thus, whether it's a bug or not).

@Sciss Sciss changed the title Scala 2.13.0-RC1 - cannot override final member / trait linearisation Scala 2.13.0-RC1 - method without override modifier rejected when overridden both earlier and later in trait linearisation Apr 21, 2019
@hrhino
Copy link

hrhino commented Apr 21, 2019

Isn't this the opposite of #11136? (Not that I'm biased...)

@som-snytt
Copy link

The PR to the earlier ticket is explanatory (though it also has a long tail of follow-up).

What do you call a duplicate ticket that is the opposite? A mirror ticket?

I'm not sure which ticket I admire more for their creative variants of IO-related trait names.

@Sciss
Copy link
Author

Sciss commented Apr 22, 2019

I don't understand - is this resolved?

@som-snytt
Copy link

@Sciss See smarter's comment -- the current behavior is correct, the old behavior was wrong, and was always wrong. Now I have to check my "stackable traits" answer on stackoverflow from 2012.

@SethTisue SethTisue modified the milestones: 2.13.0-RC2, 2.13.0-RC1 Apr 22, 2019
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

No branches or pull requests

5 participants