2017-11-06 3 views
0

Wenn Sie diesen Code auf Xcode 9.1 mit der Optimierungsstufe Fast, whole Module Optimization ausführen, stürzt er ab. Wenn die Optimierungsstufe auf None eingestellt ist, ist alles in Ordnung.Swift 4 Fehler bei Release-Konfiguration

Hat jemand eine Idee von dem Problem?

protocol FooProtocol { 
    func foo() 
} 

class FooProtocolImplementation : NSObject, FooProtocol { 
    func foo() {} 
} 

var set: Set<AnyHashable> = [] 
_ = set.insert(FooProtocolImplementation()) 
let array = set.flatMap { $0 as? FooProtocol } // filtering out nils 
_ = array[0] // # error (EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) 
+0

Was ist, wenn Sie erben nicht von 'NSObject'? – LShi

+0

Es funktioniert nicht –

+0

Was würde passieren, wenn Sie 'FooProtocol' als Klassenprotokoll festlegen:' Protokoll FooProtocol: class'? Und wenn Sie mehr Details zur Verfügung stellen können, wie in welcher Zeile es abstürzt. – Ivan

Antwort

0

von Apple berichtet, es als einen Fehler und fixiert es in Xcode 9.3