-
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.
Add version-specific source directories in the library
And replace Tuple.scala with a Scala 2 implementation and a Scala 3 implementation. The Scala 2 implementaion of Tuple.scala is not strictly necessary but could be useful if non-version-specific library sources end up referencing scala.Tuple.
- Loading branch information
Showing
4 changed files
with
44 additions
and
5 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,26 @@ | ||
package scala | ||
import annotation.showAsInfix | ||
|
||
object typelevel { | ||
erased def erasedValue[T]: T = ??? | ||
} | ||
|
||
import typelevel._ | ||
|
||
sealed trait Tuple extends Any | ||
|
||
@showAsInfix | ||
sealed class *:[+H, +T <: Tuple] extends Tuple { | ||
rewrite def head: H = ??? | ||
rewrite def tail: T = ??? | ||
|
||
rewrite private def _size(xs: Tuple): Int = //rewrite | ||
xs match { | ||
case _: Unit => 0 | ||
case _: *:[_, xs1] => _size(erasedValue[xs1]) + 1 | ||
} | ||
} | ||
|
||
object *: { | ||
rewrite def unapply[H, T <: Tuple](x: H *: T) = Some((x.head, x.tail)) | ||
} |
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