Open
Description
Compiler version
3.2.1-RC2
Minimized code
class Foo {
def member: String = this.toString
}
def method[T](c: T => Boolean): T = ???
val y: Foo => Boolean = _ => true
val x : String = "5"
method(y).member // error
Output
Found: Nothing
Required: ?{ member: ? }
Note that implicit conversions were not tried because the result of an implicit conversion
must be more specific than ?{ member: <?> }
Expectation
Should compile. I understand that Nothing
is inferrable here and that I should not expect .member
to be able to constrain the type of T
. Since Nothing <: Person
I suppose it makes sense to infer the tightest type, but does it? Scala widens types in many places and I'm not sure there's any reason to ever want to infer Nothing
here. This case is simple enough that I suspect it is intended behavior, but I'm still curious.