diff --git a/langkit/dsl_unparse.py b/langkit/dsl_unparse.py index 07ee06c23..bcaf286f7 100644 --- a/langkit/dsl_unparse.py +++ b/langkit/dsl_unparse.py @@ -502,8 +502,16 @@ def type_name(type): from langkit.compiled_types import ASTNodeType, resolve_type type = resolve_type(type) + + def bases(typ): + t = typ.base + while t is not None: + yield t + t = t.base + if isinstance(type, ASTNodeType): - if type.is_list_type: + if (type.is_list_type + and not any(t.is_generic_list_type for t in bases(type.base))): return "ASTList[{}]".format(type_name(type.element_type)) else: return type.raw_name.camel diff --git a/testsuite/tests/contrib/lkt_parse_1/test.py b/testsuite/tests/contrib/lkt_parse_1/test.py index 7369f8beb..96ffbb055 100644 --- a/testsuite/tests/contrib/lkt_parse_1/test.py +++ b/testsuite/tests/contrib/lkt_parse_1/test.py @@ -32,7 +32,7 @@ tests = sorted(((P.join(root, f), P.basename(root)) # parse them all. test_whitelist = [ 'dflt_arg_val', 'rewriting', 'ghost_nodes', 'import_argcount', - 'symbol_type', 'unicode_buffer', + 'symbol_type', 'unicode_buffer', ] whitelisted_tests = [t for t in tests if t[1] in test_whitelist] diff --git a/testsuite/tests/lexical_envs/env_get_all/expected_concrete_syntax.lkt b/testsuite/tests/lexical_envs/env_get_all/expected_concrete_syntax.lkt index 015e60eb7..a63ab05a3 100644 --- a/testsuite/tests/lexical_envs/env_get_all/expected_concrete_syntax.lkt +++ b/testsuite/tests/lexical_envs/env_get_all/expected_concrete_syntax.lkt @@ -15,7 +15,7 @@ class FooNode { fun unique_id (s : SymbolType): FooNode = self.unit.root.make_id(s) } -class ASTList[Insert] : ASTList[Insert] { +class Program : ASTList[Insert] { } class Id : FooNode { diff --git a/testsuite/tests/ocaml_api/general/expected_concrete_syntax.lkt b/testsuite/tests/ocaml_api/general/expected_concrete_syntax.lkt index 73703b1a2..0e5d287a5 100644 --- a/testsuite/tests/ocaml_api/general/expected_concrete_syntax.lkt +++ b/testsuite/tests/ocaml_api/general/expected_concrete_syntax.lkt @@ -44,7 +44,7 @@ class Example : FooNode { ## * ${node_name(T.Null)} ## * ${node_name(T.StringLiteral)} ## * ${node_name(T.Var)} -class ASTList[FooNode] : ASTList[FooNode] { +class Sequence : ASTList[FooNode] { @export fun all_items (): Array[Entity[FooNode]] = entity.map((i) => i) @@ -65,5 +65,5 @@ class StringLiteral : FooNode { } class Var : FooNode { - @parse_field arg : ASTList[FooNode] + @parse_field arg : Sequence } diff --git a/testsuite/tests/properties/is_visible_from/expected_concrete_syntax.lkt b/testsuite/tests/properties/is_visible_from/expected_concrete_syntax.lkt index 609054193..6a45145cf 100644 --- a/testsuite/tests/properties/is_visible_from/expected_concrete_syntax.lkt +++ b/testsuite/tests/properties/is_visible_from/expected_concrete_syntax.lkt @@ -14,7 +14,7 @@ class FooNode { } } -class ASTList[Name] : ASTList[Name] { +class Scope : ASTList[Name] { } class Name : FooNode { diff --git a/testsuite/tests/properties/rebindings/expected_concrete_syntax.lkt b/testsuite/tests/properties/rebindings/expected_concrete_syntax.lkt index 08fafc41f..8803cb4a8 100644 --- a/testsuite/tests/properties/rebindings/expected_concrete_syntax.lkt +++ b/testsuite/tests/properties/rebindings/expected_concrete_syntax.lkt @@ -18,7 +18,7 @@ class DefNode : FooNode { } class Block : DefNode { - @parse_field params : ASTList[Param] + @parse_field params : Params @parse_field name_field : Name @parse_field vars : ASTList[BlockVar] @@ -63,7 +63,7 @@ class Param : DefNode { fun name (): SymbolType = self.name_field.symbol } -class ASTList[Param] : ASTList[Param] { +class Params : ASTList[Param] { } class Name : FooNode { diff --git a/testsuite/tests/properties/then_analysis_unit/expected_concrete_syntax.lkt b/testsuite/tests/properties/then_analysis_unit/expected_concrete_syntax.lkt index a5a44ddbe..ef9df152e 100644 --- a/testsuite/tests/properties/then_analysis_unit/expected_concrete_syntax.lkt +++ b/testsuite/tests/properties/then_analysis_unit/expected_concrete_syntax.lkt @@ -9,7 +9,7 @@ class FooNode { @export fun node_unit (): InternalUnit = (self.to[Name]) then (n => n.unit) } -class ASTList[Name] : ASTList[Name] { +class Scope : ASTList[Name] { } class Name : FooNode { diff --git a/testsuite/tests/python_api/array_types/expected_concrete_syntax.lkt b/testsuite/tests/python_api/array_types/expected_concrete_syntax.lkt index b57143f00..cf0d1bc5d 100644 --- a/testsuite/tests/python_api/array_types/expected_concrete_syntax.lkt +++ b/testsuite/tests/python_api/array_types/expected_concrete_syntax.lkt @@ -18,7 +18,7 @@ class Example : FooNode { ## ## * ${node_name(T.Example)} ## * ${node_name(T.NullNode)} -class ASTList[FooNode] : ASTList[FooNode] { +class Sequence : ASTList[FooNode] { @export fun all_items (): Array[Entity[FooNode]] = entity.map((i) => i) diff --git a/testsuite/tests/python_api/entity_eq/expected_concrete_syntax.lkt b/testsuite/tests/python_api/entity_eq/expected_concrete_syntax.lkt index 9d521f55b..036b82654 100644 --- a/testsuite/tests/python_api/entity_eq/expected_concrete_syntax.lkt +++ b/testsuite/tests/python_api/entity_eq/expected_concrete_syntax.lkt @@ -18,7 +18,7 @@ class DefNode : FooNode { } class Block : DefNode { - @parse_field params : ASTList[Param] + @parse_field params : Params @parse_field name_field : Name @parse_field vars : ASTList[BlockVar] @@ -49,7 +49,7 @@ class Param : DefNode { fun name (): SymbolType = self.name_field.symbol } -class ASTList[Param] : ASTList[Param] { +class Params : ASTList[Param] { } class Name : FooNode { diff --git a/testsuite/tests/python_api/tokens/expected_concrete_syntax.lkt b/testsuite/tests/python_api/tokens/expected_concrete_syntax.lkt index 18e8b0273..7e04aa6ef 100644 --- a/testsuite/tests/python_api/tokens/expected_concrete_syntax.lkt +++ b/testsuite/tests/python_api/tokens/expected_concrete_syntax.lkt @@ -12,5 +12,5 @@ class FooNode { class Atom : FooNode { } -class ASTList[FooNode] : ASTList[FooNode] { +class Sequence : ASTList[FooNode] { }