-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
In order to implement a PartialFunction one needs to define both
def isDefinedAt(x: T)
def apply(x: T)
so there are two abstract methods.
PartialFunction currently is treated specially,
https://github.com/lampepfl/dotty/blob/master/src/dotty/tools/dotc/core/Types.scala#L2723-L2730
forcing it to be treated as a SAM.
The comment says that
// In the future it would be better to merge
// Function and PartialFunction, have Function1 contain a isDefinedAt method
// def isDefinedAt(x: T) = true
// and overwrite that method whenever the function body is a sequence of
// case clauses.
The comment means that Function1 instances which are PartialFunctions could not be SAMs as they need to override a method.