class Foo def main is shared a = TypeA() b = a to? TypeA # .warning. The given expression is already a "TypeA" so the typecast is redundant. You can remove it c = a to ? d = c to? TypeA # .warning. The given expression is already a "TypeA", but nilable. You can use "to !" to remove the nilability or remove the redundant cast. ok = a to? TypeA? e = c to? TypeA? # .warning. The given expression is already a "TypeA?" so the typecast is redundant. You can remove it. CobraCore.noOp(a, b, c, d, ok, e) s as String? = 'aoeu' t = s to? String # .warning. The given expression is already a "String", but nilable. ba = B() to? A # no warning here because casting to a more general type is a legit way to affect type inference CobraCore.noOp(ba) u = 'aoeu' to? String? t = u to? String # .warning. The given expression is already a "String", but nilable. You can use "to !" to remove the nilability or remove the redundant cast. assert t u2 = u to? String? # .warning. The given expression is already a "String?" so the typecast is redundant. You can remove it. assert u2 # just to use the variable to avoid a warning class A pass class B inherits A pass class TypeA pass