File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1964,8 +1964,17 @@ void TypeChecker::validateDecl(OperatorDecl *OD) {
1964
1964
}
1965
1965
1966
1966
bool swift::doesContextHaveValueSemantics (DeclContext *dc) {
1967
- if (Type contextTy = dc->getDeclaredInterfaceType ())
1968
- return !contextTy->hasReferenceSemantics ();
1967
+ if (Type contextTy = dc->getDeclaredInterfaceType ()) {
1968
+ // If the decl context is an extension, then it could be imposing a class
1969
+ // constraint (ex: where Self: SomeClass). Make sure we include that
1970
+ // in our check as well.
1971
+ auto extensionRequiresClass = false ;
1972
+ if (auto ED = dyn_cast<ExtensionDecl>(dc)) {
1973
+ extensionRequiresClass =
1974
+ ED->getGenericSignature ()->requiresClass (ED->getSelfInterfaceType ());
1975
+ }
1976
+ return !contextTy->hasReferenceSemantics () && !extensionRequiresClass;
1977
+ }
1969
1978
return false ;
1970
1979
}
1971
1980
You can’t perform that action at this time.
0 commit comments