Skip to content

Commit

Permalink
[inferhack] test case for changes to hackc intended to make constants…
Browse files Browse the repository at this point in the history
… in traits work properly

Reviewed By: davidpichardie

Differential Revision:
D62647632

Privacy Context Container: L1208441

fbshipit-source-id: a0b9c7a34e39db1f932a8ff1a7dd7e4de828543d
  • Loading branch information
Nick Benton authored and facebook-github-bot committed Sep 18, 2024
1 parent 3a5c261 commit c1bd05a
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions infer/tests/codetoanalyze/hack/pulse/constinit.hack
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
public static async function mainOK(classname<C> $c): Awaitable<void> {
$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
Expand All @@ -41,4 +58,14 @@ class Tester {
return; // UAA error
};
}

// no longer an FP
public static async function main2OK(): Awaitable<void> {
if (T1::INDEX === 1) {
return; // should always happen
}
$_ = async {
return; // UAA error, should be unreachable
};
}
}

0 comments on commit c1bd05a

Please sign in to comment.