     return object.object(forKey: key)
   }
 
-  @usableFromInline
-  internal func lookup(_ i: Index) -> (key: Key, value: Value) {
-    let key: Key = i.allKeys[i.currentKeyIndex]
-    let value: Value = i.base.object.object(forKey: key)!
+  @inlinable
+  @inline(__always)
+  internal func lookup(_ index: Index) -> (key: Key, value: Value) {
+    _precondition(index.base.object === self.object, "Invalid index")
+    let key: Key = index.allKeys[index.currentKeyIndex]
+    let value: Value = index.base.object.object(forKey: key)!
     return (key, value)
+  }
+
+  @inlinable
+  @inline(__always)
+  func key(at index: Index) -> Key {
+    _precondition(index.base.object === self.object, "Invalid index")
+    return index.allKeys[index.currentKeyIndex]
+  }
+
+  @inlinable
+  @inline(__always)
+  func value(at index: Index) -> Value {
+    _precondition(index.base.object === self.object, "Invalid index")
+    let key = index.allKeys[index.currentKeyIndex]
+    return index.base.object.object(forKey: key)!
   }
 }
 

  }
}

extension _CocoaDictionary {
  @usableFromInline
  @_effects(releasenone)
  internal func key(for index: Index) -> AnyObject {
    return index.allKeys[index.currentKeyIndex]
  }
}

extension _CocoaDictionary: Equatable {
  @usableFromInline
  internal static func ==(

      cocoaPath()
      // We have to migrate the data first.  But after we do so, the Cocoa
      // index becomes useless, so get the key first.
      let cocoaKey = cocoa.key(at: index._asCocoa)
      let native = _NativeDictionary<Key, Value>(cocoa)
      self = .native(native)
      let nativeKey = _forceBridgeFromObjectiveC(cocoaKey, Key.self)
