From c26866aed73922c3657f5faebb0dfc2d36b519b2 Mon Sep 17 00:00:00 2001 From: Lexidor Digital <31805625+lexidor@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:51:47 +0000 Subject: [PATCH] Require and support hhast 4.158 (#36) * Require hhvm 4.158 * The hsl is always built-in. * ext_watchman and HH\Facts are always available. * varray eq vec and darray eq dict is always true. * Parsing for varray and darray remains supported. * Update CI to 4.158 * Support autoloading with ext_watchman * Fix lint * Drop scanning for trait conflict resolutions * They have been removed from Hack --- .gitattributes | 1 + .github/workflows/build-and-test.yml | 2 +- .hhvmconfig.hdf | 3 +++ composer.json | 7 +++---- hh_autoload.json | 3 ++- src/consumers/scope_from_ast_and_ns.hack | 10 ++-------- src/expression/StaticDarrayExpression.hack | 6 +++--- src/expression/StaticListExpression.hack | 5 +---- src/expression/StaticShapeExpression.hack | 6 +++--- src/expression/StaticVarrayExpression.hack | 8 ++++---- tests/AttributesTest.hack | 18 +++++++++--------- tests/RelationshipsTest.hack | 12 ------------ 12 files changed, 32 insertions(+), 49 deletions(-) create mode 100644 .hhvmconfig.hdf diff --git a/.gitattributes b/.gitattributes index 1a3d880..be50ca0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ tests/ export-ignore bin/ export-ignore .hhconfig export-ignore +.hhvmconfig.hdf export-ignore *.hack linguist-language=Hack diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 67c7f0e..f8d9ca7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [ ubuntu ] hhvm: - - '4.157' + - '4.158' - latest - nightly runs-on: ${{matrix.os}}-latest diff --git a/.hhvmconfig.hdf b/.hhvmconfig.hdf new file mode 100644 index 0000000..e8800ca --- /dev/null +++ b/.hhvmconfig.hdf @@ -0,0 +1,3 @@ +Autoload { + Query = {"expression": ["allof", ["type", "f"], ["suffix", ["anyof", "hack", "php"]], ["not",["anyof",["dirname",".var"],["dirname",".git"]]]]} +} \ No newline at end of file diff --git a/composer.json b/composer.json index 8de4474..b24e2df 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,12 @@ } }, "require": { - "hhvm": "^4.157", - "hhvm/hhvm-autoload": "^2.0|^3.0", - "hhvm/hsl": "^4.0", + "hhvm": "^4.158", "hhvm/type-assert": "^3.2|^4.0", - "hhvm/hhast": "^4.157" + "hhvm/hhast": "^4.158" }, "require-dev": { + "hhvm/hhvm-autoload": "^2.0|^3.0", "facebook/fbexpect": "^2.6.1", "hhvm/hacktest": "^2.0" }, diff --git a/hh_autoload.json b/hh_autoload.json index 7db537a..bab2fb1 100644 --- a/hh_autoload.json +++ b/hh_autoload.json @@ -4,5 +4,6 @@ ], "devRoots": [ "tests/" - ] + ], + "useFactsIfAvailable": true } diff --git a/src/consumers/scope_from_ast_and_ns.hack b/src/consumers/scope_from_ast_and_ns.hack index 9c4b395..3da25fc 100644 --- a/src/consumers/scope_from_ast_and_ns.hack +++ b/src/consumers/scope_from_ast_and_ns.hack @@ -54,16 +54,10 @@ function scope_from_ast_and_ns( $ast->getChildrenOfType(HHAST\MethodishDeclaration::class), $node ==> method_from_ast($context, $node), ), - /* trait use statements = */ Vec\concat( - Vec\map( + /* trait use statements = */ Vec\map( $ast->getChildrenOfType(HHAST\TraitUse::class), $node ==> $node->getNames()->getChildrenOfType(HHAST\Node::class), - ), - Vec\map( - $ast->getChildrenOfType(HHAST\TraitUseConflictResolution::class), - $node ==> $node->getNames()->getChildrenOfType(HHAST\Node::class), - ), - ) + ) |> Vec\flatten($$) |> Vec\map($$, $node ==> typehint_from_ast($context, $node)) |> Vec\filter_nulls($$), diff --git a/src/expression/StaticDarrayExpression.hack b/src/expression/StaticDarrayExpression.hack index 6287cb6..b69841f 100644 --- a/src/expression/StaticDarrayExpression.hack +++ b/src/expression/StaticDarrayExpression.hack @@ -11,16 +11,16 @@ namespace Facebook\DefinitionFinder\Expression; use namespace Facebook\HHAST; -final class StaticDarrayExpression extends Expression> { +final class StaticDarrayExpression extends Expression> { const type TNode = HHAST\DarrayIntrinsicExpression; <<__Override>> protected static function matchImpl( this::TNode $node, - ): ?Expression> { + ): ?Expression> { $members = $node->getMembers(); $members = $members?->getChildrenOfItemsOfType(HHAST\Node::class) ?? vec[]; - $ret = darray[]; + $ret = dict[]; foreach ($members as $m) { $pair = StaticElementInitializerExpression::match($m); if ($pair === null) { diff --git a/src/expression/StaticListExpression.hack b/src/expression/StaticListExpression.hack index 82a956f..a727117 100644 --- a/src/expression/StaticListExpression.hack +++ b/src/expression/StaticListExpression.hack @@ -18,10 +18,7 @@ final class StaticListExpression extends Expression> { protected static function matchImpl( HHAST\NodeList> $n, ): ?Expression> { - $items = Vec\map( - $n->getChildrenOfItems(), - StaticExpression::match<>, - ); + $items = Vec\map($n->getChildrenOfItems(), StaticExpression::match<>); $out = vec[]; foreach ($items as $item) { if ($item === null) { diff --git a/src/expression/StaticShapeExpression.hack b/src/expression/StaticShapeExpression.hack index ecceba1..08e93ca 100644 --- a/src/expression/StaticShapeExpression.hack +++ b/src/expression/StaticShapeExpression.hack @@ -11,16 +11,16 @@ namespace Facebook\DefinitionFinder\Expression; use namespace Facebook\HHAST; -final class StaticShapeExpression extends Expression> { +final class StaticShapeExpression extends Expression> { const type TNode = HHAST\ShapeExpression; <<__Override>> protected static function matchImpl( this::TNode $node, - ): ?Expression> { + ): ?Expression> { $members = $node->getFields(); $members = $members?->getChildrenOfItemsOfType(HHAST\Node::class) ?? vec[]; - $ret = darray[]; + $ret = dict[]; foreach ($members as $m) { $pair = StaticFieldInitializerExpression::match($m); if ($pair === null) { diff --git a/src/expression/StaticVarrayExpression.hack b/src/expression/StaticVarrayExpression.hack index 52bec2d..0235307 100644 --- a/src/expression/StaticVarrayExpression.hack +++ b/src/expression/StaticVarrayExpression.hack @@ -11,22 +11,22 @@ namespace Facebook\DefinitionFinder\Expression; use namespace Facebook\HHAST; -final class StaticVarrayExpression extends Expression> { +final class StaticVarrayExpression extends Expression> { const type TNode = HHAST\VarrayIntrinsicExpression; <<__Override>> protected static function matchImpl( this::TNode $node, - ): ?Expression> { + ): ?Expression> { $m = $node->getMembers(); if ($m === null) { - return new self(varray[]); + return new self(vec[]); } $values = StaticListExpression::match($m); if ($values === null) { return null; } - $out = varray[]; + $out = vec[]; foreach ($values->getValue() as $value) { $out[] = $value; } diff --git a/tests/AttributesTest.hack b/tests/AttributesTest.hack index c8020f7..86f1f75 100644 --- a/tests/AttributesTest.hack +++ b/tests/AttributesTest.hack @@ -111,16 +111,16 @@ class AttributesTest extends \Facebook\HackTest\HackTest { tuple('INF', \INF), tuple('+123', 123), tuple('-123', -123), - tuple('varray[]', varray[]), - tuple('varray[123]', varray[123]), - tuple('varray[123,]', varray[123]), - tuple('varray[123,456]', varray[123, 456]), - tuple('varray[123,456,]', varray[123, 456]), + tuple('varray[]', vec[]), + tuple('varray[123]', vec[123]), + tuple('varray[123,]', vec[123]), + tuple('varray[123,456]', vec[123, 456]), + tuple('varray[123,456,]', vec[123, 456]), tuple('1.23', 1.23), - tuple('varray[123,456]', varray[123, 456]), - tuple('varray[123 , 456]', varray[123, 456]), - tuple('darray[123 => 456]', darray[123 => 456]), - tuple('shape()', darray[]), + tuple('varray[123,456]', vec[123, 456]), + tuple('varray[123 , 456]', vec[123, 456]), + tuple('darray[123 => 456]', dict[123 => 456]), + tuple('shape()', dict[]), tuple( 'shape("foo" => "bar", "herp" => 123)', shape('foo' => 'bar', 'herp' => 123), diff --git a/tests/RelationshipsTest.hack b/tests/RelationshipsTest.hack index 74003ff..073bd4d 100644 --- a/tests/RelationshipsTest.hack +++ b/tests/RelationshipsTest.hack @@ -90,18 +90,6 @@ class RelationshipsTest extends \Facebook\HackTest\HackTest { expect($def->getTraitNames())->toBeSame(vec['Herp', 'Derp']); } - public async function testUseTraitWithConflictResolution(): Awaitable { - $data = "getClass('MyClass'); - expect($def->getTraitNames())->toBeSame(vec['Foo', 'Bar']); - } - public async function testUsesTraitsInNamespace(): Awaitable { $data = "