array.RemoveLast & BidirectionalCollection, RangeReplacableCollection and interpreting swift.swiftinterface

From the Array struct inside Swift.SwiftInterface, I'm trying to find out why Swift passes the witness table for RangeReplacableCollection.

extension BidirectionalCollection where Self == Self.SubSequence {
  @inlinable mutating public func removeLast() -> Element {
    let element = last!
    self = self[startIndex..<index(before: endIndex)]
    return element

From left to right it passes, the resut pointer, the type of the array, the witness table for BidirectionalCollection, the witness table for RangeReplaceableCollection and the Array itself.

I understand the "why" for most of these. However, how does the compiler decide RangeReplaceableCollection becomes part of this?

The only reasoning I can come up with is that somehow, the body of the method influences what witness tables are passed, but that can't be true right?

Terms of Service

Privacy Policy

Cookie Policy