Update documentation for Function class.

Fixes #36303

Bug: https://github.com/dart-lang/sdk/issues/36303
Change-Id: I1e995ee624660b5cfc40b9395b34beeeb985eeda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118989
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
This commit is contained in:
Lasse R.H. Nielsen 2019-09-27 13:30:33 +00:00 committed by commit-bot@chromium.org
parent 9852c135a7
commit 30b2a5dbb3

View file

@ -47,23 +47,26 @@ abstract class Function {
/**
* Test whether another object is equal to this function.
*
* System-created function objects are only equal to other functions.
* Function objects are only equal to other function objects
* (an object satisfying `object is Function`),
* and never to non-function objects.
*
* Two function objects are known to represent the same function if
* Some function objects are considered equal by `==`
* because they are recognized as representing the "same function":
*
* - It is the same object. Static and top-level functions are compile time
* constants when used as values, so referring to the same function twice
* always give the same object,
* - or if they refer to the same member method extracted from the same object.
* Extracting a member method as a function value twice gives equal, but
* not necessarily identical, function values.
* always give the same object, as does referring to a local function
* declaration twice in the same scope where it was declared.
* - if they refer to the same member method extracted from the same object.
* Repeatedly extracting an instance method of an object as a function value
* gives equal, but not necessarily identical, function values.
*
* Function expressions never give rise to equal function objects. Each time
* a function expression is evaluated, it creates a new closure value that
* is not known to be equal to other closures created by the same expression.
*
* Classes implementing `Function` by having a `call` method should have their
* own `operator==` and `hashCode` depending on the object.
* Different evaluations of function literals
* never give rise to equal function objects.
* Each time a function literal is evaluated,
* it creates a new function value that is not equal to any other function
* value, not even ones created by the same expression.
*/
bool operator ==(Object other);
}