mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
fix reconciliation between a list and iterable
This commit is contained in:
parent
2e8d575543
commit
8929f8b4d8
@ -771,12 +771,25 @@ class AssertionReconciler extends Reconciler
|
||||
}
|
||||
|
||||
if ($type_1_param->getId() !== $type_2_param->getId()) {
|
||||
$type_1_param = $type_2_param;
|
||||
$type_1_param = $type_2_param->setPossiblyUndefined($type_1_param->possibly_undefined);
|
||||
}
|
||||
}
|
||||
unset($type_1_param);
|
||||
|
||||
$matching_atomic_type = $type_1_atomic->setProperties($type_1_properties);
|
||||
if ($type_1_atomic->fallback_params === null) {
|
||||
$fallback_types = null;
|
||||
} else {
|
||||
//any fallback type is now the value of iterable
|
||||
$fallback_types = [$type_1_atomic->fallback_params[0], $type_2_param];
|
||||
}
|
||||
|
||||
$matching_atomic_type = new TKeyedArray(
|
||||
$type_1_properties,
|
||||
$type_1_atomic->class_strings,
|
||||
$fallback_types,
|
||||
$type_1_atomic->is_list,
|
||||
$type_1_atomic->from_docblock,
|
||||
);
|
||||
$atomic_comparison_results->type_coerced = true;
|
||||
}
|
||||
|
||||
|
@ -179,6 +179,7 @@ class ReconcilerTest extends TestCase
|
||||
'IsNotAClassReconciliation' => ['int', new Assertion\IsNotAClass(new TNamedObject('IDObject'), true), 'int|IDObject'],
|
||||
'nonEmptyArray' => ['non-empty-array<array-key, mixed>', new IsType(Atomic::create('non-empty-array')), 'array'],
|
||||
'nonEmptyList' => ['non-empty-list<mixed>', new IsType(Atomic::create('non-empty-list')), 'array'],
|
||||
'ListOfInts' => ['list<int>', new IsType(new TIterable([Type::getMixed(), Type::getInt()])), 'list<mixed>'],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user