Nice/src/bossa/syntax typedef.nice,1.18,1.19 monotype.nice,1.11,1.12 TypeScope.java,1.41,1.42
Daniel Bonniot <[email protected]>
| Newsgroups | gmane.comp.lang.nice.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5448/src/bossa/syntax
Modified Files:
typedef.nice monotype.nice TypeScope.java
Log Message:
Fix classes whose parent has less type parameters that the grand-parent,
by creating a new TypeConstructor when this is discovered (fixes #1097571).
Index: typedef.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** typedef.nice 16 Feb 2005 12:13:17 -0000 1.18
--- typedef.nice 16 Feb 2005 22:35:06 -0000 1.19
***************
*** 38,47 ****
?mlsub.typing.Monotype[?] parentParams = null;
int[?] parentTypeParameterMap = null;
!
{
modifiers.makePublic();
!
int arity = getVariance(this);
!
let tpv = notNull( typeParametersVariances );
--- 38,51 ----
?mlsub.typing.Monotype[?] parentParams = null;
int[?] parentTypeParameterMap = null;
!
{
modifiers.makePublic();
! this.computeVariance();
! }
!
! void computeVariance()
! {
int arity = getVariance(this);
!
let tpv = notNull( typeParametersVariances );
***************
*** 50,57 ****
else
this.variance = mlsub.typing.Variance.make(new int[arity]);
!
this.createTC();
typeParametersVariances = null;
!
if( modifiers.isFinal() )
tc.setMinimal();
--- 54,61 ----
else
this.variance = mlsub.typing.Variance.make(new int[arity]);
!
this.createTC();
typeParametersVariances = null;
!
if( modifiers.isFinal() )
tc.setMinimal();
***************
*** 59,63 ****
boolean isConcrete() = !modifiers.isAbstract();
!
boolean implementsJavaInterface(String name)
{
--- 63,67 ----
boolean isConcrete() = !modifiers.isAbstract();
!
boolean implementsJavaInterface(String name)
{
***************
*** 235,238 ****
--- 239,244 ----
}
+ this.recomputeVariance();
+
this.createContext();
}
***************
*** 521,528 ****
{
?mlsub.typing.Interface associatedInterface = null;
!
{
! modifiers.makeInterface();
! associatedInterface = new mlsub.typing.Interface(variance, tc);
}
--- 527,533 ----
{
?mlsub.typing.Interface associatedInterface = null;
!
{
! modifiers.makeInterface();
}
***************
*** 533,537 ****
getTypeSymbol() =
notNull( associatedInterface );
!
resolveClass()
{
--- 538,548 ----
getTypeSymbol() =
notNull( associatedInterface );
!
! computeVariance()
! {
! super;
! associatedInterface = new mlsub.typing.Interface(variance, tc);
! }
!
resolveClass()
{
***************
*** 747,751 ****
if (missing == 0)
! return new mlsub.typing.MonotypeConstructor(tc, cast(params) );
return null;
--- 758,762 ----
if (missing == 0)
! return new mlsub.typing.MonotypeConstructor(def.tc, cast(params) );
return null;
***************
*** 800,804 ****
return null;
! return new mlsub.typing.MonotypeConstructor(tc, cast(fullParams));
}
--- 811,815 ----
return null;
! return new mlsub.typing.MonotypeConstructor(def.tc, cast(fullParams));
}
***************
*** 861,864 ****
--- 872,917 ----
}
+ // Variance lookup after resolution
+
+ void recomputeVariance(TypeDefinition this)
+ {
+ for (itf : interfaces)
+ {
+ let itfDef = getTypeDefinition(itf.associatedTC());
+ if (itfDef != null)
+ {
+ this.copyVariance(itfDef);
+ return;
+ }
+ }
+ }
+
+ recomputeVariance(ClassDefinition this)
+ {
+ let superClass = this.getSuperClassDefinition();
+ if (superClass != null)
+ this.copyVariance(superClass);
+ else
+ super;
+ }
+
+ private void copyVariance(TypeDefinition this, TypeDefinition from)
+ {
+ if (this.variance != from.variance)
+ {
+ this.variance = from.variance;
+ tc.discard();
+ let constructors = getConstructors(tc);
+ this.createTC();
+ if (constructors != null)
+ for (c : constructors)
+ addConstructor(tc, c.getMethodDeclaration());
+ Node.getGlobalTypeScope().updateMapping(tc.toString(), tc);
+ classConstraint = from.classConstraint;
+ parentParams = from.parentParams;
+ parentTypeParameterMap = from.parentTypeParameterMap;
+ }
+ }
+
// Constructors
ClassDefinition makeClass(LocatedString name,
Index: monotype.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/monotype.nice,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** monotype.nice 16 Jan 2005 00:28:21 -0000 1.11
--- monotype.nice 16 Feb 2005 22:35:06 -0000 1.12
***************
*** 141,153 ****
rawResolve(tm)
{
try{
return sureMonotype(new mlsub.typing.MonotypeConstructor(tc, params));
}
catch(mlsub.typing.BadSizeEx e){
- // See if this is a class with default type parameters
- let res = getTypeWithTC(tc, params);
- if (res != null)
- return sureMonotype(res);
-
throw User.error(this, "Class " + tc + Util.has(e.expected, "type parameter", e.actual));
}
--- 141,153 ----
rawResolve(tm)
{
+ // See if this is a class with default type parameters
+ let res = getTypeWithTC(tc, params);
+ if (res != null)
+ return sureMonotype(res);
+
try{
return sureMonotype(new mlsub.typing.MonotypeConstructor(tc, params));
}
catch(mlsub.typing.BadSizeEx e){
throw User.error(this, "Class " + tc + Util.has(e.expected, "type parameter", e.actual));
}
Index: TypeScope.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeScope.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** TypeScope.java 20 Dec 2004 20:25:53 -0000 1.41
--- TypeScope.java 16 Feb 2005 22:35:06 -0000 1.42
***************
*** 74,77 ****
--- 74,83 ----
}
+ /** Change a previous mapping. */
+ void updateMapping(String name, TypeSymbol s)
+ {
+ map.put(name, s);
+ }
+
void addMappings(Collection names, TypeSymbol[] symbols)
throws DuplicateName
-------------------------------------------------------
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://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click