Skip to content

Commit 14c0114

Browse files
[AST] Consider storage signature when computing opaque params implicit generic params
1 parent bb59291 commit 14c0114

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/AST/NameLookup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,11 @@ createOpaqueParameterGenericParams(GenericContext *genericContext, GenericParamL
28452845
if (!value)
28462846
return { };
28472847

2848+
// Consider storage signature opaque parameters for accessor declaration.
2849+
if (auto *AD = dyn_cast<AccessorDecl>(value)) {
2850+
value = AD->getStorage();
2851+
}
2852+
28482853
// Functions, initializers, and subscripts can contain opaque parameters.
28492854
ParameterList *params = nullptr;
28502855
if (auto func = dyn_cast<AbstractFunctionDecl>(value))

test/type/opaque_parameters.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,19 @@ typealias FnType<T> = (T) -> Void
115115

116116
func consumingA(fn: (some P) -> Void) { } // expected-error{{'some' cannot appear in parameter position in parameter type '(some P) -> Void'}}
117117
func consumingB(fn: FnType<some P>) { } // expected-error{{'some' cannot appear in parameter position in parameter type '(some P) -> Void'}}
118+
119+
// https://github.com/apple/swift/issues/61387
120+
struct I61387 {
121+
subscript(s: some StringProtocol) -> String {
122+
fatalError()
123+
}
124+
}
125+
126+
struct I61387_1 {
127+
subscript(s: some StringProtocol) -> String {
128+
get { fatalError() }
129+
set {
130+
fatalError()
131+
}
132+
}
133+
}

0 commit comments

Comments
 (0)