     return otherwise()
   }
 
-  @inlinable // FIXME(sil-serialize-all)
-  internal static func asObjectIdentifier(_ value: Any) -> ObjectIdentifier? {
+  private static func asObjectIdentifier(_ value: Any) -> ObjectIdentifier? {
     return checkValue(value,
       ifClass: { return ObjectIdentifier($0) },
       otherwise: { return nil })
   }
 
-  @inlinable // FIXME(sil-serialize-all)
-  internal static func asNumericValue(_ value: Any) -> Int {
-    return checkValue(value,
+  private static func asObjectAddress(_ value: Any) -> String {
+    let address = checkValue(value,
       ifClass: { return unsafeBitCast($0, to: Int.self) },
       otherwise: { return 0 })
-  }
-
-  @inlinable // FIXME(sil-serialize-all)
-  internal static func asStringRepresentation(
+    return String(address, radix: 16, uppercase: false)
+  }
+
+  private static func asStringRepresentation(
     value: Any?,
     mirror: Mirror,
     count: Int
   ) -> String? {
-    let ds = mirror.displayStyle ?? .`struct`
-    switch ds {
-      case .optional:
-        if count > 0 {
-          return "\(mirror.subjectType)"
-        }
-        else {
-          if let x = value {
-            return String(reflecting: x)
-          }
-        }
-      case .collection:
-        fallthrough
-      case .dictionary:
-        fallthrough
-      case .set:
-        fallthrough
-      case .tuple:
-        if count == 1 {
-          return "1 element"
-        } else {
-          return "\(count) elements"
-        }
-      case .`struct`:
-        fallthrough
-      case .`enum`:
-        if let x = value {
-          if let cdsc = (x as? CustomDebugStringConvertible) {
-            return cdsc.debugDescription
-          }
-          if let csc = (x as? CustomStringConvertible) {
-            return csc.description
-          }
-        }
-        if count > 0 {
-            return "\(mirror.subjectType)"
-        }
-      case .`class`:
-        if let x = value {
-          if let cdsc = (x as? CustomDebugStringConvertible) {
-            return cdsc.debugDescription
-          }
-          if let csc = (x as? CustomStringConvertible) {
-            return csc.description
-          }
-          // for a Class with no custom summary, mimic the Foundation default
-          return "<\(type(of: x)): 0x\(String(asNumericValue(x), radix: 16, uppercase: false))>"
-        } else {
-          // but if I can't provide a value, just use the type anyway
-          return "\(mirror.subjectType)"
-        }
-    }
-    if let x = value {
-      return String(reflecting: x)
-    }
-    return nil
-  }
-
-  @inlinable // FIXME(sil-serialize-all)
-  internal static func ivarCount(mirror: Mirror) -> Int {
-    let count = Int(mirror.children.count)
-    if let sc = mirror.superclassMirror {
-      return ivarCount(mirror: sc) + count
-    } else {
-      return count
-    }
-  }
-
-
-  @inlinable // FIXME(sil-serialize-all)
-  internal static func shouldExpand(
+    switch mirror.displayStyle {
+    case .optional? where count > 0:
+        return "\(mirror.subjectType)"
+    case .optional?:
+      return value.map(String.init(reflecting:))
+    case .collection?, .dictionary?, .set?, .tuple?:
+      return count == 1 ? "1 element" : "\(count) elements"
+    case .`struct`?, .`enum`?, nil:
+      switch value {
+      case let x as CustomDebugStringConvertible:
+        return x.debugDescription
+      case let x as CustomStringConvertible:
+        return x.description
+      case _ where count > 0:
+        return "\(mirror.subjectType)"
+      default:
+        return value.map(String.init(reflecting:))
+      }
+    case .`class`?:
+      switch value {
+      case let x as CustomDebugStringConvertible:
+        return x.debugDescription
+      case let x as CustomStringConvertible:
+        return x.description
+      case let x?:
+        // for a Class with no custom summary, mimic the Foundation default
+        return "<\(type(of: x)): 0x\(asObjectAddress(x))>"
+      default:
+        // but if I can't provide a value, just use the type anyway
+        return "\(mirror.subjectType)"
+      }
+    }
+  }
+
+  private static func ivarCount(mirror: Mirror) -> Int {
+    let ivars = mirror.superclassMirror.map(ivarCount) ?? 0
+    return ivars + mirror.children.count
+  }
+
+  private static func shouldExpand(
     mirror: Mirror,
     collectionStatus: CollectionStatus,
     isRoot: Bool
   ) -> Bool {
     if isRoot || collectionStatus.isCollection { return true }
-    let count = Int(mirror.children.count)
-    if count > 0 { return true }
-    if let ds = mirror.displayStyle {
-      if ds == .`class` {
-        return true
-      }
-    }
-    if let sc = mirror.superclassMirror {
-      return ivarCount(mirror: sc) > 0
-    } else {
-      return true
-    }
-  }
-
-  @inlinable // FIXME(sil-serialize-all)
-  internal static func printForDebuggerImpl<StreamType : TextOutputStream>(
+    if mirror.children.count > 0 { return true }
+    if mirror.displayStyle == .`class` { return true }
+    if let sc = mirror.superclassMirror { return ivarCount(mirror: sc) > 0 }
+    return true
+  }
+
+  private static func printForDebuggerImpl<StreamType : TextOutputStream>(
     value: Any?,
     mirror: Mirror,
     name: String?,

        indent: indent + 2,
        maxDepth: maxDepth - 1,
        isRoot: false,
        parentCollectionStatus: .NotACollection,
        refsAlreadySeen: &refsAlreadySeen,
        maxItemCounter: &maxItemCounter,
        targetStream: &targetStream)
    }
  
    for (optionalName,child) in mirror.children {
      let childName = optionalName ?? "\(printedElements)"
      if maxItemCounter <= 0 {
        for _ in 0..<(indent+4) {
          print(" ", terminator: "", to: &targetStream)
        }
        let remainder = count - printedElements
        print("(\(remainder)", terminator: "", to: &targetStream)
        if printedElements > 0 {
          print(" more", terminator: "", to: &targetStream)
        }
        if remainder == 1 {
          print(" child)", to: &targetStream)
        } else {
          print(" children)", to: &targetStream)
        }
        return
      }
    

      indent: 0,
      maxDepth: maxItemCounter,
      isRoot: true,
      parentCollectionStatus: .notACollection,
      refsAlreadySeen: &refs,
      maxItemCounter: &maxItemCounter,
      target: &target)

    return target
  }
}

public func _stringForPrintObject(_ value: Any) -> String {
  return _DebuggerSupport.stringForPrintObject(value)
}

public func _debuggerTestingCheckExpect(_: String, _: String) { }

// Utilities to get refcount(s) of class objects.
@_silgen_name("swift_retainCount")
