Skip to content

Don't emit @noescape error on every "@autoclosure is now a ..." error #4017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1662,9 +1662,11 @@ void TypeChecker::checkNoEscapeAttr(ParamDecl *PD, NoEscapeAttr *attr) {
}

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

// Stop if we've already applied this attribute.
if (FTy->isNoEscape())
Expand Down
3 changes: 3 additions & 0 deletions test/attr/attr_autoclosure.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// RUN: %target-parse-verify-swift
// RUN: not %target-swift-frontend -parse %s 2>&1 | FileCheck %s
// No errors at invalid locations!
// CHECK-NOT: <unknown>:0:

// Simple case.
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'}}
Expand Down