-
Notifications
You must be signed in to change notification settings - Fork 1.1k
TyperState crash: search for extension method in implicit scope #18687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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 |
Note that this error (instead of the crash) can also be produced by unwrapping this code block outside of getOrElse. |
Likely duplicate of #16326 but will keep both open while I dig deeper. |
Compiler version
3.3.1
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: