forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow opaque type aliases of context functions
We could allow them but they would not do what one probably expects (i.e. create context closures). This is because abstract types upper-bounded by context functions don't do that either (see neg/i16035a.scala), and we have to keep semantic equivalence between the two. Therefore, it's better to disallow them. Fixes scala#16035
- Loading branch information
1 parent
1e8a4c8
commit c561dfd
Showing
7 changed files
with
50 additions
and
1 deletion.
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
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
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,12 @@ | ||
object Scope: | ||
opaque type Uses[A, B] = A ?=> B // error | ||
opaque type UsesAlt = [A, B] =>> A ?=> B // error | ||
|
||
object Uses: | ||
def apply[A, B](fn: A ?=> B): Uses[A, B] = fn | ||
|
||
import Scope.* | ||
val uses = | ||
given Int = 1 | ||
Uses[Int, String](i ?=> s"*$i*") | ||
|
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,14 @@ | ||
trait S: | ||
type Uses[A, B] <: A ?=> B | ||
object Uses: | ||
def apply[A, B](fn: A ?=> B): Uses[A, B] = fn // error | ||
val uses1 = | ||
given Int = 1 | ||
Uses[Int, String](i ?=> s"*$i*") | ||
|
||
object I extends S: | ||
type Uses[A, B] = A ?=> B | ||
val uses2 = | ||
given Int = 1 | ||
Uses[Int, String](i ?=> s"*$i*") | ||
|
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,11 @@ | ||
object Scope: | ||
type Uses[A, B] = A ?=> B | ||
|
||
object Uses: | ||
def apply[A, B](fn: A ?=> B): Uses[A, B] = fn | ||
|
||
import Scope.* | ||
val uses = | ||
given Int = 1 | ||
Uses[Int, String](i ?=> s"*$i*") | ||
|