[m-rev.] diff: fix C# class name same as enclosing class

Peter Wang novalazy at gmail.com
Mon Nov 29 11:24:54 AEDT 2010

Branches: main

In the C# backend, mangle the class name corresponding to a du type
constructor if it would be the same as the enclosing class.

        As above.

diff --git a/compiler/ml_type_gen.m b/compiler/ml_type_gen.m
index d6c90be..e2c9b87 100644
--- a/compiler/ml_type_gen.m
+++ b/compiler/ml_type_gen.m
@@ -1115,11 +1115,13 @@ ml_gen_du_ctor_name_unqual_type(CompilationTarget, UnqualTypeName, TypeArity,
         Name, Arity) = CtorName :-
     UnqualName = unqualify_name(Name),
-        CompilationTarget = target_java,
+        ( CompilationTarget = target_java
+        ; CompilationTarget = target_csharp
+        ),
         UnqualName = UnqualTypeName,
         Arity = TypeArity
-        % In Java we must not generate a class with the same name as its
+        % In Java and C# we must not generate a class with the same name as its
         % enclosing class.  We add the prefix to avoid that situation arising.
         % (A user may name another functor of the same type with "mr_" to
         % trigger the problem.)

mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au

More information about the reviews mailing list