Skip to content

Stop tuple adaptation earlier #64

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

Open
wants to merge 1 commit into
base: 2.12.x
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions src/compiler/scala/tools/nsc/typechecker/Infer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -666,19 +666,20 @@ trait Infer extends Checkable {
* and the argument list can be tupled (based on its length.)
*/
def eligibleForTupleConversion(paramsCount: Int, argsCount: Int, varargsTarget: Boolean): Boolean = {
def canSendTuple = argsCount match {
case 0 => !varargsTarget // avoid () to (()) conversion - scala/bug#3224
def canSendTuple = (argsCount match {
case 0 => !varargsTarget // avoid () to (()) conversion - scala/bug#3224
case 1 => false // can't tuple a single argument
case n => n <= MaxTupleArity // <= 22 arguments
}
})
def canReceiveTuple = paramsCount match {
case 1 => true
case 2 => varargsTarget
case _ => false
}
canSendTuple && canReceiveTuple
!settings.noAdaptedArgs.value && canSendTuple && canReceiveTuple
}
def eligibleForTupleConversion(formals: List[Type], argsCount: Int): Boolean = formals match {
case _ if settings.noAdaptedArgs.value => false
case p :: Nil => eligibleForTupleConversion(1, argsCount, varargsTarget = isScalaRepeatedParamType(p))
case _ :: p :: Nil if isScalaRepeatedParamType(p) => eligibleForTupleConversion(2, argsCount, varargsTarget = true)
case _ => false
Expand Down