From 53b2c7dac65a45fe59ca98cd01960bcbc8b441dd Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Tue, 30 Apr 2019 11:53:09 +0200 Subject: [PATCH] TypeSet: fix handling of abstract classes with no concrete subclasses TN: S311-015 --- langkit/utils/types.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/langkit/utils/types.py b/langkit/utils/types.py index 2bb2065b9..a91a1ed28 100644 --- a/langkit/utils/types.py +++ b/langkit/utils/types.py @@ -156,13 +156,22 @@ class TypeSet(object): for parent in reversed(parents): if not parent.abstract or parent in self.matched_types: break - subclasses = set(parent.subclasses) + + subclasses = set(parent.concrete_subclasses) if not subclasses.issubset(self.matched_types): break - # If we reach this point, all parent's subclasses are matched, - # so we can state that parent itself is always matched. + + # If we reach this point, all parent's concrete subclasses are + # matched, so we can state that parent itself is always matched. self.matched_types.add(parent) + # Also include subclasses: we may add abstract subclasses which + # have no concrete subclasses themselves. Typically: the generic + # list type (which is abstract) while there is no list in the + # grammar. + for s in parent.subclasses: + self.include(s) + return False def exclude(self, t):