[swift-dev] swift-corelibs-foundation failing in object conversion when building on Darwin host

Philippe Hausler phausler at apple.com
Thu Aug 4 15:21:22 CDT 2016


With a freshly built toolchain from ToT swift, building ToT swift-corelibs-foundation I am getting some very strange failures in the unit tests:

Test Suite 'TestNSKeyedArchiver' started at 13:15:01.843
Test Case 'TestNSKeyedArchiver.test_archive_array' started at 13:15:01.843
assertion failed: file /Volumes/Users/phausler/Documents/Public/swift/swift-corelibs-foundation/Foundation/NSKeyedArchiver.swift, line 23
2016-08-04 13:15:07.650689 TestFoundation[47395:4939580] assertion failed: file /Volumes/Users/phausler/Documents/Public/swift/swift-corelibs-foundation/Foundation/NSKeyedArchiver.swift, line 23
Current stack trace:

this is being caused by the line:

let classReference = innerDecodingContext.dict["$class"] as? CFKeyedArchiverUID

CFKeyedArchiverUID being AnyObject

and 

class DecodingContext {
        fileprivate var dict : Dictionary<String, Any>
	…
}

It claims a conditional cast from Any? to AnyObject always succeeds but it is giving me an unexpected type later on

Changing to:

let classReference = innerDecodingContext.dict["$class"] as CFKeyedArchiverUID?

Then makes the process no longer crash, however it then fails in an even more strange way:


guard let root = try unarchiver.decodeTopLevelObjectOfClasses(classes,
                        forKey: NSKeyedArchiveRootObjectKey) as? NSObject else {

by expanding that out the decoded object is a NSArray (expected), but that cannot be represented as an NSObject?! This isn’t Swift, this is madness!

Perhaps there is some other failure that I am not seeing underpinning this?


More information about the swift-dev mailing list