Skip to content

Commit d93cc60

Browse files
committed
Allow autotupling if fn's param is a type param
1 parent 3408ed7 commit d93cc60

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,10 @@ trait Applications extends Compatibility {
22372237

22382238
def isCorrectUnaryFunction(alt: TermRef): Boolean =
22392239
val formals = params(alt)
2240-
formals.length == 1 && ptIsCorrectProduct(formals.head, args)
2240+
formals.lengthIs == 1 && {
2241+
ptIsCorrectProduct(formals.head, args)
2242+
| formals.head.dealias.isInstanceOf[TypeParamRef] // eg. i21682
2243+
}
22412244

22422245
val numArgs = args.length
22432246
if numArgs > 1

tests/pos/i21682.1.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sealed abstract class Gen[+T1]
2+
given [T2]: Conversion[T2, Gen[T2]] = ???
3+
4+
trait Show[T3]
5+
given Show[Boolean] = ???
6+
given [A1: Show, B1: Show, C1: Show]: Show[(A1, B1, C1)] = ???
7+
8+
object ForAll:
9+
def apply[A2: Show, B2](f: A2 => B2): Unit = ???
10+
def apply[A3: Show, B3: Show, C3](f: (A3, B3) => C3): Unit = ???
11+
def apply[A4: Show, B4](gen: Gen[A4])(f: A4 => B4): Unit = ???
12+
13+
@main def Test =
14+
ForAll: (b1: Boolean, b2: Boolean, b3: Boolean) =>
15+
???

tests/pos/i21682.2.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object ForAll:
2+
def apply[A1, B](f: A1 => B): Unit = ???
3+
def apply[A1, A2, B](f: (A1, A2) => B): Unit = ???
4+
5+
@main def Test =
6+
ForAll: (b1: Boolean, b2: Boolean, b3: Boolean) =>
7+
???

0 commit comments

Comments
 (0)