Skip to content

Commit

Permalink
Remove TupledFunction
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nicolasstucki committed Nov 20, 2020
1 parent cc3da61 commit f4e1ca4
Show file tree
Hide file tree
Showing 21 changed files with 0 additions and 315 deletions.
4 changes: 0 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Expand Up @@ -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")
Expand Down
45 changes: 0 additions & 45 deletions compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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,
Expand Down
82 changes: 0 additions & 82 deletions docs/docs/reference/other-new-features/tupled-function.md

This file was deleted.

2 changes: 0 additions & 2 deletions docs/sidebar.yml
Expand Up @@ -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
Expand Down
163 changes: 0 additions & 163 deletions library/src-bootstrapped/scala/runtime/TupledFunctions.scala

This file was deleted.

19 changes: 0 additions & 19 deletions library/src/scala/util/TupledFunction.scala

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f4e1ca4

Please sign in to comment.