Skip to content

Triply-curried type functions don't work (in the REPL?) #6474

Closed
@Blaisorblade

Description

@Blaisorblade

I tried doing some experiments while looking at Namer.typeDefSig, and type-member currying seems to only work up to one level: Foo3.T[A][B][C] below behaves pretty weirdly.

Given:

object Foo1 { type T[+A] = (A, Int) }
object Foo2 { type T[+A] = [+B] => (A, B) }
object Foo3 { type T[+A] = [+B] => [C] => (A, B) }

This works as intended:

scala> ((1, 2): Foo1.T[Int]): Foo1.T[Any]
val res1: (Any, Int) = (1,2)

scala> ((1, 2): Foo2.T[Int][Int]): Foo2.T[Any][Int]
val res2: (Any, Int) = (1,2)

scala> (1, 2): Foo3.T[Int][Int]
1 |(1, 2): Foo3.T[Int][Int]
  |        ^^^^^^^^^^^^^^^^
  |        Missing type parameter for Foo3.T[Int][Int]

This doesn't:

scala> ((1, 2): Foo3.T[Int][Int][Int]): Foo3.T[Any][Int][Int]
1 |((1, 2): Foo3.T[Int][Int][Int]): Foo3.T[Any][Int][Int]
  | ^^^^^^
  | Found:    (Int, Int)
  | Required: (Int, Int)

scala> object Foo3 { type T[A] = [B] => [C] => (A, B) }
// defined object Foo3

scala> ((1, 2): Foo3.T[Int][Int][Int])
1 |((1, 2): Foo3.T[Int][Int][Int])
  | ^^^^^^
  | Found:    (Int, Int)
  | Required: (Int, Int)
cala> object Foo3 { type T[A] = [B] => [C] => (Int, Int) }
// defined object Foo3

scala> ((1, 2): Foo3.T[Int][Int][Int])
1 |((1, 2): Foo3.T[Int][Int][Int])
  | ^^^^^^
  | Found:    (Int, Int)
  | Required: (Int, Int)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions