From a055b964589fd8f83230b097330b41f513ae4927 Mon Sep 17 00:00:00 2001 From: degory Date: Sun, 19 May 2024 10:28:34 +0200 Subject: [PATCH] IL name override fix (#1178) Bugs fixed: - Overriding the IL name of a class with `@IL.name` generates in incorrect IL --- .config/dotnet-tools.json | 2 +- Directory.Build.props | 2 +- src/semantic/dotnet/type_details.ghul | 16 ---------------- src/semantic/symbols/classy.ghul | 11 ++++++----- src/semantic/symbols/symbol.ghul | 19 +++++++++---------- src/syntax/process/declare_symbols.ghul | 2 +- 6 files changed, 18 insertions(+), 34 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 87d407cfc..72e60e974 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "ghul.compiler": { - "version": "0.8.45", + "version": "0.8.46", "commands": [ "ghul-compiler" ] diff --git a/Directory.Build.props b/Directory.Build.props index 102fca394..7318ae88c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 0.8.46-alpha.4 + 0.8.47-alpha.5 $(NoWarn);NU1507 diff --git a/src/semantic/dotnet/type_details.ghul b/src/semantic/dotnet/type_details.ghul index c75f96c06..389800431 100644 --- a/src/semantic/dotnet/type_details.ghul +++ b/src/semantic/dotnet/type_details.ghul @@ -32,22 +32,6 @@ namespace Semantic.DotNet is self.version_number = version_number; si - init( - dotnet_type: TYPE, - assembly_name: string, - version_number: string - ) is - assert dotnet_type? else "dotnet_type is null"; - - self.dotnet_type = dotnet_type; - - self.ghul_namespace = dotnet_type.`namespace; - self.ghul_type_name = dotnet_type.name; - self.il_name = dotnet_type.name; - self.assembly_name = assembly_name; - self.version_number = version_number; - si - matches(namespace_name: string, name: string) -> bool => namespace_name =~ ghul_namespace /\ name =~ ghul_type_name; diff --git a/src/semantic/symbols/classy.ghul b/src/semantic/symbols/classy.ghul index fac9604f4..d8bdb0101 100644 --- a/src/semantic/symbols/classy.ghul +++ b/src/semantic/symbols/classy.ghul @@ -396,9 +396,9 @@ namespace Semantic.Symbols is buffer.append("."); si - gen_dotted_name(buffer: System.Text.StringBuilder, qualifying: Scope) is + gen_dotted_name(buffer: System.Text.StringBuilder, qualifying: Scope) is let iln = il_name_override; - + if iln? then let parts = il_name_override.split(['[',']']); @@ -406,6 +406,10 @@ namespace Semantic.Symbols is buffer .append(parts[2]); else + if owner? /\ !iln.contains('.') then + owner.gen_dotted_name(buffer, self); + fi + buffer.append(iln); fi else @@ -1057,9 +1061,6 @@ namespace Semantic.Symbols is declare(location, `field, symbol_definition_listener); - // FIXME: this doesn't seem like it does anything - `field.il_name_override = `field.il_name_override; - `field.set_type(type); _captures.add(`field); diff --git a/src/semantic/symbols/symbol.ghul b/src/semantic/symbols/symbol.ghul index 06180ff3b..53ad296b5 100644 --- a/src/semantic/symbols/symbol.ghul +++ b/src/semantic/symbols/symbol.ghul @@ -124,16 +124,16 @@ namespace Semantic.Symbols is qualified_name: string => if owner? then - return owner.qualify(name); + owner.qualify(name); else - return name; + name; fi; il_name: string => if il_name_override? then - return il_name_override; + il_name_override; else - return "'{name}'"; + "'{name}'"; fi; il_name_override: string public; @@ -151,15 +151,14 @@ namespace Semantic.Symbols is specialized_from: Symbol public; - root_specialized_from: Symbol is - let sf = specialized_from; + root_specialized_from: Symbol => + let sf = specialized_from in if sf? then - return sf.root_specialized_from; + sf.root_specialized_from; else - return self; - fi - si + self; + fi; access: ACCESS => ACCESS.PUBLIC; diff --git a/src/syntax/process/declare_symbols.ghul b/src/syntax/process/declare_symbols.ghul index fab0ea7a9..d7e1387e7 100644 --- a/src/syntax/process/declare_symbols.ghul +++ b/src/syntax/process/declare_symbols.ghul @@ -135,7 +135,7 @@ namespace Syntax.Process is fi if is_primitive then - symbol.il_is_primitive_type = true; + symbol.il_is_primitive_type = true; fi symbol.il_name_override = il_name;