-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
My use case is to give students a method with an empty body and a postcondition, and to ask them to complete the body so it satisfies the postcondition:
object test {
def m(x: Int): Int = {
???
} ensuring(ans => ans == x)
}
This compiles with Dotty 0.7.0 but Dotty master gives:
-- [E008] Member Not Found Error: inferEnsuring.scala:4:5 ----------------------
2 | def m(x: Int): Int = {
3 | ???
| ^
| value `ensuring` is not a member of Nothing
one error found
Since ensuring
is a member of Int
and since Nothing <: Int
, ensuring
should also be a member of Nothing
.
Although the member is injected by an implicit conversion to Ensuring
, the same reasoning applies: the implicit conversion applies to every subtype of Any
, and Nothing <: Any
.