1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix templated class conversion allowing child class

This commit is contained in:
Matthew Brown 2019-01-13 14:40:21 -05:00
parent 2c55e7aabb
commit 3ca5ec9281
3 changed files with 9 additions and 2 deletions

View File

@ -804,7 +804,7 @@ class AssertionFinder
if ($var_type->from_docblock || $other_type->from_docblock) {
if (IssueBuffer::accepts(
new DocblockTypeContradiction(
$var_type . ' does not contain ' . $other_type,
$var_type->getId() . ' does not contain ' . $other_type->getId(),
new CodeLocation($source, $conditional)
),
$source->getSuppressedIssues()

View File

@ -997,7 +997,7 @@ class Union
$new_types[$unknown_class_string->getKey()] = $unknown_class_string;
} elseif ($template_type_part instanceof Type\Atomic\TNamedObject) {
$literal_class_string = new Type\Atomic\TLiteralClassString($template_type_part->value);
$literal_class_string = new Type\Atomic\TClassString($template_type_part->value);
$new_types[$literal_class_string->getKey()] = $literal_class_string;
}

View File

@ -1233,6 +1233,13 @@ class TemplateTest extends TestCase
echo $object->id;
}
}
class FooChild extends Foo {}
/** @param Collection<Foo> $c */
function handleCollectionOfFoo(Collection $c) : void {
if ($c->getType() === FooChild::class) {}
}',
],
'getEquateClass' => [