Skip to content

Commit 45c6315

Browse files
committed
Sema: Simplify 'dynamic' and 'final' inference a bit
1 parent 72735ec commit 45c6315

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,14 +1250,12 @@ static void validatePatternBindingEntries(TypeChecker &tc,
12501250

12511251
void swift::makeFinal(ASTContext &ctx, ValueDecl *D) {
12521252
if (D && !D->isFinal()) {
1253-
assert(!D->isDynamic());
12541253
D->getAttrs().add(new (ctx) FinalAttr(/*IsImplicit=*/true));
12551254
}
12561255
}
12571256

12581257
void swift::makeDynamic(ASTContext &ctx, ValueDecl *D) {
12591258
if (D && !D->isDynamic()) {
1260-
assert(!D->isFinal());
12611259
D->getAttrs().add(new (ctx) DynamicAttr(/*IsImplicit=*/true));
12621260
}
12631261
}
@@ -5485,8 +5483,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
54855483

54865484
// If this is a class member, mark it final if the class is final.
54875485
if (auto cls = FD->getDeclContext()->getAsClassOrClassExtensionContext()) {
5488-
if (cls->isFinal() && !FD->isAccessor() &&
5489-
!FD->isFinal() && !FD->isDynamic()) {
5486+
if (cls->isFinal() && !FD->isFinal()) {
54905487
makeFinal(TC.Context, FD);
54915488
}
54925489
// static func declarations in classes are synonyms
@@ -7817,7 +7814,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
78177814
// class is final, or if it was declared with 'let'.
78187815
if (auto cls = dyn_cast<ClassDecl>(nominalDecl)) {
78197816
if (cls->isFinal() || VD->isLet()) {
7820-
if (!VD->isFinal() && !VD->isDynamic()) {
7817+
if (!VD->isFinal()) {
78217818
makeFinal(Context, VD);
78227819
}
78237820
}

0 commit comments

Comments
 (0)