Skip to content
Permalink
Browse files

Fix #2527 - no crash when template cannot be resolved

  • Loading branch information
muglug committed Dec 29, 2019
1 parent 0c7851a commit d3fb0181cb6b8b7c4268e6602b3ced229ffdce80
@@ -1851,7 +1851,7 @@ private static function isMatchingTypeContainedBy(
}

if (!$generic_params) {
throw new \UnexpectedValueException('$generic_params should not be empty');
return false;
}

$input_type_part = new TGenericObject(
@@ -340,7 +340,7 @@ public static function findMatchingAtomicTypeForTemplate(
}

if (!$new_generic_params) {
throw new \UnexpectedValueException('$new_generic_params should not be empty');
return new Atomic\TNamedObject($atomic_input_type->value);
}

return new Atomic\TGenericObject(
@@ -2716,7 +2716,7 @@ protected function doNormalize($v): string
return trim($v);
}
}'
]
],
];
}

@@ -3701,6 +3701,34 @@ function baz($t) {
}',
'error_message' => 'InvalidReturnStatement'
],
'noCrashForTooManyTemplateParams' => [
'<?php
interface InterfaceA {}
class ImplemX implements InterfaceA {}
interface DoStuff {
public function stuff(InterfaceA $object): void;
}
/**
* @implements DoStuff<ImplemX>
*/
class DoStuffX implements DoStuff {
public function stuff(InterfaceA $object): void {}
}
final class Foo {
/**
* @template A of InterfaceA
* @psalm-param DoStuff<A> $stuff
*/
public function __construct(DoStuff $stuff) {}
}
new Foo(new DoStuffX());',
'error_message' => 'InvalidArgument'
]
];
}
}

0 comments on commit d3fb018

Please sign in to comment.
You can’t perform that action at this time.