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.
Avoid cyclic references due to experimental check when inlining
Fixes scala#16116
- Loading branch information
1 parent
003ce03
commit 36508ab
Showing
5 changed files
with
53 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ import scala.annotation.experimental | |
inline def g() = () | ||
|
||
def test: Unit = | ||
g() // errors | ||
g() // error | ||
() |
8 changes: 8 additions & 0 deletions
8
tests/neg-custom-args/no-experimental/experimentalInline2.scala
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 @@ | ||
import scala.annotation.experimental | ||
|
||
@experimental | ||
transparent inline def g() = () | ||
|
||
def test: Unit = | ||
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,39 @@ | ||
package x | ||
|
||
import scala.annotation.* | ||
import scala.concurrent.* | ||
|
||
trait CpsMonad[F[_]] { | ||
type Context | ||
} | ||
|
||
object CpsMonad { | ||
type Aux[F[_],C] = CpsMonad[F] { type Context = C } | ||
given CpsMonad[Future] with {} | ||
} | ||
|
||
@experimental | ||
object Test { | ||
|
||
@capability | ||
class CpsTransform[F[_]] { | ||
def await[T](ft: F[T]): { this } T = ??? | ||
} | ||
|
||
transparent inline def cpsAsync[F[_]](using m:CpsMonad[F]) = | ||
new Test.InfernAsyncArg | ||
|
||
class InfernAsyncArg[F[_],C](using am:CpsMonad.Aux[F,C]) { | ||
def apply[A](expr: (CpsTransform[F], C) ?=> A): F[A] = ??? | ||
} | ||
|
||
def asyncPlus[F[_]](a:Int, b:F[Int])(using cps: CpsTransform[F]): { cps } Int = | ||
a + (cps.await(b).asInstanceOf[Int]) | ||
|
||
def testExample1Future(): Unit = | ||
val fr = cpsAsync[Future] { | ||
val y = asyncPlus(1,Future successful 2).asInstanceOf[Int] | ||
y+1 | ||
} | ||
|
||
} |