diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index aefb2266e86..ddb86abbf3a 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -811,6 +811,7 @@ private function inferPropertyTypeFromConstructor( } $storage->external_mutation_free = true; + $storage->mutation_free_inferred = true; foreach ($assigned_properties as $property_name => $property_type) { $classlike_storage->properties[$property_name]->type = $property_type; diff --git a/tests/ClassTest.php b/tests/ClassTest.php index 580622b9ea5..5feddebacd8 100644 --- a/tests/ClassTest.php +++ b/tests/ClassTest.php @@ -372,6 +372,32 @@ function foo(string $a_class) : void { } }', ], + 'markInferredMutationFreeDuringPropertyTypeInferenceAsActuallyInferred' => [ + 'code' => 'renderer = $r; + } + } + + class ConcreteClass extends AbstractClass + { + public function __construct(A $r) + { + parent::__construct($r); + } + } + ', + ], 'interfaceExistsCreatesClassString' => [ 'code' => '