Skip to content

Commit 837ea08

Browse files
authored
Merge pull request #4017 from benlangmuir/autoclosure-noescape-diag-3.0
Don't emit @NoEscape error on every "@autoclosure is now a ..." error
2 parents 489b5be + d4182c0 commit 837ea08

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,9 +1662,11 @@ void TypeChecker::checkNoEscapeAttr(ParamDecl *PD, NoEscapeAttr *attr) {
16621662
}
16631663

16641664
// This decl attribute has been moved to being a type attribute.
1665-
diagnose(attr->getLocation(), diag::attr_decl_attr_now_on_type, "@noescape")
1666-
.fixItRemove(attrRemovalRange)
1667-
.fixItInsert(PD->getTypeLoc().getSourceRange().Start, "@noescape ");
1665+
if (!attr->isImplicit()) {
1666+
diagnose(attr->getLocation(), diag::attr_decl_attr_now_on_type, "@noescape")
1667+
.fixItRemove(attrRemovalRange)
1668+
.fixItInsert(PD->getTypeLoc().getSourceRange().Start, "@noescape ");
1669+
}
16681670

16691671
// Stop if we've already applied this attribute.
16701672
if (FTy->isNoEscape())

test/attr/attr_autoclosure.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// RUN: %target-parse-verify-swift
2+
// RUN: not %target-swift-frontend -parse %s 2>&1 | FileCheck %s
3+
// No errors at invalid locations!
4+
// CHECK-NOT: <unknown>:0:
25

36
// Simple case.
47
var fn : @autoclosure () -> Int = 4 // expected-error {{@autoclosure may only be used on parameters}} expected-error {{cannot convert value of type 'Int' to specified type '() -> Int'}}

0 commit comments

Comments
 (0)