New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-10438] Self constraint working on Swift 4.2 but not Swift 5 #52838
Comments
Comment by Vincent Isambart (JIRA) A slight variation of the code above even crashes the compiler: import Foundation
public protocol AuthenticationFlowStateMachine {
associatedtype StartState: AuthenticationFlowStateMachineStartState where StartState.NonFinalState == Self.NonFinalState
associatedtype NonFinalState: AuthenticationFlowStateMachineNonFinalState where NonFinalState.StateMachine == Self
associatedtype FlowError: AuthenticationFlowStateMachineFlowError where FlowError.StateMachine == Self
}
public protocol AuthenticationFlowStateMachineFlowError: Error {
associatedtype StateMachine: AuthenticationFlowStateMachine where StateMachine.FlowError == Self
}
public protocol AuthenticationFlowStateMachineStartState {
associatedtype NonFinalState: AuthenticationFlowStateMachineNonFinalState
}
public protocol AuthenticationFlowStateMachineNonFinalState {
associatedtype StateMachine: AuthenticationFlowStateMachine where StateMachine.NonFinalState == Self
}
public protocol AuthenticationFlowStateMachineSynchronousAction {
associatedtype StateMachine: AuthenticationFlowStateMachine
}
public class AuthenticationFlowStateMachineAction<StateMachine: AuthenticationFlowStateMachine> {
public static func synchronous<Action: AuthenticationFlowStateMachineSynchronousAction>(_ action: Action) where Action.StateMachine == StateMachine {}
} That gives you: Client.swift:5:35: warning: redundant conformance constraint 'Self.NonFinalState': 'AuthenticationFlowStateMachineNonFinalState'
associatedtype NonFinalState: AuthenticationFlowStateMachineNonFinalState where NonFinalState.StateMachine == Self
^
Client.swift:4:32: note: conformance constraint 'Self.NonFinalState': 'AuthenticationFlowStateMachineNonFinalState' implied here
associatedtype StartState: AuthenticationFlowStateMachineStartState where StartState.NonFinalState == Self.NonFinalState
^
Stack dump:
0. Program arguments: /Applications/Xcode-10.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret Client.swift -enable-objc-interop -sdk /Applications/Xcode-10.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name Client
1. While emitting IR SIL function "@$s6Client36AuthenticationFlowStateMachineActionC11synchronousyyqd__AA0bcde11SynchronousF0Rd__0dE0_05StartD008NonFinalD0AfGQYd__AGRtz0C5Error_AfghfGQZAIRSAF_AghfkfGQYd__ALRSlFZ".
for 'synchronous(_:)' (at Client.swift:26:12)
0 swift 0x000000010fe69ee3 PrintStackTraceSignalHandler(void*) + 51
1 swift 0x000000010fe696bc SignalHandler(int) + 348
2 libsystem_platform.dylib 0x00007fff6bd7fb5d _sigtramp + 29
3 libsystem_platform.dylib 0x00007ffee3fc5f90 _sigtramp + 2015650896
4 swift 0x000000010bd16dc1 swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>*) + 65
5 swift 0x000000010bd16d32 swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 450
6 swift 0x000000010bd16b38 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&)::$_1>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 1656
7 swift 0x000000010be6753f swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 335
8 swift 0x000000010bd15cea swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 490
9 swift 0x000000010bd15818 swift::irgen::FulfillmentMap::searchTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::irgen::IsExact_t, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 264
10 swift 0x000000010bf1415a swift::irgen::IRGenFunction::bindLocalTypeDataFromTypeMetadata(swift::CanType, swift::irgen::IsExact_t, llvm::Value*, swift::MetadataState) + 314
11 swift 0x000000010be650ad swift::irgen::emitPolymorphicParameters(swift::irgen::IRGenFunction&, swift::SILFunction&, swift::irgen::Explosion&, swift::irgen::WitnessMetadata*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 1053
12 swift 0x000000010becbf71 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8049
13 swift 0x000000010bd8a350 swift::irgen::IRGenerator::emitGlobalTopLevel(bool) + 1232
14 swift 0x000000010beac1b4 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1076
15 swift 0x000000010bea9937 swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::GlobalVariable**) + 711
16 swift 0x000000010bcce4e6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 50486
17 swift 0x000000010bcbe6de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
18 swift 0x000000010bc5c7be main + 1246
19 libdyld.dylib 0x00007fff6bb9a3d5 start + 1
Segmentation fault: 11 |
No, I think this is a different issue. |
The first test case no longer diagnoses on master, so I'll add a regression test. The second one doesn't crash anymore either, but still produces the bogus warning, and then a bogus diagnostic about the nested type:
|
Comment by Vincent Isambart (JIRA) Thanks for the update! Adding a regression test would be really appreciated 😃. I tried for the first time installing the toolchains from swift.org, and the installation and management from Xcode was way easier than I thought 🙂. I tried building the full library with both the latest master and 5.1 toolchains, and even though for 5.1 the result was the same as with 5.0.1, the full library did indeed build successfully with the latest master. Great that there weren't any additional problem. I guess we'll have to wait until a version of Xcode (probably 10.4 or 11.0?) includes the current master... |
Comment by Ky (JIRA) Looks to be working again in 5.1 |
This is fixed in Swift 5.1 |
Environment
Xcode 10.2
Additional Detail from JIRA
md5: 080fd66d9f09694bafd0af891239a2f0
is duplicated by:
Issue Description:
The following code was building successfully on Xcode 10.1, but is not in Xcode 10.2 (in both Swift 4.2 and 5 mode).
Xcode 10.2 (Swift 5) gives me the following error:
The text was updated successfully, but these errors were encountered: