Update of /cvsroot/nice/Nice/src/mlsub/typing
In directory sc8-pr-cvs1:/tmp/cvs-serv27945/src/mlsub/typing
Modified Files:
Polytype.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: Polytype.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Polytype.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Polytype.java 24 Jul 2003 15:05:54 -0000 1.17
--- Polytype.java 25 Jul 2003 16:59:23 -0000 1.18
***************
*** 19,22 ****
--- 19,23 ----
import mlsub.typing.lowlevel.Engine;
import java.util.ArrayList;
+ import java.util.Map;
/**
***************
*** 48,56 ****
public Polytype cloneType()
{
//Optimization
if (isMonomorphic())
! return this;
! java.util.Map map = new java.util.HashMap();
TypeSymbol[] binders = constraint.binders();
TypeSymbol[] newBinders = new TypeSymbol[binders.length];
--- 49,70 ----
public Polytype cloneType()
{
+ Map map = getCloningMap();
+ if (map == null)
+ return this;
+ else
+ return cloneType(map);
+ }
+
+ public Map getCloningMap()
+ {
//Optimization
if (isMonomorphic())
! return null;
! return new java.util.HashMap();
! }
!
! public Polytype cloneType(Map map)
! {
TypeSymbol[] binders = constraint.binders();
TypeSymbol[] newBinders = new TypeSymbol[binders.length];
***************
*** 67,71 ****
monotype.substitute(map));
}
!
public Constraint getConstraint()
{
--- 81,94 ----
monotype.substitute(map));
}
!
! public Polytype applyMap(Map map)
! {
! return new Polytype
! (isMonomorphic() ? Constraint.True
! : new Constraint(constraint.binders(),
! AtomicConstraint.substitute(map, constraint.atoms())),
! monotype.substitute(map));
! }
!
public Constraint getConstraint()
{
***************
*** 113,117 ****
{
// Optimization
! if (isMonomorphic())
return;
--- 136,140 ----
{
// Optimization
! if(!Constraint.hasBinders(constraint))
return;
***************
*** 257,261 ****
public void simplify()
{
! if (isMonomorphic() || simplified || Polytype.noSimplify)
return;
--- 280,284 ----
public void simplify()
{
! if (!Constraint.hasBinders(constraint) || simplified || Polytype.noSimplify)
return;
|