From c1ce543e81dd1c73f6c890d5115d1014be168926 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 17 Dec 2017 01:06:12 -0500 Subject: [PATCH] Make sure to clear previously inferred types when rechecking trait statements Fixes #399 --- .../Statements/Expression/CallChecker.php | 2 ++ tests/TraitTest.php | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Psalm/Checker/Statements/Expression/CallChecker.php b/src/Psalm/Checker/Statements/Expression/CallChecker.php index c9e7db30d..ab5efcc6f 100644 --- a/src/Psalm/Checker/Statements/Expression/CallChecker.php +++ b/src/Psalm/Checker/Statements/Expression/CallChecker.php @@ -1237,6 +1237,8 @@ class CallChecker $project_checker = $file_checker->project_checker; $source = $statements_checker->getSource(); + $stmt->inferredType = null; + if ($stmt->class instanceof PhpParser\Node\Name) { $fq_class_name = null; diff --git a/tests/TraitTest.php b/tests/TraitTest.php index 46ac3e9da..572503ded 100644 --- a/tests/TraitTest.php +++ b/tests/TraitTest.php @@ -332,6 +332,26 @@ class TraitTest extends TestCase use T; }', ], + 'differentMethodReturnTypes' => [ + '