-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14724 from dotty-staging/fix-14722
Extend "cannot override mutable variable" restriction to deferred var…
- Loading branch information
Showing
3 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
abstract class HasId(var id: String) | ||
|
||
case class Entity(override val id: String) extends HasId(id) // error | ||
|
||
object Test extends App { | ||
val entity = Entity("0001") | ||
entity.id = "0002" | ||
println(entity.id) | ||
} | ||
|
||
trait HasId2: | ||
var id: String = "" | ||
|
||
case class Entity2(override val id: String) extends HasId2 // error | ||
|
||
trait HasId3: | ||
def id: String | ||
def id_=(x: String): Unit | ||
|
||
case class Entity3(override var id: String) extends HasId3 // ok |