The type inference engine does not know the Ints bit width. He does not even know that Ints are numbers. The engine knows nothing about the "limitation" or "narrowness" of how types are implemented. He just knows how types relate to each other as supertypes and subtypes ("ISA" relationships), and tries to solve the constraint problems by figuring out what he can connect to the type variables you provided.
, +. + Int . :
public func +(lhs: Int8, rhs: Int8) -> Int8
Int8 . , , :
public func +<T : Strideable>(lhs: T, rhs: T.Stride) -> T
? An Int8 SignedInteger. SignedInteger Strideable :
public protocol Strideable : Comparable {
associatedtype Stride : SignedNumber
public func distance(to other: Self) -> Self.Stride
public func advanced(by n: Self.Stride) -> Self
}
extension SignedInteger {
public func distance(to other: Self) -> Int
public func advanced(by n: Int) -> Self
}
- , Stride Int. , :
public func +(lhs: Int8, rhs: Int) -> Int8
, , .
BTW, , Swift , - - +. , .