Skip to content

Commit b12df61

Browse files
committed
WIP
1 parent f82952f commit b12df61

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Foo.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ class Foo {
55
// 36.169 ±(99.9%) 0.655 ms/op [Average]
66

77

8-
Tuple2(1, 2).tail
8+
// Tuple2(1, 2).tail
99
// 419.855 ±(99.9%) 44.090 ms/op [Average]
1010
// 254.921 ±(99.9%) 3.946 ms/op [Average]
1111
// 237.878 ±(99.9%) 2.846 ms/op [Average]
1212

13-
// (21 *: 22 *: ())
13+
(21 *: 22 *: ())
1414
}

compiler/src/dotty/tools/dotc/transform/GenericTuples.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class GenericTuples extends MiniPhase with IdentityDenotTransformer {
3030
else super.transformApply(tree)
3131
}
3232

33-
override def transformTypeApply(tree: tpd.TypeApply)(implicit ctx: Context): tpd.Tree = {
34-
if (tree.symbol == defn.NonEmptyTuple_tail) transformTupleTail(tree)
35-
else super.transformTypeApply(tree)
36-
}
33+
// override def transformTypeApply(tree: tpd.TypeApply)(implicit ctx: Context): tpd.Tree = {
34+
// if (tree.symbol == defn.NonEmptyTuple_tail) transformTupleTail(tree)
35+
// else super.transformTypeApply(tree)
36+
// }
3737

3838
private def transformTupleCons(tree: tpd.Apply)(implicit ctx: Context): Tree = {
3939
val TypeApply(Select(qual, _), headType :: tailType :: Nil) = tree.fun

library/src-bootstrapped/scala/Tuple.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sealed trait Tuple extends Any {
3232
DynamicTuple.dynamicToArray(this)
3333
}
3434

35-
def *: [H, This >: this.type <: Tuple] (x: H): H *: This = ???
35+
def *: [H, This >: this.type <: Tuple] (x: H): H *: This
3636

3737
inline def ++ [This >: this.type <: Tuple](that: Tuple): Concat[This, that.type] = {
3838
type Result = Concat[This, that.type]
@@ -194,8 +194,6 @@ sealed trait NonEmptyTuple extends Tuple {
194194
resVal.asInstanceOf[Result]
195195
}
196196

197-
def tail[This >: this.type <: NonEmptyTuple]: Tail[This]
198-
199197
inline def fallbackApply(n: Int) =
200198
inline constValueOpt[n.type] match {
201199
case Some(n: Int) => error("index out of bounds: ", n)
@@ -253,6 +251,15 @@ sealed trait NonEmptyTuple extends Tuple {
253251

254252
}
255253

254+
object NonEmptyTuple {
255+
import Tuple._
256+
implicit class NonEmptyTupleOps[This <: NonEmptyTuple](val self: This) {
257+
inline def tail: Tail[This] =
258+
scala.runtime.DynamicTuple.dynamicTail[This](self)
259+
}
260+
261+
}
262+
256263
@showAsInfix
257264
sealed abstract class *:[+H, +T <: Tuple] extends NonEmptyTuple
258265

0 commit comments

Comments
 (0)