Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12386/src/bossa/syntax
Modified Files:
NiceClass.java
Log Message:
Fixed field type override checking when there is a value override higher up
in the hierarchy.
Index: NiceClass.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -d -r1.90 -r1.91
*** NiceClass.java 15 Oct 2004 11:39:17 -0000 1.90
--- NiceClass.java 15 Oct 2004 12:56:21 -0000 1.91
***************
*** 409,420 ****
if (checkValue && original.value != null)
{
! try {
! Typing.leq(original.value.getType(), this.sym.getType());
! }
! catch (mlsub.typing.TypingEx ex) {
! User.error(sym, "The default value declared in " +
! original.getDeclaringClass() +
! "\nis not compatible with the overriden type");
! }
return false;
}
--- 409,413 ----
if (checkValue && original.value != null)
{
! checkValue(original.value, original.getDeclaringClass());
return false;
}
***************
*** 423,426 ****
--- 416,436 ----
}
+ void checkOverride(ValueOverride original)
+ {
+ checkValue(original.value, original.getDeclaringClass());
+ }
+
+ private void checkValue(Expression value, NiceClass location)
+ {
+ try {
+ Typing.leq(value.getType(), this.sym.getType());
+ }
+ catch (mlsub.typing.TypingEx ex) {
+ User.error(sym, "The default value declared in " +
+ location +
+ "\nis not compatible with the overriden type");
+ }
+ }
+
public String toString()
{
***************
*** 437,440 ****
--- 447,460 ----
}
+ NiceClass getDeclaringClass()
+ {
+ return NiceClass.this;
+ }
+
+ boolean hasName(String name)
+ {
+ return this.name.toString().equals(name);
+ }
+
void updateConstructorParameter(List inherited)
{
***************
*** 497,501 ****
for (Iterator it = valueOverrides.iterator(); it.hasNext(); )
((ValueOverride)it.next()).resolve(definition.scope, localScope);
-
}
--- 517,520 ----
***************
*** 527,530 ****
--- 546,561 ----
checkValue = field.checkOverride(overrides[i], checkValue);
+ if (checkValue)
+ for (Iterator it = valueOverrides.iterator(); it.hasNext(); )
+ {
+ ValueOverride original = (ValueOverride) it.next();
+ if (original.hasName(name))
+ {
+ field.checkOverride(original);
+ checkValue = false;
+ break;
+ }
+ }
+
NiceClass parent = getParent();
if (parent != null)
|