-1

新的 Xcode GM 种子(以及之前的 beta 6)无法构建多个分段错误 11 错误(使用 swift 4.2)。即使我删除、重命名或注释掉有问题的类,错误也不会消失。

该项目在带有 Xcode 9 的 Swift 4.1 上构建没有问题。

出现错误的示例类:

import Foundation

/// Possible sides for a corner.
public enum CornerSide {
    /// Corner on the left side.
    case left,
    /// Corner on the right side.
    right
}

或者

import Foundation

extension Int {
    var toString: String { return "\(self)" }
}

或者

import Foundation

public class DemoStatistics: Statistics { }

统计类是具有功能和扩展的普通类(没什么特别的)。

堆栈跟踪:

0  swift                    0x000000011199264a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x0000000111991dfe SignalHandler(int) + 302
2  libsystem_platform.dylib 0x00007fff7e337f5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fd691b0bcd8 _sigtramp + 326974872
4  swift                    0x000000010f17e126 swift::ProtocolConformanceRef::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 550
5  swift                    0x000000010f18a7f9 swift::SubstitutionMap::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 761
6  swift                    0x000000010f17e4fd swift::ProtocolConformance::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 749
7  swift                    0x000000010f17e7bb swift::ProtocolConformance::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 1451
8  swift                    0x000000010eda6e59 swift::ConformanceChecker::ensureRequirementsAreSatisfied(bool)::GatherConformancesListener::satisfiedConformance(swift::Type, swift::Type, swift::ProtocolConformanceRef) + 201
9  swift                    0x000000010ed7cc2f swift::TypeChecker::checkGenericArguments(swift::DeclContext*, swift::SourceLoc, swift::SourceLoc, swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, llvm::ArrayRef<swift::Requirement>, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, llvm::function_ref<bool (swift::TypeCheckRequest)>*, swift::OptionSet<swift::ConformanceCheckFlags, unsigned int>, swift::GenericRequirementsCheckListener*, swift::SubstOptions) + 1103
10 swift                    0x000000010eda6bcd swift::ConformanceChecker::ensureRequirementsAreSatisfied(bool) + 1325
11 swift                    0x000000010edc24ba swift::ConformanceChecker::resolveTypeWitnesses() + 378
12 swift                    0x000000010ed92973 swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 11347
13 swift                    0x000000010ed8f8c2 swift::MultiConformanceChecker::checkAllConformances() + 162
14 swift                    0x000000010eda8ac7 swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 4279
15 swift                    0x000000010edf2f94 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2388
16 swift                    0x000000010ea2d865 swift::CompilerInstance::performSema() + 4949
17 swift                    0x000000010dc1a59b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 731
18 swift                    0x000000010dc16dc5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
19 swift                    0x000000010dbbca35 main + 1349
20 libdyld.dylib            0x00007fff7e029015 start + 1
21 libdyld.dylib            0x00000000000000ac start + 2180870296

出现错误的所有类都在我正在构建并在示例 iOS 应用程序中使用的框架中。任何帮助,将不胜感激。

4

1 回答 1

0

设法自己解决了这个问题。问题在于单个泛型类从同一个协议继承了两次(一次直接继承,一次通过另一个协议)。

奇怪的是,swift 4.1 和 Xcode 9 没有问题,分段错误 11 位置与实际错误的位置无关。

于 2018-09-17T11:44:19.260 回答