1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Don’t clobber intersection types after generic in union

Fixes #3274
This commit is contained in:
Brown 2020-04-30 23:15:16 -04:00
parent 470bf807b7
commit bb1c8a9d74
2 changed files with 14 additions and 1 deletions

View File

@ -504,7 +504,9 @@ class TypeCombination
foreach ($combination->object_type_params as $generic_type => $generic_type_params) {
$generic_type = substr($generic_type, 0, (int) strpos($generic_type, '<'));
$new_types[] = new TGenericObject($generic_type, $generic_type_params);
$generic_object = new TGenericObject($generic_type, $generic_type_params);
$generic_object->extra_types = $combination->extra_types;
$new_types[] = $generic_object;
}
if ($combination->class_string_types) {

View File

@ -200,6 +200,17 @@ class TypeParseTest extends TestCase
);
}
/**
* @return void
*/
public function testIteratorAndTraversableOrNull()
{
$this->assertSame(
'Iterator<mixed, int>&Traversable|null',
(string) Type::parseString('Iterator<mixed, int>&Traversable|null')
);
}
/**
* @return void
*/