Skip to content

[AST] Prefer 'synthesized' conformances to 'implied' ones consistently. #14385

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

Merged
merged 2 commits into from
Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Swift 5.0

Runtime query of conditional conformances is now implemented. Therefore,
a dynamic cast such as `value as? P`, where the dynamic type of `value`
conditional conforms to `P`, will succeed when the conditional
conditionally conforms to `P`, will succeed when the conditional
requirements are met.

Swift 4.1
Expand Down
10 changes: 5 additions & 5 deletions include/swift/AST/DeclContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ enum class LocalDeclContextKind : uint8_t {
///
/// The enumerators are ordered in terms of decreasing preference:
/// an inherited conformance is best, followed by explicit
/// conformances, then implied conformances. Earlier conformance
/// kinds supersede later conformance kinds, possibly with a
/// conformances, then synthesized and implied conformances. Earlier
/// conformance kinds supersede later conformance kinds, possibly with a
/// diagnostic (e.g., if an inherited conformance supersedes an
/// explicit conformance).
enum class ConformanceEntryKind : unsigned {
Expand All @@ -131,11 +131,11 @@ enum class ConformanceEntryKind : unsigned {
/// Explicitly specified.
Explicit,

/// Implied by an explicitly-specified conformance.
Implied,

/// Implicitly synthesized.
Synthesized,

/// Implied by an explicitly-specified conformance.
Implied,
};

/// Describes the kind of conformance lookup desired.
Expand Down
4 changes: 4 additions & 0 deletions test/multifile/Inputs/protocol-conformance-sr6839-other.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class EnumValueConstructor<EnumType : EnumValueType> where EnumType.RawValue : Hashable {}
class _PositionRelation_GeneratedWrapperConstructor : EnumValueConstructor<_PositionRelation> {}
extension _PositionRelation : EnumValueType {}
protocol EnumValueType : RawRepresentable {}
10 changes: 10 additions & 0 deletions test/multifile/protocol-conformance-sr6839.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: %target-swift-frontend -emit-sil -module-name main -primary-file %s %S/Inputs/protocol-conformance-sr6839-other.swift | %FileCheck -check-prefix CHECK-FIRST %s
// RUN: %target-swift-frontend -emit-sil -module-name main %s -primary-file %S/Inputs/protocol-conformance-sr6839-other.swift | %FileCheck -check-prefix CHECK-SECOND %s

// We need to consistently pick where the witness table for _PositionRelation :
// RawRepresentable goes.
// CHECK-FIRST: sil_witness_table hidden _PositionRelation: RawRepresentable
// CHECK-SECOND-NOT: sil_witness_table hidden _PositionRelation: RawRepresentable
enum _PositionRelation: Int {
case before = 0
}