-
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.
Map regular function types to impure function types when unpickling
Map regular function types to impure function types when unpickling a class under -Ycc that was not itself compiled with -Ycc.
- Loading branch information
Showing
6 changed files
with
73 additions
and
4 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
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,6 @@ | ||
object Lib: | ||
extension [A](xs: Seq[A]) | ||
def mapp[B](f: A => B): Seq[B] = | ||
xs.map(f.asInstanceOf[A -> B]) | ||
|
||
|
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,15 @@ | ||
import language.experimental.saferExceptions | ||
import Lib.* | ||
|
||
class LimitExceeded extends Exception | ||
|
||
val limit = 10e9 | ||
|
||
def f(x: Double): Double throws LimitExceeded = | ||
if x < limit then x * x else throw LimitExceeded() | ||
|
||
@main def test(xs: Double*) = | ||
try println(xs.mapp(f).sum) | ||
catch case ex: LimitExceeded => println("too large") | ||
|
||
|
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,18 @@ | ||
import language.experimental.saferExceptions | ||
|
||
class LimitExceeded extends Exception | ||
|
||
val limit = 10e9 | ||
|
||
extension [A](xs: Seq[A]) | ||
def mapp[B](f: A => B): Seq[B] = | ||
xs.map(f.asInstanceOf[A -> B]) | ||
|
||
def f(x: Double): Double throws LimitExceeded = | ||
if x < limit then x * x else throw LimitExceeded() | ||
|
||
@main def test(xs: Double*) = | ||
try println(xs.mapp(f).sum + xs.map(f).sum) | ||
catch case ex: LimitExceeded => println("too large") | ||
|
||
|