Skip to content

Commit 28b61b8

Browse files
committed
[moveOnly] Simplify some code as per DougG's review in a589b4a.
This is tested by test/Sema/noimplicitcopy_attr.swift. Everything still passes!
1 parent 8aef84c commit 28b61b8

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,15 @@ void AttributeChecker::visitNoImplicitCopyAttr(NoImplicitCopyAttr *attr) {
285285
return;
286286
}
287287

288-
if (vd->hasStorage()) {
289-
// We do not support fields of nominal types now.
290-
if (isa<NominalTypeDecl>(dc)) {
291-
auto error = diag::noimplicitcopy_attr_valid_only_on_local_let;
292-
diagnoseAndRemoveAttr(attr, error);
293-
return;
294-
}
288+
// We only support local lets.
289+
if (!dc->isLocalContext()) {
290+
auto error = diag::noimplicitcopy_attr_valid_only_on_local_let;
291+
diagnoseAndRemoveAttr(attr, error);
292+
return;
295293
}
296294

297-
// We do not support static or global vars either yet.
298-
if (dc->isModuleScopeContext() || (dc->isTypeContext() && vd->isStatic())) {
295+
// We do not support static vars either yet.
296+
if (dc->isTypeContext() && vd->isStatic()) {
299297
auto error = diag::noimplicitcopy_attr_valid_only_on_local_let;
300298
diagnoseAndRemoveAttr(attr, error);
301299
return;

0 commit comments

Comments
 (0)