Skip to content

Commit 34b6e4f

Browse files
committed
Add precondition that no repairs were made to _mangledTypeName string
1 parent ea6b69e commit 34b6e4f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

stdlib/public/core/Misc.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ func _mangledTypeName<T>(_ type: T.Type) -> String? {
9292
return nil
9393
}
9494

95-
return String._fromUTF8Repairing(
96-
UnsafeBufferPointer(start: stringPtr, count: count)).0
95+
let (result, repairsMade) = String._fromUTF8Repairing(
96+
UnsafeBufferPointer(start: stringPtr, count: count))
97+
98+
precondition(!repairsMade, "repairs made to _mangledTypeName, this is not expected since names should always valid UTF-8")
99+
100+
return result
97101
}
98102

99103
/// Lookup a class given a name. Until the demangled encoding of type

0 commit comments

Comments
 (0)