This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: duplicate definition


Chris Dean wrote:

Consider three modules A, B, and C.  B has a macro that uses a
function in A and C requires both A and B.  When I compile C, I get a
duplicate definition warning.

How do I not get the warning?

This is a bug. The problem is we can't make func-a private in <B>, because the exported macro macro-b references it. Instead, we give it a prublic field with the magic $Prvt$ prefix. The bug is that the code in require does not check for this.

Attached is a temporary patch that fixes this problem.  It's
temporary, because it's in the middle of stuff I'm working on.
Perhaps you could write the testcase in a form where it can be
added to the testsuite?
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/
Index: kawa/standard/require.java
===================================================================
RCS file: /cvs/kawa/kawa/kawa/standard/require.java,v
retrieving revision 1.31
diff -u -r1.31 require.java
--- kawa/standard/require.java	3 Mar 2004 22:44:15 -0000	1.31
+++ kawa/standard/require.java	15 Oct 2004 18:44:39 -0000
@@ -245,12 +245,15 @@
 		    // But if the binding is re-exported (or EXTERNAL_ACCESS
 		    // gets set), then we need a separate declaration.
 		    // (If EXTERNAL_ACCESS, the field gets PRIVATE_PREFIX.)
+		    boolean hidden
+		      = fname.startsWith(Declaration.PRIVATE_PREFIX);
 		    Object aname;
 		    if (uri == null)
 		      aname = fdname;
 		    else
 		      aname = Symbol.make(uri, fdname);
-		    Declaration adecl = defs.getDefine(aname, 'w', tr);
+		    Declaration adecl = hidden ? new Declaration(aname)
+		      : defs.getDefine(aname, 'w', tr);
 		    Declaration fdecl = new Declaration(fdname, dtype);
 		    ReferenceExp fref = new ReferenceExp(fdecl);
 		    SetExp sexp = new SetExp(adecl, fref);
@@ -299,7 +302,8 @@
 		    fdecl.setSimple(false);
 		    adecl.setFlag(Declaration.IS_IMPORTED);
 		    adecl.setSimple(false);
-		    tr.push(adecl);  // Add to translation env.
+		    if (! hidden)
+		      tr.push(adecl);  // Add to translation env.
 		    forms.addElement(sexp);
 		  }
 		catch (Exception ex)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]