-
Notifications
You must be signed in to change notification settings - Fork 12
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 #234 from sjrd/selftypes
Handle self types.
- Loading branch information
Showing
8 changed files
with
176 additions
and
7 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
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
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,23 @@ | ||
package simple_trees | ||
|
||
object SelfTypes: | ||
trait Foo[T]: | ||
self: Bar[T, Int] => | ||
|
||
def throughSelf: Pair[T, Int] = self.bar() | ||
def throughThis: MyPair = this.bar() | ||
def bare: Pair[T, Int] = bar() | ||
end Foo | ||
|
||
trait Bar[A, B]: | ||
def bar(): Pair[A, B] | ||
|
||
type MyPair = Pair[A, B] | ||
end Bar | ||
|
||
class FooBar extends Foo[String] with Bar[String, Int]: | ||
def bar(): Pair[String, Int] = Pair("foo", 4) | ||
end FooBar | ||
|
||
final class Pair[+A, +B](val a: A, val B: B) | ||
end SelfTypes |