Skip to content

Remove TupledFunction for 3.0 #10416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.