Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv27945/src/bossa/syntax
Modified Files:
VarSymbol.java PolySymbol.java OverloadedSymbolExp.java
MonoSymbol.java
Log Message:
When cloning the type of a method, also clone the type symbols in the
arguments types (which can share type parameters, in case of default values
that refer to quantified type variables, like anonymous functions).
Index: VarSymbol.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** VarSymbol.java 25 Jul 2003 16:13:10 -0000 1.31
--- VarSymbol.java 25 Jul 2003 16:59:24 -0000 1.32
***************
*** 118,122 ****
// explained in OverloadedSymbolExp
! abstract void makeClonedType();
abstract void releaseClonedType();
abstract Polytype getClonedType();
--- 118,126 ----
// explained in OverloadedSymbolExp
! /** @param argTypes some types can contain unquantified occurences
! of the type parameters of this symbol, in which case they must be
! cloned too to keep the relationship.
! */
! abstract void makeClonedType(Polytype[] argTypes);
abstract void releaseClonedType();
abstract Polytype getClonedType();
Index: PolySymbol.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/PolySymbol.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** PolySymbol.java 13 Sep 2001 10:24:58 -0000 1.13
--- PolySymbol.java 25 Jul 2003 16:59:24 -0000 1.14
***************
*** 69,78 ****
private Polytype clonedType;
! final void makeClonedType()
{
if(clonedType != null)
Internal.error(this, "clonedType in use");
! clonedType = type.cloneType();
}
--- 69,88 ----
private Polytype clonedType;
! final void makeClonedType(Polytype[] argTypes)
{
if(clonedType != null)
Internal.error(this, "clonedType in use");
! java.util.Map map = type.getCloningMap();
! if (map == null)
! {
! clonedType = type;
! return;
! }
!
! clonedType = type.cloneType(map);
! if (argTypes != null)
! for (int i = 0; i < argTypes.length; i++)
! argTypes[i] = argTypes[i].applyMap(map);
}
Index: OverloadedSymbolExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/OverloadedSymbolExp.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** OverloadedSymbolExp.java 19 Jun 2003 15:32:00 -0000 1.55
--- OverloadedSymbolExp.java 25 Jul 2003 16:59:24 -0000 1.56
***************
*** 135,138 ****
--- 135,141 ----
Debug.println("Overloading: Trying with "+s);
+ Polytype[] argsType =
+ Expression.getType(arguments.getExpressions(s));
+
// we clone the type to avoid clashes with another use
// of the same symbol
***************
*** 140,146 ****
// and we check that cloneType() is not called twice
// before the clone type is released
! s.makeClonedType();
! Polytype[] argsType =
! Expression.getType(arguments.getExpressions(s));
Polytype t = CallExp.wellTyped(s.getClonedType(), argsType);
--- 143,147 ----
// and we check that cloneType() is not called twice
// before the clone type is released
! s.makeClonedType(argsType);
Polytype t = CallExp.wellTyped(s.getClonedType(), argsType);
***************
*** 201,205 ****
{
VarSymbol s = (VarSymbol) i.next();
! s.makeClonedType();
try{
Typing.leq(s.getClonedType(), expectedType);
--- 202,206 ----
{
VarSymbol s = (VarSymbol) i.next();
! s.makeClonedType(null);
try{
Typing.leq(s.getClonedType(), expectedType);
Index: MonoSymbol.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MonoSymbol.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** MonoSymbol.java 13 Mar 2003 23:19:42 -0000 1.20
--- MonoSymbol.java 25 Jul 2003 16:59:24 -0000 1.21
***************
*** 141,145 ****
// explained in OverloadedSymbolExp
! final void makeClonedType() {}
final void releaseClonedType() {}
--- 141,145 ----
// explained in OverloadedSymbolExp
! final void makeClonedType(Polytype[] argTypes) {}
final void releaseClonedType() {}
|