-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'new-definition-typing' into newQ
- Loading branch information
Showing
1 changed file
with
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
:NewDefs | ||
|
||
// FIXME: this looks like a bug about mutually-referential definitions | ||
abstract class Option[out T]: (Some[T] | None) { | ||
virtual fun filter: (p: T -> Bool) -> Option[T] | ||
} | ||
class Some[out T](val value: T) extends Option[T] { | ||
fun filter(p) = if p of value then Some(value) else None | ||
} | ||
module None extends Option[nothing] { | ||
fun filter(_) = None | ||
} | ||
//│ ╔══[ERROR] Type `#Some & {Some#T <: ?T}` does not contain member `Option#T` | ||
//│ ║ l.4: abstract class Option[out T]: (Some[T] | None) { | ||
//│ ╙── ^ | ||
//│ ╔══[ERROR] Type `#None` does not contain member `Option#T` | ||
//│ ║ l.4: abstract class Option[out T]: (Some[T] | None) { | ||
//│ ╙── ^ | ||
//│ abstract class Option[T]: None | Some[T] { | ||
//│ fun filter: (p: T -> Bool) -> Option[T] | ||
//│ } | ||
//│ class Some[T](value: T) extends Option { | ||
//│ fun filter: (T -> Object) -> (None | Some[T]) | ||
//│ } | ||
//│ module None extends Option { | ||
//│ fun filter: anything -> None | ||
//│ } |