-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #2563: Unconditionally emit mixin forwarders #6081
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<527..527> in mixin-forwarder-clash1.scala | ||
<284..284> in mixin-forwarder-clash1.scala | ||
Name clash between inherited members: | ||
override def concat(suffix: Int): X in trait OneB at line 10 and | ||
override def concat: [Dummy](suffix: Int): Y in trait TwoB at line 18 | ||
def concat(suffix: Int): X in trait One at line 4 and | ||
def concat: [Dummy](suffix: Int): Y in trait Two at line 8 | ||
have the same type after erasure. |
This file contains hidden or 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 |
---|---|---|
@@ -1,38 +1,28 @@ | ||
class Foo | ||
|
||
// Using self-types to force mixin forwarders | ||
|
||
trait OneA[X] { | ||
trait One[X] { | ||
def concat(suffix: Int): X = ??? | ||
} | ||
|
||
trait OneB[X] { self: OneA[X] => | ||
override def concat(suffix: Int): X = ??? | ||
} | ||
|
||
trait TwoA[Y/* <: Foo*/] { | ||
trait Two[Y/* <: Foo*/] { | ||
def concat[Dummy](suffix: Int): Y = ??? | ||
} | ||
|
||
trait TwoB[Y/* <: Foo*/] { self: TwoA[Y] => | ||
override def concat[Dummy](suffix: Int): Y = ??? | ||
} | ||
|
||
class Bar1 extends OneA[Foo] with OneB[Foo] | ||
class Bar1 extends One[Foo] | ||
// Because mixin forwarders are generated after erasure, we get: | ||
// override def concat(suffix: Int): Object | ||
|
||
class Bar2 extends Bar1 with TwoA[Foo] with TwoB[Foo] // error | ||
// We get a mixin forwarder for TwoB: | ||
class Bar2 extends Bar1 with Two[Foo] // error | ||
// We get a mixin forwarder for Two: | ||
// override def concat(suffix: Int): Object | ||
// This clashes with the forwarder generated in Bar1, and the compiler detects that: | ||
// | ||
// |class Bar2 extends Bar1 with TwoA[Foo] with TwoB[Foo] | ||
// |class Bar2 extends Bar1 with Two[Foo] | ||
// | ^ | ||
// | Name clash between inherited members: | ||
// | override def concat(suffix: Int): Object in trait OneB at line 10 and | ||
// | override def concat: [Dummy](suffix: Int): Y in trait TwoB at line 18 | ||
// | have the same type after erasure. | ||
// | Name clash between inherited members: | ||
// | def concat(suffix: Int): X in trait One at line 4 and | ||
// | def concat: [Dummy](suffix: Int): Y in trait Two at line 8 | ||
// | have the same type after erasure. | ||
// | ||
// This also works with separate compilation as demonstrated by | ||
// mixin-forwarder-clash2. |
This file contains hidden or 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<6..6> in B_2.scala | ||
Name clash between inherited members: | ||
override def concat(suffix: Int): X in trait OneB and | ||
override def concat: [Dummy](suffix: Int): Y in trait TwoB | ||
def concat(suffix: Int): X in trait One and | ||
def concat: [Dummy](suffix: Int): Y in trait Two | ||
have the same type after erasure. |
This file contains hidden or 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 |
---|---|---|
@@ -1,23 +1,13 @@ | ||
class Foo | ||
|
||
// Using self-types to force mixin forwarders | ||
|
||
trait OneA[X] { | ||
trait One[X] { | ||
def concat(suffix: Int): X = ??? | ||
} | ||
|
||
trait OneB[X] { self: OneA[X] => | ||
override def concat(suffix: Int): X = ??? | ||
} | ||
|
||
trait TwoA[Y/* <: Foo*/] { | ||
trait Two[Y/* <: Foo*/] { | ||
def concat[Dummy](suffix: Int): Y = ??? | ||
} | ||
|
||
trait TwoB[Y/* <: Foo*/] { self: TwoA[Y] => | ||
override def concat[Dummy](suffix: Int): Y = ??? | ||
} | ||
|
||
class Bar1 extends OneA[Foo] with OneB[Foo] | ||
class Bar1 extends One[Foo] | ||
// Because mixin forwarders are generated after erasure, we get: | ||
// override def concat(suffix: Int): Object |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,23 +1,18 @@ | ||
class Foo | ||
// This test case was supposed to fail when mixin forwarders were generated before erasure, | ||
// but didn't due to separate compilation unlike mixin-forwarder-clash1, | ||
// it's not supposed to fail anymore since the forwarders generated after erasure do not clash, | ||
// the comments are preserved for posterity. | ||
|
||
// Using self-types to force mixin forwarders | ||
class Foo | ||
|
||
trait OneA[X] { | ||
trait One[X] { | ||
def concat(suffix: Int): X = ??? | ||
} | ||
|
||
trait OneB[X] { self: OneA[X] => | ||
override def concat(suffix: Int): X = ??? | ||
} | ||
|
||
trait TwoA[Y <: Foo] { | ||
trait Two[Y <: Foo] { | ||
def concat[Dummy](suffix: Int): Y = ??? | ||
} | ||
|
||
trait TwoB[Y <: Foo] { self: TwoA[Y] => | ||
override def concat[Dummy](suffix: Int): Y = ??? | ||
} | ||
|
||
class Bar1 extends OneA[Foo] with OneB[Foo] | ||
class Bar1 extends One[Foo] | ||
// Because mixin forwarders are generated before erasure, we get: | ||
// override def concat(suffix: Int): Foo |
This file contains hidden or 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
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.