Wiki

Ticket #77: passthrough-no-warn.patch

File passthrough-no-warn.patch, 1.3 KB (added by hopscc, 12 years ago)
  • Source/BinaryOpExpr.cobra

     
    882882                    else if leftType inherits NilableType and not rightType inherits NilableType and rightType.isStrictDescendantOf(leftType.nonNil) 
    883883                        # ex: someNilableShape inherits Circle 
    884884                        pass 
     885                    else if leftType inherits PassThroughType # rightType passThrough shd be an error 
     886                        pass 
    885887                    else if leftType inherits NilableType and not rightType inherits NilableType and leftType.nonNil.isDescendantOf(rightType) 
    886888                        # ex: someNilableCircle inherits Shape 
    887889                        .compiler.warning(this, 'The expression will always be of type "[.right.toCobraSource]" when not nil. You can just check for not nil by removing "inherits [.right.toCobraSource]".') 
  • Tests/800-warnings/510-passthrough-no-warning.cobra

     
     1class A 
     2 
     3    def main is shared 
     4        #x as int = 1 to passthrough 
     5        x as passthrough = A()  
     6        s = 'notA' 
     7        if x inherits A 
     8            #print 'A' 
     9            s = 'A' 
     10        assert s == 'A'