-
Notifications
You must be signed in to change notification settings - Fork 3.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 #10268 from lrytz/t12715
Disallow mixins where super calls bind to vals
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
t12715.scala:21: error: parent trait E has a super call to method B.f, which binds to the value D.f. Super calls can only target methods. | ||
object O1 extends B with C with D with E | ||
^ | ||
t12715.scala:22: error: parent trait E has a super call to method B.f, which binds to the value C.f. Super calls can only target methods. | ||
object O2 extends B with C with E with D | ||
^ | ||
2 errors |
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,23 @@ | ||
trait A { | ||
def f: String | ||
} | ||
|
||
trait B extends A { | ||
def f = "B"; | ||
} | ||
|
||
trait C extends A { | ||
override val f = "C" | ||
} | ||
|
||
trait D extends C { | ||
override val f = "D" | ||
} | ||
|
||
trait E extends A with B { | ||
def d = super.f | ||
} | ||
|
||
object O1 extends B with C with D with E | ||
object O2 extends B with C with E with D | ||
object O3 extends B with E with C with D |
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,4 @@ | ||
t12715b.scala:17: error: parent trait D has a super call to method B.f, which binds to the value C.f. Super calls can only target methods. | ||
new A(10.0f) with C with D {} | ||
^ | ||
1 error |
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,19 @@ | ||
trait B { | ||
def f: Float = 1.0f | ||
} | ||
|
||
class A(override val f: Float) extends B | ||
|
||
trait C extends B { | ||
abstract override val f = super.f + 100.0f | ||
} | ||
|
||
trait D extends B { | ||
abstract override val f = super.f + 1000.0f | ||
} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
new A(10.0f) with C with D {} | ||
} | ||
} |