Skip to content

[Runtime] Allow ~Escapable types in _getMangledTypeName. #80000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/public/core/Misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ func _typeName(_ type: Any.Type, qualified: Bool = true) -> String {
@available(SwiftStdlib 5.3, *)
@_silgen_name("swift_getMangledTypeName")
@_preInverseGenerics
public func _getMangledTypeName(_ type: any ~Copyable.Type)
public func _getMangledTypeName(_ type: any (~Copyable & ~Escapable).Type)
-> (UnsafePointer<UInt8>, Int)

/// Returns the mangled name for a given type.
@available(SwiftStdlib 5.3, *)
@_unavailableInEmbedded
@_preInverseGenerics
public // SPI
func _mangledTypeName(_ type: any ~Copyable.Type) -> String? {
func _mangledTypeName(_ type: any (~Copyable & ~Escapable).Type) -> String? {
let (stringPtr, count) = unsafe _getMangledTypeName(type)
guard count > 0 else {
return nil
Expand Down
6 changes: 6 additions & 0 deletions test/Runtime/demangleToMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ DemangleToMetadataTests.test("Nested types in same-type-constrained extensions")
}

struct NonCopyable: ~Copyable {}
struct NonEscapable: ~Escapable {}

if #available(SwiftStdlib 5.3, *) {
DemangleToMetadataTests.test("Round-trip with _mangledTypeName and _typeByName") {
Expand Down Expand Up @@ -531,6 +532,11 @@ if #available(SwiftStdlib 5.3, *) {
let type: any ~Copyable.Type = NonCopyable.self
expectEqual("4main11NonCopyableV", _mangledTypeName(type))
}

DemangleToMetadataTests.test("Check _MangledTypeName with any ~Escapable.Type") {
let type: any ~Escapable.Type = NonEscapable.self
expectEqual("4main12NonEscapableV", _mangledTypeName(type))
}
}

if #available(SwiftStdlib 5.1, *) {
Expand Down