Skip to content

Commit

Permalink
[inferhack] add test for 86pinit being called in factory
Browse files Browse the repository at this point in the history
Reviewed By: davidpichardie

Differential Revision:
D61539691

Privacy Context Container: L1208441

fbshipit-source-id: 0da54c98dd2fac8ea5cf29355308666549ef0d06
  • Loading branch information
Nick Benton authored and facebook-github-bot committed Aug 20, 2024
1 parent 476225b commit 77c5cd2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions infer/tests/codetoanalyze/hack/pulse/factory.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

namespace Factory;

<<__ConsistentConstruct>>
class A {
public int $x = 99;

public function __construct(public int $y) {
}
}

class B extends A {

public static function create(classname<A> $class): A {
return new $class(42);
}

public static async function genTestIt(): Awaitable<void> {
$a = self::create(B::class);
if ($a->x == 0) {
// this should never happen 'cos we've just set the property to 99
$_fail = async {
return 9;
};
}
return;
}

}

0 comments on commit 77c5cd2

Please sign in to comment.