diff --git a/infer/tests/codetoanalyze/hack/pulse/constinit.hack b/infer/tests/codetoanalyze/hack/pulse/constinit.hack index c6fe188a2e1..8f5342cf648 100644 --- a/infer/tests/codetoanalyze/hack/pulse/constinit.hack +++ b/infer/tests/codetoanalyze/hack/pulse/constinit.hack @@ -25,11 +25,28 @@ class D extends C { const int Dc = 2; } +// a more complex situation that really happens +trait T1 { + const int INDEX = C1::INDEX; +} + +class C1 { + use T2; +} + +trait T2 implements I1 {} + +interface I1 extends I2 {} + +interface I2 { + const int INDEX = 1; +} + class Tester { - public static async function mainOK(): Awaitable { + public static async function mainOK(classname $c): Awaitable { $d = D::Dc; // at this point we should have called, and marked as - // called, C$static._86init + // called, C$static._86constinit // So the subsequent access to C::Cc shouldn't call constinit first $c = C::Cc; // next bit shows we're dealing with constants in interfaces properly @@ -41,4 +58,14 @@ class Tester { return; // UAA error }; } + + // no longer an FP + public static async function main2OK(): Awaitable { + if (T1::INDEX === 1) { + return; // should always happen + } + $_ = async { + return; // UAA error, should be unreachable + }; + } }