Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5461/src/bossa/syntax
Modified Files:
niceMethod.nice
Log Message:
Factored checkOverride out to simplify the logics of findSpecializedMethods.
Index: niceMethod.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** niceMethod.nice 6 Mar 2005 01:34:26 -0000 1.20
--- niceMethod.nice 8 Mar 2005 09:48:54 -0000 1.21
***************
*** 136,168 ****
// In a compiled package, we don't need checking.
! if (module.compiled())
! {
! this.addSpecializedMethod(d);
continue;
- }
-
- if (! nice.tools.typing.Types.covariantSpecialization(this.getType(), s.getType()))
- {
- User.error
- (returnTypeLocation != null ? returnTypeLocation : this.location(),
- "The return type is less precise than the original return type of method\n" +
- d + "\ndefined in:\n" +
- d.location());
- }
-
- // Check if we are a proper specialization, or if we actually have
- // the same domain.
- if (mlsub.typing.Typing.smaller(itsDomain, ourDomain))
- {
- if (module == d.module)
- User.error(this, "This method has a domain identical to " +
- d + ", which is defined at " + d.location());
- else
- // Methods with identical domains in different packages are
- // accepted, but they do not specialize each other.
- // They can be refered to unambiguously by using their
- // fully qualified name.
- continue;
- }
this.addSpecializedMethod(d);
--- 136,143 ----
// In a compiled package, we don't need checking.
! if (! module.compiled())
! if (! this.checkOverride(s, d, ourDomain, itsDomain))
! // Ignore. Errors are reported by checkOverride.
continue;
this.addSpecializedMethod(d);
***************
*** 172,175 ****
--- 147,184 ----
}
+ /** Return true if the override of d by this is OK.
+ Return false if the override should be ignored.
+ */
+ private boolean checkOverride
+ (VarSymbol s, MethodDeclaration d,
+ mlsub.typing.Domain ourDomain, mlsub.typing.Domain itsDomain)
+ {
+ if (! nice.tools.typing.Types.covariantSpecialization(this.getType(), s.getType()))
+ {
+ User.error
+ (returnTypeLocation != null ? returnTypeLocation : this.location(),
+ "The return type is less precise than the original return type of method\n" +
+ d + "\ndefined in:\n" +
+ d.location());
+ }
+
+ // Check if we are a proper specialization, or if we actually have
+ // the same domain.
+ if (mlsub.typing.Typing.smaller(itsDomain, ourDomain))
+ {
+ if (module == d.module)
+ User.error(this, "This method has a domain identical to " +
+ d + ", which is defined at " + d.location());
+ else
+ // Methods with identical domains in different packages are
+ // accepted, but they do not specialize each other.
+ // They can be refered to unambiguously by using their
+ // fully qualified name.
+ return false;
+ }
+
+ return true;
+ }
+
private void addSpecializedMethod(MethodDeclaration method)
{
|