diff --git a/src/Psalm/Type/ParseTree.php b/src/Psalm/Type/ParseTree.php index 87d034c91..f697f3e9d 100644 --- a/src/Psalm/Type/ParseTree.php +++ b/src/Psalm/Type/ParseTree.php @@ -396,6 +396,7 @@ class ParseTree } if ($current_parent && $current_parent instanceof ParseTree\IntersectionTree) { + $current_leaf = $current_parent; break; } diff --git a/tests/TypeParseTest.php b/tests/TypeParseTest.php index c7f42880b..87cf3b1e3 100644 --- a/tests/TypeParseTest.php +++ b/tests/TypeParseTest.php @@ -132,7 +132,7 @@ class TypeParseTest extends TestCase */ public function testIntersection() { - $this->assertSame('I1&I2', (string) Type::parseString('I1&I2')); + $this->assertSame('I1&I2&I3', (string) Type::parseString('I1&I2&I3')); } /** @@ -170,6 +170,14 @@ class TypeParseTest extends TestCase ); } + /** + * @return void + */ + public function testIntersectionAfterGeneric() + { + $this->assertSame('Countable&iterable&I', (string) Type::parseString('Countable&iterable&I')); + } + /** * @return void */