Skip to content

Commit 809f423

Browse files
authored
!seems swift 5.3 mac release for some reason did not include the new (#776)
function, so we have to remove this functionality
1 parent 200c051 commit 809f423

File tree

2 files changed

+1
-103
lines changed

2 files changed

+1
-103
lines changed

Sources/DistributedActors/Serialization/Serialization+Manifest.swift

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -132,34 +132,7 @@ extension Serialization {
132132
@inlinable
133133
@inline(__always)
134134
internal static func getTypeHint(_ messageType: Any.Type) -> String {
135-
#if compiler(>=5.3)
136-
#if os(Linux)
137-
let (ptr, count) = _getMangledTypeName(messageType)
138-
if count > 0 {
139-
return String(cString: ptr)
140-
} else {
141-
return _typeName(messageType)
142-
}
143-
#else
144-
if #available(macOS 10.16, iOS 14.0, *) {
145-
// This is "special". A manifest containing a mangled type name can be summoned if the type remains unchanged
146-
// on a receiving node. Summoning a type is basically `_typeByName` with extra checks that this type should be allowed
147-
// to be deserialized (thus, we can disallow decoding random messages for security).
148-
//
149-
// We would eventually want "codingTypeName" or something similar
150-
let (ptr, count) = _getMangledTypeName(messageType)
151-
if count > 0 {
152-
return String(cString: ptr)
153-
} else {
154-
return _typeName(messageType)
155-
}
156-
} else {
157-
return _typeName(messageType)
158-
}
159-
#endif // os
160-
#else
161-
return _typeName(messageType)
162-
#endif // swift-version
135+
_typeName(messageType)
163136
}
164137

165138
/// Summon a `Type` from a manifest whose `hint` contains a mangled name.

Tests/DistributedActorsTests/SerializationTests.swift

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -409,81 +409,6 @@ class SerializationTests: ActorSystemXCTestCase {
409409
let back = try system.serialization.deserialize(as: PListXMLCodableTest.self, from: serialized)
410410
back.shouldEqual(test)
411411
}
412-
413-
// ==== ----------------------------------------------------------------------------------------------------------------
414-
// MARK: Mangled-name Manifests
415-
416-
func test_manifest_usingMangledName() throws {
417-
var ok = true
418-
#if compiler(>=5.3)
419-
ok = true // ok
420-
#else
421-
ok = false
422-
#endif
423-
424-
#if os(Linux)
425-
ok = ok && true // ok
426-
#else
427-
if #available(macOS 10.16, iOS 14.0, *) {
428-
() // ok, it's available on these platforms
429-
} else {
430-
ok = false
431-
}
432-
#endif
433-
434-
guard ok else {
435-
pnote("Skipping \(#function) test, as the required [_getMangledTypeName] is not available on this platform.")
436-
return
437-
}
438-
439-
let manifest = try self.system.serialization.outboundManifest(ManifestArray<CodableAnimal>.self)
440-
manifest.hint!.shouldStartWith(prefix: "22DistributedActorsTests13ManifestArray")
441-
manifest.hint!.shouldEndWith(suffix: "CodableAnimalCG")
442-
}
443-
444-
// Disclaimer: Such deserialization style COULD be a security risk, however we ensure to always use the `summonType`
445-
// and actor system associated APIs which working with mangled names and types -- the system can be configured in strict
446-
// or lose mode, meaning that normally it should ENFORCE that we never deserialize a type that we did not EXPLICITLY enlist to be available for such intents.
447-
func test_mangledTypeName_catDogList() throws {
448-
var ok = true
449-
#if compiler(>=5.3)
450-
ok = true // ok
451-
#else
452-
ok = false
453-
#endif
454-
455-
#if os(Linux)
456-
ok = ok && true // ok
457-
#else
458-
if #available(macOS 10.16, iOS 14.0, *) {
459-
() // ok, it's available on these platforms
460-
} else {
461-
ok = false
462-
}
463-
#endif
464-
465-
guard ok else {
466-
pnote("Skipping \(#function) test, as the required [_getMangledTypeName] is not available on this platform.")
467-
return
468-
}
469-
470-
let dog = TestDog(bark: "woof")
471-
let cat = TestCat(purr: "purr")
472-
let list: ManifestArray<CodableAnimal> = [
473-
dog,
474-
cat,
475-
]
476-
477-
let serialized = try self.system.serialization.serialize(list)
478-
pinfo("\(serialized.buffer.stringDebugDescription())")
479-
480-
let back = try self.system.serialization.deserialize(as: ManifestArray<CodableAnimal>.self, from: serialized)
481-
pinfo("\(back))")
482-
483-
back.elements.count.shouldEqual(list.elements.count)
484-
(back.elements.first(where: { "\($0)".contains("Dog") }) as! TestDog).shouldEqual(dog)
485-
(back.elements.first(where: { "\($0)".contains("Cat") }) as! TestCat).shouldEqual(cat)
486-
}
487412
}
488413

489414
// ==== ----------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)