Nice/src/bossa/syntax niceMethod.nice,1.22,1.23
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-serv23136/src/bossa/syntax
Modified Files:
niceMethod.nice
Log Message:
Factored out the specialization predicates. Finally under one pagefull.
Hopefully the logics is clear now.
Index: niceMethod.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** niceMethod.nice 8 Mar 2005 10:11:09 -0000 1.22
--- niceMethod.nice 8 Mar 2005 10:50:59 -0000 1.23
***************
*** 107,150 ****
let itsDomain = nice.tools.typing.Types.domain(s.getType());
! // Do we have a smaller domain?
! if (! (mlsub.typing.Typing.smaller(ourDomain, itsDomain, true))
! || nice.tools.typing.Types.typeParameterDispatch(this.getType(), s.getType()))
{
! // If the method is imported,
! // check if the reverse relation holds with that method
! if (d.module != null && d.module.compiled() &&
! mlsub.typing.Typing.smaller(itsDomain, ourDomain, true) &&
! ! nice.tools.typing.Types.typeParameterDispatch(s.getType(), this.getType()))
! {
! if (! nice.tools.typing.Types.covariantSpecialization(s.getType(), this.getType()))
! this.reportReturnTypeError(shouldBeLess: true, than: d);
! // d is a specialized version of this.
! if (d instanceof NiceMethod)
! d.addSpecializedMethod(this);
! // Therefore, all its implementations also belong to this.
! addAllAlternatives(d, this);
! }
! continue;
! }
! // 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);
! }
! homonyms = null;
}
private UserError reportReturnTypeError
! (boolean shouldBeLess, MethodDeclaration than)
{
! let message = shouldBeLess ?
"This return type should be less precise than the return type of method" :
"This return type is less precise than the original return type of method";
--- 107,163 ----
let itsDomain = nice.tools.typing.Types.domain(s.getType());
! if (this.specializes(s, ourDomain, itsDomain))
! {
! // 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);
! }
! else if (this.isSpecializedBy(d, s, ourDomain, itsDomain))
{
! if (! nice.tools.typing.Types.covariantSpecialization(s.getType(), this.getType()))
! this.reportReturnTypeError(shouldBeLessPrecise: true, than: d);
! // d is a specialized version of this.
! if (d instanceof NiceMethod)
! d.addSpecializedMethod(this);
! // Therefore, all its implementations also belong to this.
! addAllAlternatives(d, this);
! }
! }
! homonyms = null;
! }
! private boolean specializes
! (VarSymbol s,
! mlsub.typing.Domain ourDomain, mlsub.typing.Domain itsDomain)
! =
! mlsub.typing.Typing.smaller(ourDomain, itsDomain, true)
! && ! nice.tools.typing.Types.typeParameterDispatch(this.getType(), s.getType());
! private boolean isSpecializedBy
! (MethodDeclaration d, VarSymbol s,
! mlsub.typing.Domain ourDomain, mlsub.typing.Domain itsDomain)
! {
! // Only consider imported methods.
! // Methods being compiled will be found in the direct way
! // if they override this method.
! if (d.module == null || ! d.module.compiled())
! return false;
! return
! mlsub.typing.Typing.smaller(itsDomain, ourDomain, true) &&
! ! nice.tools.typing.Types.typeParameterDispatch(s.getType(), this.getType());
}
private UserError reportReturnTypeError
! (boolean shouldBeLessPrecise, MethodDeclaration than)
{
! let message = shouldBeLessPrecise ?
"This return type should be less precise than the return type of method" :
"This return type is less precise than the original return type of method";
***************
*** 163,167 ****
{
if (! nice.tools.typing.Types.covariantSpecialization(this.getType(), s.getType()))
! this.reportReturnTypeError(shouldBeLess: false, than: d);
// Check if we are a proper specialization, or if we actually have
--- 176,180 ----
{
if (! nice.tools.typing.Types.covariantSpecialization(this.getType(), s.getType()))
! this.reportReturnTypeError(shouldBeLessPrecise: false, than: d);
// Check if we are a proper specialization, or if we actually have
-------------------------------------------------------
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