Skip to content

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 21, 2022

…iables.

Extend "cannot override mutable variable" restriction also to deferred variables.
This aligns the behavior with Scala 2.

Fixes #14722

odersky added 2 commits March 21, 2022 09:56
…iables.

Extend "cannot override mutable variable" restriction also to deferred variables.
This aligns the behavior with Scala 2.

Fixes scala#14722
@odersky odersky requested a review from smarter March 21, 2022 10:08
@odersky odersky self-assigned this Mar 21, 2022
// was: variable i of type Int cannot override a mutable variable
trait NotOk {var i: Int}
class NotOkC extends NotOk { override var i: Int = 1 }
class NotOkC extends NotOk { override var i: Int = 1 } // error
Copy link
Member

Choose a reason for hiding this comment

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

If this breaks it means we're not really aligned with Scala 2 and we need to re-open #13019 /cc @som-snytt . The Scala 2 logic here is scala/scala@9b59f5f

Copy link
Contributor

Choose a reason for hiding this comment

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

In my tweak I didn't try trait params. I'll take another look at a fix. I haven't taken the trait params coursera yet.

@odersky odersky assigned smarter and unassigned odersky Mar 21, 2022
@smarter smarter merged commit 84fc139 into scala:main Mar 21, 2022
@smarter smarter deleted the fix-14722 branch March 21, 2022 13:17
@Kordyjan Kordyjan added this to the 3.1.3 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.

Semantic bug when override var with val and no way to extends from a trait that has a var for a case class

4 participants