Reject escaping use of 'this' in disposable implementation
commit26cfc6c4ea81a81181e2f23ccc9a512afaa8df3e
authorAndrew Kennedy <akenn@fb.com>
Mon, 27 Nov 2017 22:28:42 +0000 (27 14:28 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Mon, 27 Nov 2017 22:45:02 +0000 (27 14:45 -0800)
tree978800fa539a92166edf76224be28410fab5dec2
parent96f5d5268ffd83e86073568b331b13e3013f56c2
Reject escaping use of 'this' in disposable implementation

Summary:
Continuing the implementation of type-checker rules that ensure that disposables are created and
disposed only via `using` clauses, we now outlaw the use of `$this` in implementations of
`IDisposable` or `IAsyncDisposable` except as method receivers or when passed as parameters
marked with the attribute `<<__AcceptDisposable>>`. Note that the testing of the type of `$this`
against `IDisposable` or `IAsyncDisposable` also catches the case of traits marked `require implements IDisposable`
and similar.

Reviewed By: KendallHopkins

Differential Revision: D6413708

fbshipit-source-id: da5ca2e60ba872954f9a32049667a3afcbd2eadb
hphp/hack/src/typing/typing.ml
hphp/hack/src/utils/errors/errors.ml
hphp/hack/src/utils/errors/errors_sig.ml
hphp/hack/test/typecheck/using/using_bad_escaping_this.php [new file with mode: 0644]
hphp/hack/test/typecheck/using/using_bad_escaping_this.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/using/using_bad_escaping_this.php.no_format [new file with mode: 0644]