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

Extend "cannot override mutable variable" restriction to deferred var… #14724

Merged
merged 2 commits into from Mar 21, 2022

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

…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
@@ -10,4 +10,4 @@ class Ok2C extends Ok2 { override var i: Int = 1 }

// 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