Skip to content

Commit e066d43

Browse files
authored
Merge pull request #34586 from rintaro/ide-completion-rdar71005827
[DerivedConformance] Correctly set access of derived 'hash(into:)'
2 parents 84360d9 + fa7b671 commit e066d43

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ deriveHashable_hashInto(
552552
/*GenericParams=*/nullptr, params, returnType, parentDC);
553553
hashDecl->setBodySynthesizer(bodySynthesizer);
554554

555-
hashDecl->copyFormalAccessFrom(derived.Nominal);
555+
hashDecl->copyFormalAccessFrom(derived.Nominal,
556+
/*sourceIsParentContext=*/true);
556557

557558
derived.addMembersToConformanceContext({hashDecl});
558559

test/IDE/complete_rdar71005827.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
2+
3+
private enum GlobalPrivateE {
4+
case foo, bar
5+
}
6+
7+
func testGlobalPrivate(val: GlobalPrivateE) {
8+
val.#^GLOBALPRIVATE^#
9+
// GLOBALPRIVATE: Begin completions, 3 items
10+
// GLOBALPRIVATE-DAG: Keyword[self]/CurrNominal: self[#GlobalPrivateE#];
11+
// GLOBALPRIVATE-DAG: Decl[InstanceVar]/CurrNominal: hashValue[#Int#];
12+
// GLOBALPRIVATE-DAG: Decl[InstanceMethod]/CurrNominal: hash({#into: &Hasher#})[#Void#];
13+
// GLOBALPRIVATE: End completions
14+
}
15+
16+
func testLocal() {
17+
enum LocalE {
18+
case foo, bar
19+
}
20+
var val = LocalE.foo
21+
val.#^LOCAL^#
22+
// LOCAL: Begin completions, 3 items
23+
// LOCAL-DAG: Keyword[self]/CurrNominal: self[#LocalE#];
24+
// LOCAL-DAG: Decl[InstanceVar]/CurrNominal: hashValue[#Int#];
25+
// LOCAL-DAG: Decl[InstanceMethod]/CurrNominal: hash({#into: &Hasher#})[#Void#];
26+
// LOCAL: End completions
27+
}

0 commit comments

Comments
 (0)