From f4e1ca4f565c74fbe1aa56ea88ce6f59409ccdf0 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 20 Nov 2020 15:19:44 +0100 Subject: [PATCH] Remove TupledFunction We remove from functions form 3.0 as it is not required for any other language feature. This can be added into 3.1 or later version. --- .../dotty/tools/dotc/core/Definitions.scala | 4 - .../dotty/tools/dotc/typer/Synthesizer.scala | 45 ----- .../other-new-features/tupled-function.md | 82 --------- docs/sidebar.yml | 2 - .../scala/runtime/TupledFunctions.scala | 163 ------------------ library/src/scala/util/TupledFunction.scala | 19 -- .../erased/tupled-function-instances.scala | 0 .../neg/tupled-function-instances.scala | 0 tests/{ => disabled}/pos/i7851.scala | 0 .../pos/tupled-function-instances.scala | 0 .../run/tupled-function-andThen.check | 0 .../run/tupled-function-andThen.scala | 0 .../run/tupled-function-apply.check | 0 .../run/tupled-function-apply.scala | 0 .../run/tupled-function-compose.check | 0 .../run/tupled-function-compose.scala | 0 .../tupled-function-extension-method.check | 0 .../tupled-function-extension-method.scala | 0 .../run/tupled-function-tupled.check | 0 .../run/tupled-function-tupled.scala | 0 .../run/tupled-function-untupled.scala | 0 21 files changed, 315 deletions(-) delete mode 100644 docs/docs/reference/other-new-features/tupled-function.md delete mode 100644 library/src-bootstrapped/scala/runtime/TupledFunctions.scala delete mode 100644 library/src/scala/util/TupledFunction.scala rename tests/{ => disabled}/neg-custom-args/erased/tupled-function-instances.scala (100%) rename tests/{ => disabled}/neg/tupled-function-instances.scala (100%) rename tests/{ => disabled}/pos/i7851.scala (100%) rename tests/{ => disabled}/pos/tupled-function-instances.scala (100%) rename tests/{ => disabled}/run/tupled-function-andThen.check (100%) rename tests/{ => disabled}/run/tupled-function-andThen.scala (100%) rename tests/{ => disabled}/run/tupled-function-apply.check (100%) rename tests/{ => disabled}/run/tupled-function-apply.scala (100%) rename tests/{ => disabled}/run/tupled-function-compose.check (100%) rename tests/{ => disabled}/run/tupled-function-compose.scala (100%) rename tests/{ => disabled}/run/tupled-function-extension-method.check (100%) rename tests/{ => disabled}/run/tupled-function-extension-method.scala (100%) rename tests/{ => disabled}/run/tupled-function-tupled.check (100%) rename tests/{ => disabled}/run/tupled-function-tupled.scala (100%) rename tests/{ => disabled}/run/tupled-function-untupled.scala (100%) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 1098d8822f05..fea1f3039727 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -894,10 +894,6 @@ class Definitions { lazy val RuntimeTuple_isInstanceOfEmptyTuple: Symbol = RuntimeTupleModule.requiredMethod("isInstanceOfEmptyTuple") lazy val RuntimeTuple_isInstanceOfNonEmptyTuple: Symbol = RuntimeTupleModule.requiredMethod("isInstanceOfNonEmptyTuple") - @tu lazy val TupledFunctionTypeRef: TypeRef = requiredClassRef("scala.util.TupledFunction") - def TupledFunctionClass(using Context): ClassSymbol = TupledFunctionTypeRef.symbol.asClass - def RuntimeTupleFunctionsModule(using Context): Symbol = requiredModule("scala.runtime.TupledFunctions") - // Annotation base classes @tu lazy val AnnotationClass: ClassSymbol = requiredClass("scala.annotation.Annotation") @tu lazy val ClassfileAnnotationClass: ClassSymbol = requiredClass("scala.annotation.ClassfileAnnotation") diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index 0dcc748edd0c..26825e6e21f9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -77,50 +77,6 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): } end synthesizedTypeTest - val synthesizedTupleFunction: SpecialHandler = (formal, span) => - formal match - case AppliedType(_, funArgs @ fun :: tupled :: Nil) => - def functionTypeEqual(baseFun: Type, actualArgs: List[Type], - actualRet: Type, expected: Type) = - expected =:= defn.FunctionOf(actualArgs, actualRet, - defn.isContextFunctionType(baseFun), defn.isErasedFunctionType(baseFun)) - val arity: Int = - if defn.isErasedFunctionType(fun) || defn.isErasedFunctionType(fun) then -1 // TODO support? - else if defn.isFunctionType(fun) then - // TupledFunction[(...) => R, ?] - fun.dropDependentRefinement.dealias.argInfos match - case funArgs :+ funRet - if functionTypeEqual(fun, defn.tupleType(funArgs) :: Nil, funRet, tupled) => - // TupledFunction[(...funArgs...) => funRet, ?] - funArgs.size - case _ => -1 - else if defn.isFunctionType(tupled) then - // TupledFunction[?, (...) => R] - tupled.dropDependentRefinement.dealias.argInfos match - case tupledArgs :: funRet :: Nil => - defn.tupleTypes(tupledArgs.dealias) match - case Some(funArgs) if functionTypeEqual(tupled, funArgs, funRet, fun) => - // TupledFunction[?, ((...funArgs...)) => funRet] - funArgs.size - case _ => -1 - case _ => -1 - else - // TupledFunction[?, ?] - -1 - if arity == -1 then - EmptyTree - else if arity <= Definitions.MaxImplementedFunctionArity then - ref(defn.RuntimeTupleFunctionsModule) - .select(s"tupledFunction$arity".toTermName) - .appliedToTypes(funArgs) - else - ref(defn.RuntimeTupleFunctionsModule) - .select("tupledFunctionXXL".toTermName) - .appliedToTypes(funArgs) - case _ => - EmptyTree - end synthesizedTupleFunction - /** If `formal` is of the form Eql[T, U], try to synthesize an * `Eql.eqlAny[T, U]` as solution. */ @@ -408,7 +364,6 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): defn.ClassTagClass -> synthesizedClassTag, defn.TypeTestClass -> synthesizedTypeTest, defn.EqlClass -> synthesizedEql, - defn.TupledFunctionClass -> synthesizedTupleFunction, defn.ValueOfClass -> synthesizedValueOf, defn.Mirror_ProductClass -> synthesizedProductMirror, defn.Mirror_SumClass -> synthesizedSumMirror, diff --git a/docs/docs/reference/other-new-features/tupled-function.md b/docs/docs/reference/other-new-features/tupled-function.md deleted file mode 100644 index ad94169210ad..000000000000 --- a/docs/docs/reference/other-new-features/tupled-function.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -layout: doc-page -title: "Tupled Function" ---- - -Tupled Function ----------------------- - -With functions bounded to arities up to 22 it was possible to generalize some operation on all function types using overloading. -Now that we have functions and tuples generalized to [arities above 22](../dropped-features/limit22.md) overloading is not an option anymore. -The type class `TupleFunction` provides a way to abstract directly over a function of any arity converting it to an equivalent function that receives all arguments in a single tuple. - -```scala -/** Type class relating a `FunctionN[..., R]` with an equivalent tupled function `Function1[TupleN[...], R]` - * - * @tparam F a function type - * @tparam G a tupled function type (function of arity 1 receiving a tuple as argument) - */ -@implicitNotFound("${F} cannot be tupled as ${G}") -sealed trait TupledFunction[F, G] { - def tupled(f: F): G - def untupled(g: G): F -} -``` - -The compiler will synthesize an instance of `TupledFunction[F, G]` if: - -* `F` is a function type of arity `N` -* `G` is a function with a single tuple argument of size `N` and its types are equal to the arguments of `F` -* The return type of `F` is equal to the return type of `G` -* `F` and `G` are the same sort of function (both are `(...) => R` or both are `(...) ?=> R`) -* If only one of `F` or `G` is instantiated the second one is inferred. - -Examples --------- -`TupledFunction` can be used to generalize the `Function1.tupled`, ... `Function22.tupled` methods to functions of any arities. -The following defines `tupled` as [extension method](../contextual/extension-methods.html) ([full example](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-tupled.scala)). - -```scala -/** Creates a tupled version of this function: instead of N arguments, - * it accepts a single [[scala.Tuple]] with N elements as argument. - * - * @tparam F the function type - * @tparam Args the tuple type with the same types as the function arguments of F - * @tparam R the return type of F - */ -extension [F, Args <: Tuple, R](f: F) - def tupled(using tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f) -``` - -`TupledFunction` can be used to generalize the `Function.untupled` to a function of any arities ([full example](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-untupled.scala)) - -```scala -/** Creates an untupled version of this function: instead of a single argument of type [[scala.Tuple]] with N elements, - * it accepts N arguments. - * - * This is a generalization of [[scala.Function.untupled]] that work on functions of any arity - * - * @tparam F the function type - * @tparam Args the tuple type with the same types as the function arguments of F - * @tparam R the return type of F - */ -extension [F, Args <: Tuple, R](f: Args => R) - def untupled(using tf: TupledFunction[F, Args => R]): F = tf.untupled(f) -``` - -`TupledFunction` can also be used to generalize the [`Tuple1.compose`](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-compose.scala) and [`Tuple1.andThen`](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-andThen.scala) methods to compose functions of larger arities and with functions that return tuples. - -```scala -/** Composes two instances of TupledFunction into a new TupledFunction, with this function applied last. - * - * @tparam F a function type - * @tparam G a function type - * @tparam FArgs the tuple type with the same types as the function arguments of F and return type of G - * @tparam GArgs the tuple type with the same types as the function arguments of G - * @tparam R the return type of F - */ -extension [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F) - def compose(g: G)(using tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = { - (x: GArgs) => tf.tupled(f)(tg.tupled(g)(x)) -} -``` diff --git a/docs/sidebar.yml b/docs/sidebar.yml index 1b901d208ab7..bcb662ad97fe 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -101,8 +101,6 @@ sidebar: url: docs/reference/other-new-features/parameter-untupling.html - title: Kind Polymorphism url: docs/reference/other-new-features/kind-polymorphism.html - - title: Tupled Function - url: docs/reference/other-new-features/tupled-function.html - title: threadUnsafe Annotation url: docs/reference/other-new-features/threadUnsafe-annotation.html - title: targetName Annotation diff --git a/library/src-bootstrapped/scala/runtime/TupledFunctions.scala b/library/src-bootstrapped/scala/runtime/TupledFunctions.scala deleted file mode 100644 index a2b1f0caa513..000000000000 --- a/library/src-bootstrapped/scala/runtime/TupledFunctions.scala +++ /dev/null @@ -1,163 +0,0 @@ -package scala.runtime - -import scala.util.TupledFunction - -object TupledFunctions { - - def tupledFunction0[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => ((args: EmptyTuple) => f.asInstanceOf[() => Any].apply()).asInstanceOf[G], - untupledImpl = (g: G) => (() => g.asInstanceOf[EmptyTuple => Any].apply(EmptyTuple)).asInstanceOf[F] - ) - - def tupledFunction1[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => ((args: Tuple1[Any]) => f.asInstanceOf[Any => Any].apply(args._1)).asInstanceOf[G], - untupledImpl = (g: G) => ((x1: Any) => g.asInstanceOf[Tuple1[_] => Any].apply(Tuple1(x1))).asInstanceOf[F] - ) - - def tupledFunction2[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function2[_, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => Function.untupled(g.asInstanceOf[Tuple2[_, _] => Any]).asInstanceOf[F] - ) - - def tupledFunction3[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function3[_, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => Function.untupled(g.asInstanceOf[Tuple3[_, _, _] => Any]).asInstanceOf[F] - ) - - def tupledFunction4[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function4[_, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => Function.untupled(g.asInstanceOf[Tuple4[_, _, _, _] => Any]).asInstanceOf[F] - ) - - def tupledFunction5[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function5[_, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => Function.untupled(g.asInstanceOf[Tuple5[_, _, _, _, _] => Any]).asInstanceOf[F] - ) - - def tupledFunction6[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function6[_, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any) => - g.asInstanceOf[Tuple6[_, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6))).asInstanceOf[F] - ) - - def tupledFunction7[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function7[_, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any) => - g.asInstanceOf[Tuple7[_, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7))).asInstanceOf[F] - ) - - def tupledFunction8[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function8[_, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any) => - g.asInstanceOf[Tuple8[_, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8))).asInstanceOf[F] - ) - - def tupledFunction9[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function9[_, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any) => - g.asInstanceOf[Tuple9[_, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9))).asInstanceOf[F] - ) - - def tupledFunction10[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function10[_, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any) => - g.asInstanceOf[Tuple10[_, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10))).asInstanceOf[F] - ) - - def tupledFunction11[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function11[_, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any) => - g.asInstanceOf[Tuple11[_, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11))).asInstanceOf[F] - ) - - def tupledFunction12[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function12[_, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any) => - g.asInstanceOf[Tuple12[_, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12))).asInstanceOf[F] - ) - - def tupledFunction13[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function13[_, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any) => - g.asInstanceOf[Tuple13[_, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13))).asInstanceOf[F] - ) - - def tupledFunction14[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function14[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any) => - g.asInstanceOf[Tuple14[_, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14))).asInstanceOf[F] - ) - - def tupledFunction15[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any) => - g.asInstanceOf[Tuple15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15))).asInstanceOf[F] - ) - - def tupledFunction16[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any) => - g.asInstanceOf[Tuple16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16))).asInstanceOf[F] - ) - - def tupledFunction17[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any, x17: Any) => - g.asInstanceOf[Tuple17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17))).asInstanceOf[F] - ) - - def tupledFunction18[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any, x17: Any, x18: Any) => - g.asInstanceOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18))).asInstanceOf[F] - ) - - def tupledFunction19[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any, x17: Any, x18: Any, x19: Any) => - g.asInstanceOf[Tuple19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19))).asInstanceOf[F] - ) - - def tupledFunction20[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any, x17: Any, x18: Any, x19: Any, x20: Any) => - g.asInstanceOf[Tuple20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20))).asInstanceOf[F] - ) - - def tupledFunction21[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any, x17: Any, x18: Any, x19: Any, x20: Any, x21: Any) => - g.asInstanceOf[Tuple21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21))).asInstanceOf[F] - ) - - def tupledFunction22[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => f.asInstanceOf[Function22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf[G], - untupledImpl = (g: G) => - ((x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any, x17: Any, x18: Any, x19: Any, x20: Any, x21: Any, x22: Any) => - g.asInstanceOf[Tuple22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22))).asInstanceOf[F] - ) - - def tupledFunctionXXL[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( - tupledImpl = (f: F) => ((args: TupleXXL) => f.asInstanceOf[FunctionXXL].apply(args.elems)).asInstanceOf[G], - untupledImpl = (g: G) => new FunctionXXL { - override def apply(xs: IArray[Object]): AnyRef = g.asInstanceOf[TupleXXL => AnyRef].apply(TupleXXL.fromIArray(xs)) - }.asInstanceOf[F] - ) - -} diff --git a/library/src/scala/util/TupledFunction.scala b/library/src/scala/util/TupledFunction.scala deleted file mode 100644 index 080309cd7d1a..000000000000 --- a/library/src/scala/util/TupledFunction.scala +++ /dev/null @@ -1,19 +0,0 @@ -package scala.util - -import scala.annotation.implicitNotFound - -/** Type class relating a `FunctionN[..., R]` with an equivalent tupled function `Function1[TupleN[...], R]` - * - * @tparam F a function type - * @tparam G a tupled function type (function of arity 1 receiving a tuple as argument) - */ -@implicitNotFound("${F} cannot be tupled as ${G}") -sealed trait TupledFunction[F, G]: - def tupled(f: F): G - def untupled(g: G): F - -private[scala] object TupledFunction: - def apply[F, G](tupledImpl: F => G, untupledImpl: G => F): TupledFunction[F, G] = - new TupledFunction[F, G]: - def tupled(f: F): G = tupledImpl(f) - def untupled(g: G): F = untupledImpl(g) diff --git a/tests/neg-custom-args/erased/tupled-function-instances.scala b/tests/disabled/neg-custom-args/erased/tupled-function-instances.scala similarity index 100% rename from tests/neg-custom-args/erased/tupled-function-instances.scala rename to tests/disabled/neg-custom-args/erased/tupled-function-instances.scala diff --git a/tests/neg/tupled-function-instances.scala b/tests/disabled/neg/tupled-function-instances.scala similarity index 100% rename from tests/neg/tupled-function-instances.scala rename to tests/disabled/neg/tupled-function-instances.scala diff --git a/tests/pos/i7851.scala b/tests/disabled/pos/i7851.scala similarity index 100% rename from tests/pos/i7851.scala rename to tests/disabled/pos/i7851.scala diff --git a/tests/pos/tupled-function-instances.scala b/tests/disabled/pos/tupled-function-instances.scala similarity index 100% rename from tests/pos/tupled-function-instances.scala rename to tests/disabled/pos/tupled-function-instances.scala diff --git a/tests/run/tupled-function-andThen.check b/tests/disabled/run/tupled-function-andThen.check similarity index 100% rename from tests/run/tupled-function-andThen.check rename to tests/disabled/run/tupled-function-andThen.check diff --git a/tests/run/tupled-function-andThen.scala b/tests/disabled/run/tupled-function-andThen.scala similarity index 100% rename from tests/run/tupled-function-andThen.scala rename to tests/disabled/run/tupled-function-andThen.scala diff --git a/tests/run/tupled-function-apply.check b/tests/disabled/run/tupled-function-apply.check similarity index 100% rename from tests/run/tupled-function-apply.check rename to tests/disabled/run/tupled-function-apply.check diff --git a/tests/run/tupled-function-apply.scala b/tests/disabled/run/tupled-function-apply.scala similarity index 100% rename from tests/run/tupled-function-apply.scala rename to tests/disabled/run/tupled-function-apply.scala diff --git a/tests/run/tupled-function-compose.check b/tests/disabled/run/tupled-function-compose.check similarity index 100% rename from tests/run/tupled-function-compose.check rename to tests/disabled/run/tupled-function-compose.check diff --git a/tests/run/tupled-function-compose.scala b/tests/disabled/run/tupled-function-compose.scala similarity index 100% rename from tests/run/tupled-function-compose.scala rename to tests/disabled/run/tupled-function-compose.scala diff --git a/tests/run/tupled-function-extension-method.check b/tests/disabled/run/tupled-function-extension-method.check similarity index 100% rename from tests/run/tupled-function-extension-method.check rename to tests/disabled/run/tupled-function-extension-method.check diff --git a/tests/run/tupled-function-extension-method.scala b/tests/disabled/run/tupled-function-extension-method.scala similarity index 100% rename from tests/run/tupled-function-extension-method.scala rename to tests/disabled/run/tupled-function-extension-method.scala diff --git a/tests/run/tupled-function-tupled.check b/tests/disabled/run/tupled-function-tupled.check similarity index 100% rename from tests/run/tupled-function-tupled.check rename to tests/disabled/run/tupled-function-tupled.check diff --git a/tests/run/tupled-function-tupled.scala b/tests/disabled/run/tupled-function-tupled.scala similarity index 100% rename from tests/run/tupled-function-tupled.scala rename to tests/disabled/run/tupled-function-tupled.scala diff --git a/tests/run/tupled-function-untupled.scala b/tests/disabled/run/tupled-function-untupled.scala similarity index 100% rename from tests/run/tupled-function-untupled.scala rename to tests/disabled/run/tupled-function-untupled.scala