From 7a71573868ec8852cfec12291daa59824609b28c Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Mon, 30 Sep 2024 20:24:29 -0400 Subject: [PATCH] Fix names --- .../SnapshotPreviewsCore/ConformanceLookup.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/SnapshotPreviewsCore/ConformanceLookup.swift b/Sources/SnapshotPreviewsCore/ConformanceLookup.swift index 1d13d2d..bc07c64 100644 --- a/Sources/SnapshotPreviewsCore/ConformanceLookup.swift +++ b/Sources/SnapshotPreviewsCore/ConformanceLookup.swift @@ -11,6 +11,13 @@ import MachO private func getTypeName(descriptor: UnsafePointer) -> String? { let flags = descriptor.pointee.flags var parentName: String? = nil + if descriptor.pointee.parent != 0 { + let parent = UnsafeRawPointer(descriptor).advanced(by: MemoryLayout.offset(of: \.parent)!).advanced(by: Int(descriptor.pointee.parent)) + if abs(descriptor.pointee.parent) % 2 == 1 { + return nil + } + parentName = getTypeName(descriptor: parent.assumingMemoryBound(to: TargetModuleContextDescriptor.self)) + } switch flags.kind { case .Module, .Enum, .Struct, .Class: let name = UnsafeRawPointer(descriptor) @@ -18,19 +25,12 @@ private func getTypeName(descriptor: UnsafePointer.offset(of: \.parent)!).advanced(by: Int(descriptor.pointee.parent)) - if abs(descriptor.pointee.parent) % 2 == 1 { - return nil - } - parentName = getTypeName(descriptor: parent.assumingMemoryBound(to: TargetModuleContextDescriptor.self)) - } if let parentName = parentName { return "\(parentName).\(typeName)" } return typeName default: - return nil + return parentName } }