Permalink
Browse files

Change WaitHandle to Awaitable in hack

Summary: - Removed all references to WaitHandle in hphp/hack

Reviewed By: jano

Differential Revision: D6912972

fbshipit-source-id: ee3ff98b6283217e1b90889c456c3dba1ff8edfe
  • Loading branch information...
WizKid authored and hhvm-bot committed Feb 7, 2018
1 parent f9c9ef5 commit f918d01c726a441088b99055d428e8f1ddb442f3
@@ -106,17 +106,16 @@ final class Generator<Tk, +Tv, -Ts> implements KeyedIterator<Tk, Tv> {
public function rewind(): void {}
}
abstract class WaitHandle<+T> implements Awaitable<T> {
public function getWaitHandle(): this {}
abstract class Awaitable<+T> {
public static function setOnIOWaitEnterCallback(?(function(): void) $callback) {}
public static function setOnIOWaitExitCallback(?(function(): void) $callback) {}
public static function setOnJoinCallback(?(function(WaitableWaitHandle<mixed>): void) $callback) {}
}
final class StaticWaitHandle<+T> extends WaitHandle<T> {
final class StaticWaitHandle<+T> extends Awaitable<T> {
}
abstract class WaitableWaitHandle<+T> extends WaitHandle<T> {
abstract class WaitableWaitHandle<+T> extends Awaitable<T> {
}
abstract class ResumableWaitHandle<+T> extends WaitableWaitHandle<T> {
@@ -135,27 +134,27 @@ final class AsyncGeneratorWaitHandle<Tk, +Tv>
final class AwaitAllWaitHandle extends WaitableWaitHandle<void> {
public static function fromArray<T>(
array<WaitHandle<T>> $deps
): WaitHandle<void>;
array<Awaitable<T>> $deps
): Awaitable<void>;
public static function fromDict<Tk, Tv>(
dict<Tk, WaitHandle<Tv>> $deps
): WaitHandle<void>;
dict<Tk, Awaitable<Tv>> $deps
): Awaitable<void>;
public static function fromMap<Tk, Tv>(
ConstMap<Tk, WaitHandle<Tv>> $deps
): WaitHandle<void>;
ConstMap<Tk, Awaitable<Tv>> $deps
): Awaitable<void>;
public static function fromVec<T>(
vec<WaitHandle<T>> $deps
): WaitHandle<void>;
vec<Awaitable<T>> $deps
): Awaitable<void>;
public static function fromVector<T>(
ConstVector<WaitHandle<T>> $deps
): WaitHandle<void>;
ConstVector<Awaitable<T>> $deps
): Awaitable<void>;
public static function setOnCreateCallback(
?(function(AwaitAllWaitHandle, Vector<mixed>): void) $callback
): void {}
}
final class ConditionWaitHandle<T> extends WaitableWaitHandle<T> {
public static function create(WaitHandle<void> $child): ConditionWaitHandle<T> {}
public static function create(Awaitable<void> $child): ConditionWaitHandle<T> {}
public static function setOnCreateCallback(?(function(ConditionWaitHandle<T>, WaitableWaitHandle<void>): void) $callback) {}
public function succeed(T $result): void {}
public function fail(Exception $exception): void {}
@@ -827,10 +827,6 @@ interface ArrayAccess<Tk, Tv> {
public function offsetUnset(Tk $key): void;
}
interface Awaitable<+T> {
public function getWaitHandle(): WaitHandle<T>;
}
/**
* @see http://www.php.net/manual/en/jsonserializable.jsonserialize.php
*/
@@ -214,7 +214,7 @@ let emit_deprecation_warning scope = function
let rec is_awaitable h =
match h with
| _, A.Happly ((_, ("WaitHandle" | "Awaitable")), ([] | [_])) -> true
| _, A.Happly ((_, "Awaitable"), ([] | [_])) -> true
| _, (A.Hsoft h | A.Hoption h) -> is_awaitable h
| _ -> false
@@ -123,22 +123,22 @@ let rec hint_to_type_constraint
TC.make tc_name tc_flags
(* Elide the Awaitable class for async return types only *)
| A.Happly ((_, ("WaitHandle" | "Awaitable")), [(_, A.Happly((_, "void"), []))])
| A.Happly ((_, "Awaitable"), [(_, A.Happly((_, "void"), []))])
when skipawaitable ->
TC.make None []
| A.Happly ((_, ("WaitHandle" | "Awaitable")), [h])
| A.Hoption (_, A.Happly ((_, ("WaitHandle" | "Awaitable")), [h]))
| A.Happly ((_, "Awaitable"), [h])
| A.Hoption (_, A.Happly ((_, "Awaitable"), [h]))
when skipawaitable ->
hint_to_type_constraint ~kind ~tparams ~skipawaitable:false ~namespace h
| A.Hoption (_, A.Hsoft (_, A.Happly ((_, ("WaitHandle" | "Awaitable")), [h])))
| A.Hoption (_, A.Hsoft (_, A.Happly ((_, "Awaitable"), [h])))
when skipawaitable ->
make_tc_with_flags_if_non_empty_flags ~kind ~tparams ~skipawaitable ~namespace
h [TC.Soft; TC.HHType; TC.ExtendedHint]
| A.Happly ((_, ("WaitHandle" | "Awaitable")), [])
| A.Hoption (_, A.Happly ((_, ("WaitHandle" | "Awaitable")), []))
| A.Happly ((_, "Awaitable"), [])
| A.Hoption (_, A.Happly ((_, "Awaitable"), []))
when skipawaitable ->
TC.make None []
@@ -64,7 +64,6 @@ let alias_map = List.fold_left ~f:add_alias ~init:SMap.empty
HH_ONLY_TYPE("Awaitable");
HH_ONLY_TYPE("AsyncGenerator");
HH_ONLY_TYPE("WaitHandle");
HH_ONLY_TYPE("StaticWaitHandle");
HH_ONLY_TYPE("WaitableWaitHandle");
HH_ONLY_TYPE("ResumableWaitHandle");
@@ -52,7 +52,6 @@ let autoimport_classes = [
"AsyncKeyedIterator";
"InvariantException";
"AsyncGenerator";
"WaitHandle";
"StaticWaitHandle";
"WaitableWaitHandle";
"ResumableWaitHandle";
@@ -1,4 +1,4 @@
File "stdclass_final.php", line 3, characters 7-18:
You cannot extend final class stdClass (Typing[4035])
File "hhi_lib__srcs/classes.hhi", line 188, characters 13-20:
File "hhi_lib__srcs/classes.hhi", line 187, characters 13-20:
Declaration is here
@@ -1,4 +1,4 @@
File "stdclass_static_members.php", line 4, characters 13-23:
Could not find class variable $staticProp in type stdClass (Typing[4090])
File "hhi_lib__srcs/classes.hhi", line 188, characters 13-20:
File "hhi_lib__srcs/classes.hhi", line 187, characters 13-20:
Declaration of stdClass is here
@@ -2,5 +2,5 @@ File "stdclass_strict.php", line 9, characters 7-9:
Could not find member foo in an object of type stdClass (Typing[4053])
File "stdclass_strict.php", line 8, characters 8-21:
This is why I think it is an object of type stdClass
File "hhi_lib__srcs/classes.hhi", line 188, characters 13-20:
File "hhi_lib__srcs/classes.hhi", line 187, characters 13-20:
Declaration of stdClass is here
@@ -72,7 +72,7 @@ function main($a) {
'include',
AwaitAllWaitHandle::class.'::fromArray',
RescheduleWaitHandle::class.'::create',
WaitHandle::class.'::result',
WaitableWaitHandle::class.'::result',
);
verifyTestRun($stacks, $required_functions, $optional_functions);
if ($success) {
@@ -1,10 +1,10 @@
<?hh
WaitHandle::setOnIOWaitEnterCallback(function() {
WaitableWaitHandle::setOnIOWaitEnterCallback(function() {
echo "io wait enter\n";
});
WaitHandle::setOnIOWaitExitCallback(function() {
WaitableWaitHandle::setOnIOWaitExitCallback(function() {
echo "io wait exit\n";
});
@@ -11,7 +11,7 @@ function reschedule() {
);
}
function t(WaitHandle $wh, $a): void {
function t(Awaitable $wh, $a): void {
echo $wh->getName(), ' ', count($a), "\nbefore: ";
foreach ($a as $k => $aa) {
echo "$k:", HH\Asio\has_finished($aa) ? 1 : 0, ",";
@@ -1,7 +1,7 @@
<?hh
<<__MockClass>>
class MyWaitHandle extends WaitHandle {
class MyWaitHandle extends WaitableWaitHandle {
public function __construct() {
echo "Ha ha!\n";
}
@@ -1,4 +1,4 @@
<?hh
async function f(): WaitHandle {}
async function g(): WaitHandle<void> {}
async function f(): Awaitable {}
async function g(): Awaitable<void> {}
echo "Done\n";

0 comments on commit f918d01

Please sign in to comment.