mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The last step in building a generic signature is to sort the requirements. Requirements are sorted by comparing their subject types. If two requirements have the same subject type, which can only happen with conformance requirements, we break the tie by comparing protocol declarations. We compare protocol declarations using TypeDecl::compare(), which is a shortlex order on the components of the fully qualified name of a protocol (eg, Swift.Sequence, etc.) While this order is part of the ABI, it has not been updated over the years for several important changes: - It did not handle module aliases; if we import a module via an alias, we should use the real module name to compare protocols, and not the aliased name. This produced inconsistent results if the same module was imported under different names, which can happen with module interface files that use module aliases. - It did not handle the -module-abi-name flag. Changing the ABI name of a module changes how we mangle protocol names, and the order should match the mangling. This change fixes the first case only. The second requires more careful staging, because of _Concurrency and CompilerSwiftSyntax. Fixes rdar://147441890.
12 lines
648 B
Swift
12 lines
648 B
Swift
// RUN: %target-swift-emit-silgen %s -module-name main | %FileCheck %s
|
|
|
|
// See conformance_requirement_order.swift for the general case.
|
|
//
|
|
// Make sure that protocols from the _Concurrency module are ordered using
|
|
// their real module name and not their ABI module name, which is "Swift".
|
|
//
|
|
// This was a mistake since they mangle like protocols from "Swift", but
|
|
// at this point we cannot break existing code.
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @$s4main27requirementOrderConcurrencyyyxSTRzScFRzlF : $@convention(thin) <T where T : Sequence, T : Executor> (@guaranteed T) -> () {
|
|
func requirementOrderConcurrency<T: Executor & Sequence>(_: T) {} |