Permalink
Browse files

Account static methods as source of expressions that produce mutable …

…values

Summary: As in title

Reviewed By: jamesjwu

Differential Revision: D7326427

fbshipit-source-id: f23ab59ae59aa3fae3d93121305eafe836bc9195
  • Loading branch information...
vladima authored and hhvm-bot committed Mar 19, 2018
1 parent 82a61ab commit 42fd0c9f7510bb9445ec8a1a99af36433e3f5d71
@@ -31,7 +31,8 @@ let rec expr_returns_owned_mutable
| T.Call (_, (_, T.Id id), _, _, _)
| T.Call (_, (_, T.Fun_id id), _, _, _) ->
fun_returns_mutable env id
| T.Call (_, ((_, (Some (_, Tfun fty))), T.Obj_get _), _, _, _) ->
| T.Call (_, ((_, (Some (_, Tfun fty))), T.Obj_get _), _, _, _)
| T.Call (_, ((_, (Some (_, Tfun fty))), T.Class_const _), _, _, _)->
fty.ft_returns_mutable
(* conditional operator returns owned mutable if both consequence and alternative
return owned mutable *)
@@ -0,0 +1,21 @@
<?hh // strict
class A {
<<__Rx, __Mutable>>
public function __construct(private int $x) {
}
<<__Rx, __MutableReturn>>
public static function get(): A {
return new A(1);
}
<<__Rx, __Mutable>>
public function setX(int $newX): void {
$this->x = $newX;
}
}
<<__Rx>>
function f(): void {
$a = A::get();
$a->setX(5);
}

0 comments on commit 42fd0c9

Please sign in to comment.