Nice/src/bossa/syntax niceMethod.nice,1.21,1.22

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-serv11694/src/bossa/syntax

Modified Files:
	niceMethod.nice 
Log Message:
Further refactoring for simplification.


Index: niceMethod.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** niceMethod.nice	8 Mar 2005 09:48:54 -0000	1.21
--- niceMethod.nice	8 Mar 2005 10:11:09 -0000	1.22
***************
*** 91,95 ****
        return;
  
!     mlsub.typing.Domain ourDomain = nice.tools.typing.Types.domain(this.getType());
  
      for (s : notNull(homonyms))
--- 91,95 ----
        return;
  
!     let ourDomain = nice.tools.typing.Types.domain(this.getType());
  
      for (s : notNull(homonyms))
***************
*** 105,109 ****
            continue;
  
!         mlsub.typing.Domain itsDomain = nice.tools.typing.Types.domain(s.getType());
  
          // Do we have a smaller domain?
--- 105,109 ----
            continue;
  
!         let itsDomain = nice.tools.typing.Types.domain(s.getType());
  
          // Do we have a smaller domain?
***************
*** 118,126 ****
                {
                  if (! nice.tools.typing.Types.covariantSpecialization(s.getType(), this.getType()))
!                   User.error
!                     (returnTypeLocation!=null ? returnTypeLocation : this.location(),
! "The return type should be less precise than the return type of method\n" +
! d + "\ndefined in:\n" +
!                      d.location());
  
                  // d is a specialized version of this.
--- 118,122 ----
                {
                  if (! nice.tools.typing.Types.covariantSpecialization(s.getType(), this.getType()))
! 		  this.reportReturnTypeError(shouldBeLess: true, than: d);
  
                  // d is a specialized version of this.
***************
*** 147,150 ****
--- 143,158 ----
    }
  
+   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";
+ 
+     return User.error
+       (returnTypeLocation != null ? returnTypeLocation : this.location(),
+        message + "\n" than "\ndefined in:\n" + than.location());
+   }
+ 
    /** Return true if the override of d by this is OK.
        Return false if the override should be ignored.
***************
*** 155,165 ****
    {
      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
--- 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



-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.