Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document bug NodeList::getChildrenOfItemsOfType() does not refine
  • Loading branch information
lexidor committed May 24, 2023
commit 14a8feac9150e31726d1cfe4caa196bea04bee0c
36 changes: 36 additions & 0 deletions tests/NodeListGetChildrenOfItemsOfTypeTest.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

namespace Facebook\HHAST;

use namespace HH\Lib\C;
use type Facebook\HackTest\HackTest;

final class NodeListGetChildrenOfItemsOfTypeTest extends HackTest {
public function testRefinesType(): void {
$node_list = static::getNodeListOfItemsOfIExpression();
$literal_expression =
$node_list->getChildrenOfItemsOfType(LiteralExpression::class)
|> C\firstx($$);
static::takesT<LiteralExpression>($literal_expression);
}

private static function getNodeListOfItemsOfIExpression(
): NodeList<ListItem<IExpression>> {
// NodeList(123,)
return new NodeList(
vec[new ListItem(
new LiteralExpression(new DecimalLiteralToken(null, null, '123')),
new CommaToken(null, null),
)],
);
}

private static function takesT<<<__Explicit>> T>(T $_): void {}
}