Open
Description
The NNBD spec says:
Calling a method (including an operator) or getter on a receiver of static type
Never
is treated by static analysis as producing a result of typeNever
. Tearing off a method from a receiver of static typeNever
produces a value of typeNever
. Applying an expression of typeNever
in the function position of a function call produces a result of typeNever
.
Assuming "operator" means "user-definable operator" (i.e. not &&
, ||
, or ??
), then as far as I can tell, the CFE implements this faithfully.
The analyzer is inconsistent, though:
expr1 operator expr2
, whereexpr1
has static typeNever
, has static typeNever
, as specified.expr(args)
, whereexpr
has static typeNever
, has static typeNever
, as specified.expr.identifier(args)
, whereexpr
has static typeNever
, has static typeNever
, as specified.identifier1.identifier2
, whereidentifier1
has static typeNever
, has static typeNever
, as specified.expr.identifier
, whereexpr
is an expression having static typeNever
, but is not a simple identifier, behaves as follows:- If
identifier
ishashCode
,toString
,runtimeType
, ornoSuchMethod
, the type is the same as it would be if the receiver type wereObject
(e.g.(throw '').toString
has typeString Function()
). - Otherwise, the type is
InvalidType
, but no error is issued.
- If
- In an extension whose
on
type isNever
,identifier
andidentifier(args)
are treated the same as they would be treated if theon
type wereObject
.