Open m8nmueller opened 1 year ago
replacing the argument to resume results in another strange error:
trait SuspendSupport:
type Suspension[-T, +R]
extension [T, R](s: Suspension[T, R])
def resume(arg: T): R
def suspend[T, R](body: Suspension[T, R] => R): T
trait Async(using val support: SuspendSupport)
private class YZ(using ac: Async):
private def test =
Some(()).getOrElse:
ac.support.suspend[scala.util.Try[Unit], Unit](k =>
k.resume(??? : scala.util.Failure[Nothing])
)
-- [E007] Type Mismatch Error: test.scala:17:8 ---------------------------------
17 | k.resume(??? : scala.util.Failure[Nothing])
| ^
|Found: (k : YZ.this.ac.support.Suspension[util.Try[Unit], Unit])
|Required: ?{ resume: ? }
|Note that implicit extension methods cannot be applied because they are ambiguous;
|both YZ.this.ac.support and YZ.this.ac.support provide an extension method `resume` on (k : YZ.this.ac.support.Suspension[util.Try[Unit], Unit])
|
| longer explanation available when compiling with `-explain`
1 error found
importing the extension explicitly avoids the crash, as there is no longer "implicit extension method" search:
trait SuspendSupport:
type Suspension[-T, +R]
extension [T, R](s: Suspension[T, R])
def resume(arg: T): R
def suspend[T, R](body: Suspension[T, R] => R): T
trait Async(using val support: SuspendSupport)
private class YZ(using ac: Async):
import ac.support.resume
private def test =
Some(()).getOrElse:
ac.support.suspend[scala.util.Try[Unit], Unit](k =>
k.resume(scala.util.Failure(Exception()))
)
This is also a regression from error to crash between 3.0.2 and 3.1.0 (fixing the usage of fewer braces) - however as it was always an error I think perhaps this isn't as serious as standard regression
replacing the argument to resume results in another strange error:
trait SuspendSupport: type Suspension[-T, +R] extension [T, R](s: Suspension[T, R]) def resume(arg: T): R def suspend[T, R](body: Suspension[T, R] => R): T trait Async(using val support: SuspendSupport) private class YZ(using ac: Async): private def test = Some(()).getOrElse: ac.support.suspend[scala.util.Try[Unit], Unit](k => k.resume(??? : scala.util.Failure[Nothing]) )
-- [E007] Type Mismatch Error: test.scala:17:8 --------------------------------- 17 | k.resume(??? : scala.util.Failure[Nothing]) | ^ |Found: (k : YZ.this.ac.support.Suspension[util.Try[Unit], Unit]) |Required: ?{ resume: ? } |Note that implicit extension methods cannot be applied because they are ambiguous; |both YZ.this.ac.support and YZ.this.ac.support provide an extension method `resume` on (k : YZ.this.ac.support.Suspension[util.Try[Unit], Unit]) | | longer explanation available when compiling with `-explain` 1 error found
Note that this error (instead of the crash) can also be produced by unwrapping this code block outside of getOrElse.
Likely duplicate of https://github.com/lampepfl/dotty/issues/16326 but will keep both open while I dig deeper.
Compiler version
3.3.1
Minimized code
Output (click arrow to expand)