Skip to content

Commit e06f9a7

Browse files
authored
Merge pull request #13664 from dotty-staging/fix-13426
Fix erasure of curried polymorphic function types
2 parents 8c3e7a2 + 9299ece commit e06f9a7

File tree

6 files changed

+29
-2
lines changed

6 files changed

+29
-2
lines changed

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ object Erasure {
698698
def mapOwner(sym: Symbol): Symbol =
699699
if !sym.exists && tree.name == nme.apply then
700700
// PolyFunction apply Selects will not have a symbol, so deduce the owner
701-
// from the typed qual.
702-
val owner = qual1.tpe.typeSymbol
701+
// from the typed the erasure of the original qualifier.
702+
val owner = erasure(tree.qualifier.typeOpt).typeSymbol
703703
if defn.isFunctionClass(owner) then owner else NoSymbol
704704
else
705705
val owner = sym.maybeOwner

tests/pos/i13426.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
val f = [R] => () => [A] => (a: A => R, b: A) => a(b)
2+
val x = f[Int]()(_, 3)

tests/pos/i6678.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object O {
2+
val f = (i:Int) => [T] => (s:String) => 2
3+
def m = f(1)("a")
4+
}

tests/pos/i8921.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type R[F[_], A] =[B] => (A => F[B]) => F[B]
2+
3+
type M[F[_]] =[A, B] => (A => F[B]) => F[A] => F[B]
4+
5+
def mr[F[_]]: M[[A] =>> R[F, A]] =
6+
[A, B] => (f: A => R[F, B]) => (m: R[F, A]) =>
7+
[C] => (k: B => F[C]) => m(a => f(a)(k))

tests/run/i13304.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo

tests/run/i13304.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait Zero[F[_]]:
2+
def zero[A]: F[A]
3+
4+
given Zero[List] with
5+
def zero[A] = List.empty[A]
6+
7+
given Zero[Option] with
8+
def zero[A] = Option.empty[A]
9+
10+
11+
@main def Test =
12+
val test = [F[_]] => (f: Zero[F]) ?=> [G[_]] => (g: Zero[G]) ?=> println("foo")
13+
test[List][Option]

0 commit comments

Comments
 (0)