Skip to content

Fix erasure of curried polymorphic function types #13664

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 2 commits into from
Oct 3, 2021
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: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,8 @@ object Erasure {
def mapOwner(sym: Symbol): Symbol =
if !sym.exists && tree.name == nme.apply then
// PolyFunction apply Selects will not have a symbol, so deduce the owner
// from the typed qual.
val owner = qual1.tpe.typeSymbol
// from the typed the erasure of the original qualifier.
val owner = erasure(tree.qualifier.typeOpt).typeSymbol
if defn.isFunctionClass(owner) then owner else NoSymbol
else
val owner = sym.maybeOwner
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/i13426.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val f = [R] => () => [A] => (a: A => R, b: A) => a(b)
val x = f[Int]()(_, 3)
4 changes: 4 additions & 0 deletions tests/pos/i6678.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object O {
val f = (i:Int) => [T] => (s:String) => 2
def m = f(1)("a")
}
7 changes: 7 additions & 0 deletions tests/pos/i8921.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type R[F[_], A] =[B] => (A => F[B]) => F[B]

type M[F[_]] =[A, B] => (A => F[B]) => F[A] => F[B]

def mr[F[_]]: M[[A] =>> R[F, A]] =
[A, B] => (f: A => R[F, B]) => (m: R[F, A]) =>
[C] => (k: B => F[C]) => m(a => f(a)(k))
1 change: 1 addition & 0 deletions tests/run/i13304.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
13 changes: 13 additions & 0 deletions tests/run/i13304.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trait Zero[F[_]]:
def zero[A]: F[A]

given Zero[List] with
def zero[A] = List.empty[A]

given Zero[Option] with
def zero[A] = Option.empty[A]


@main def Test =
val test = [F[_]] => (f: Zero[F]) ?=> [G[_]] => (g: Zero[G]) ?=> println("foo")
test[List][Option]