SR-8054 Failure during MergeSwiftModule when UIView subclass implements init()
Issue Description:
When trying to build attached project with Debug configuration where SWIFT_COMPILATION_MODE is set to Incremental, the target fails to build with following log:
MergeSwiftModule normal x86_64 (in target: Trapped)
cd /Users/alvarhansen/Developer/Trap6
/Users/alvarhansen/Downloads/Xcode_10.1_Beta_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/View~partial.swiftmodule /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Button~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-ios12.1-simulator -enable-objc-interop -sdk /Users/alvarhansen/Downloads/Xcode_10.1_Beta_3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -I /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Products/Debug-iphonesimulator -F /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/alvarhansen/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-generated-files.hmap -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-own-target-headers.hmap -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-project-headers.hmap -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/DerivedSources/x86_64 -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/alvarhansen/Developer/Trap6 -emit-module-doc-path /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Trapped.swiftdoc -emit-objc-header-path /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Trapped-Swift.h -module-name Trapped -o /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Trapped.swiftmodule
<unknown>:0: error: fatal error encountered while reading from module 'Trapped'; please file a bug report with your project and the crash log *** DESERIALIZATION FAILURE (please include this section in any bug report) *** could not find 'init(frame:)' in parent class 0 swift 0x0000000112eea59a PrintStackTraceSignalHandler(void*) + 42 1 swift 0x0000000112ee9d4e SignalHandler(int) + 302 2 libsystem_platform.dylib 0x00007fff72a40b3d _sigtramp + 29 3 libsystem_platform.dylib 0x0000000123fa9bc6 _sigtramp + 2975240358 4 libsystem_c.dylib 0x00007fff728ff1c9 abort + 127 5 swift 0x000000011034fdbb swift::ModuleFile::fatal(llvm::Error) + 1915 6 swift 0x0000000110387413 getSILDeclRef(swift::ModuleFile*, llvm::ArrayRef<unsigned long long>, unsigned int&) + 307 7 swift 0x0000000110389754 swift::SILDeserializer::readVTable(llvm::PointerEmbeddedInt<unsigned int, 31>) + 740 8 swift 0x000000011043053b swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 331 9 swift 0x000000010f17875e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34558 10 swift 0x000000010f16cb65 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717 11 swift 0x000000010f112795 main + 1349 12 libdyld.dylib 0x00007fff72857085 start + 1 Stack dump: 0. Program arguments: /Users/alvarhansen/Downloads/Xcode_10.1_Beta_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/View~partial.swiftmodule /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Button~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-ios12.1-simulator -enable-objc-interop -sdk /Users/alvarhansen/Downloads/Xcode_10.1_Beta_3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -I /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Products/Debug-iphonesimulator -F /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/alvarhansen/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-generated-files.hmap -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-own-target-headers.hmap -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Trapped-project-headers.hmap -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/DerivedSources/x86_64 -Xcc -I/Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/alvarhansen/Developer/Trap6 -emit-module-doc-path /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Trapped.swiftdoc -emit-objc-header-path /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Trapped-Swift.h -module-name Trapped -o /Users/alvarhansen/Library/Developer/Xcode/DerivedData/Trap6-elemwkxabsutxxbqylirzvhsfvwr/Build/Intermediates.noindex/Trap6.build/Debug-iphonesimulator/Trapped.build/Objects-normal/x86_64/Trapped.swiftmodule 1. While deserializing SIL vtable for 'Button' in module 'Trapped' error: Abort trap: 6
If we use Release configuration where SWIFT_COMPILATION_MODE is set to Whole Module, building succeeds.
With rerelease (JIRA User) we were able to create this project that consists of only 2 files:
View.swift:
import UIKit
class View: UIView {}
and Button.swift
import UIKit
class Button: UIButton {}
extension NSObjectProtocol {
var controlEvent: UIControl.Event? { return nil }
}
The file names and View or Button class name does not seem to matter.
But the file order in build phase matters, View.swift needs to be before Button.swift.
Next necessary part is UIControl.Event usage inside NSObjectProtocol protocol.
It also reproduces if instead of NSObjectProtocol we use just NSObject extension.
Or if we use any UIControl nested type, for example UIControl.State (In Objective-C, these are not nested types).
Attachment: Download
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, Serialization | |Assignee | None | |Priority | Medium | md5: d88a574f0b74b6ab2fa22c04c4f990f0relates to:
Issue Description:
When trying to build attached project with Debug configuration where SWIFT_COMPILATION_MODE is set to Incremental, the target fails to build with following log:
If we use Release configuration where SWIFT_COMPILATION_MODE is set to Whole Module, building succeeds.
With rerelease (JIRA User) we were able to create this project that consists of only 2 files:
View.swift:
and Button.swift
The file names and View or Button class name does not seem to matter.
But the file order in build phase matters, View.swift needs to be before Button.swift.
Next necessary part is UIControl.Event usage inside NSObjectProtocol protocol.
It also reproduces if instead of NSObjectProtocol we use just NSObject extension.
Or if we use any UIControl nested type, for example UIControl.State (In Objective-C, these are not nested types).