Ticket #77: passthrough-no-warn.patch
File passthrough-no-warn.patch, 1.3 KB (added by hopscc, 12 years ago) |
---|
-
Source/BinaryOpExpr.cobra
882 882 else if leftType inherits NilableType and not rightType inherits NilableType and rightType.isStrictDescendantOf(leftType.nonNil) 883 883 # ex: someNilableShape inherits Circle 884 884 pass 885 else if leftType inherits PassThroughType # rightType passThrough shd be an error 886 pass 885 887 else if leftType inherits NilableType and not rightType inherits NilableType and leftType.nonNil.isDescendantOf(rightType) 886 888 # ex: someNilableCircle inherits Shape 887 889 .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
1 class 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'