Skip to content

Commit dab985a

Browse files
committed
Improve Types::asNonLiteralType for TKeyedArray
1 parent 2b9aa88 commit dab985a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Toolkit/Types.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ public function asNonLiteralType(Union $type): Union
212212
: new TNonEmptyString(),
213213
$a instanceof TLiteralInt => new TInt(),
214214
$a instanceof TLiteralFloat => new TFloat(),
215-
$a instanceof TKeyedArray => new TNonEmptyArray([
216-
self::asNonLiteralType($a->getGenericKeyType()),
217-
self::asNonLiteralType($a->getGenericValueType()),
218-
]),
215+
$a instanceof TKeyedArray => $a->is_list
216+
? new TNonEmptyList($a->getGenericValueType())
217+
: new TNonEmptyArray([
218+
self::asNonLiteralType($a->getGenericKeyType()),
219+
self::asNonLiteralType($a->getGenericValueType()),
220+
]),
219221
$a instanceof TNonEmptyList => new TNonEmptyList(
220222
self::asNonLiteralType($a->type_param),
221223
),

0 commit comments

Comments
 (0)