-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow inferred parameter types always, when eta-expanding
Rather than drawing an exemption based on fully defined types, report the right function arity. This leads eta-expansion to leave off the type, so then the parameter type is inferred. In the test case pos/i18453 this leads to the type var ?A being instantiated to X, rather than ?A & ?B being constrained against X & Y, which leads to ?A being instantiated to X & Y - and then failing to find a Box[X & Y] in scope.
- Loading branch information
Showing
4 changed files
with
19 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
object Test { | ||
def f(i: => Int) = i + i | ||
val res = List(42).map(f) // error | ||
val res = List(42).map(f) | ||
|
||
val g: (=> Int) => Int = f | ||
val h: Int => Int = g // error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
trait Box[T] | ||
|
||
class Test: | ||
def f[A, B](c: A => A & B)(using ba: Box[A]): Unit = ??? | ||
|
||
def g[X, Y](using bx: Box[X]): Unit = | ||
def d(t: X): X & Y = t.asInstanceOf[X & Y] | ||
f(d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
trait Box[T] | ||
|
||
class Test: | ||
def f[A, B](c: A => A & B)(using ba: Box[A]): Unit = ??? | ||
|
||
def g[X, Y](using bx: Box[X]): Unit = | ||
def d(t: X): X & Y = t.asInstanceOf[X & Y] | ||
f(u => d(u)) |