Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3596/src/bossa/syntax
Modified Files:
typedef.nice NiceMethod.java Monotype.java
Log Message:
Fix methods declared inside classes with less type parameters than their
parents (fixes bug #1084559).
Index: typedef.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** typedef.nice 8 Dec 2004 23:03:37 -0000 1.4
--- typedef.nice 17 Dec 2004 20:45:08 -0000 1.5
***************
*** 719,728 ****
if (def == null)
return null;
!
let params = def.parentParams;
!
if (params == null)
return null;
!
// Look for missing type parameters
int missing = 0;
--- 719,728 ----
if (def == null)
return null;
!
let params = def.parentParams;
!
if (params == null)
return null;
!
// Look for missing type parameters
int missing = 0;
***************
*** 742,746 ****
requires exactly these type parameters because it specializes its parent.
*/
! ?mlsub.typing.Monotype getTypeWithTC( TypeConstructor tc,
mlsub.typing.Monotype[] sourceParams )
{
?CTypeDefinition def = cast(getTypeDefinition(tc));
--- 742,746 ----
requires exactly these type parameters because it specializes its parent.
*/
! ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc,
mlsub.typing.Monotype[] sourceParams )
{
?CTypeDefinition def = cast(getTypeDefinition(tc));
***************
*** 767,771 ****
fullParams[i] = params[i];
! if (used < sourceParams.length)
return null;
--- 767,771 ----
fullParams[i] = params[i];
! if (sourceParams != null && used < sourceParams.length)
return null;
Index: Monotype.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Monotype.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** Monotype.java 1 Dec 2004 02:00:31 -0000 1.37
--- Monotype.java 17 Dec 2004 20:45:10 -0000 1.38
***************
*** 17,20 ****
--- 17,21 ----
import mlsub.typing.MonotypeVar;
+ import mlsub.typing.TypeConstructor;
import nice.tools.typing.PrimitiveType;
***************
*** 279,282 ****
--- 280,325 ----
/****************************************************************
+ * Wrapper for delaying resolution of constructed monotypes.
+ ****************************************************************/
+
+ static Monotype createSure(final TypeConstructor tc, final
mlsub.typing.Monotype[] params)
+ {
+ return new Monotype() {
+ boolean containsAlike() { return false; }
+
+ public mlsub.typing.Monotype rawResolve(TypeMap typeMap)
+ {
+ try{
+ return sure(new mlsub.typing.MonotypeConstructor(tc, params));
+ }
+ catch(mlsub.typing.BadSizeEx e){
+ // See if this is a class with default type parameters
+ mlsub.typing.Monotype res = dispatch.getTypeWithTC(tc, params);
+ if (res != null)
+ return sure(res);
+
+ throw User.error(this, "Class " + tc +
+ Util.has(e.expected, "type parameter",
e.actual));
+ }
+ }
+
+ Monotype substitute(Map m)
+ {
+ return this;
+ }
+
+ public Location location()
+ {
+ return Location.nowhere();
+ }
+
+ public String toString()
+ {
+ return tc + ( params != null ? Util.map("<",",",">",params) : "");
+ }
+ };
+ }
+
+ /****************************************************************
* Nullness markers
****************************************************************/
Index: NiceMethod.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceMethod.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** NiceMethod.java 16 Dec 2004 20:18:46 -0000 1.44
--- NiceMethod.java 17 Dec 2004 20:45:10 -0000 1.45
***************
*** 89,93 ****
constraint.addAtoms(thisConstraint.getAtoms());
! mlsub.typing.Monotype thisType;
// "alike" is not created for a non-abstract interface
--- 89,93 ----
constraint.addAtoms(thisConstraint.getAtoms());
! Monotype thisType;
// "alike" is not created for a non-abstract interface
***************
*** 109,115 ****
atom = new mlsub.typing.TypeConstructorLeqCst(alikeTC, tc);
constraint.addAtom(AtomicConstraint.create(atom));
!
! thisType = new mlsub.typing.MonotypeConstructor(alikeTC,
c.getTypeParameters());
!
if (hasAlike)
{
--- 109,118 ----
atom = new mlsub.typing.TypeConstructorLeqCst(alikeTC, tc);
constraint.addAtom(AtomicConstraint.create(atom));
!
! thisType = Monotype.create
! (Monotype.sure
! (new mlsub.typing.MonotypeConstructor
! (alikeTC, c.getTypeParameters())));
!
if (hasAlike)
{
***************
*** 121,131 ****
}
else
! thisType =
! new mlsub.typing.MonotypeConstructor(tc, c.getTypeParameters());
!
! params.addThis(Monotype.create(Monotype.sure(thisType)));
!
if (body == null)
! return new NiceMethod(name, constraint, returnType, params, contract,
isOverride);
else
--- 124,134 ----
}
else
! thisType =
! Monotype.createSure(tc, c.getTypeParameters());
!
! params.addThis(thisType);
!
if (body == null)
! return new NiceMethod(name, constraint, returnType, params, contract,
isOverride);
else
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
|