Skip to content

Revert "[Parser] Fix-it for declaration attributes being applied to parameter types (SR-215)" #1098

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
merged 1 commit into from
Jan 26, 2016
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
18 changes: 0 additions & 18 deletions lib/Parse/ParsePattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,6 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
if (Tok.is(tok::colon)) {
param.ColonLoc = consumeToken();

// Check if token is @ sign ergo an attribute
if (Tok.is(tok::at_sign)) {
Token nextToken = peekToken();
// Check if attribute is invalid type attribute
// and actually a declaration attribute
TypeAttrKind TK = TypeAttributes::getAttrKindFromString(nextToken.getText());
DeclAttrKind DK = DeclAttribute::getAttrKindFromString(nextToken.getText());
if ((TK == TAK_Count || (TK == TAK_noescape && !isInSILMode()))
&& DK != DAK_Count
&& DeclAttribute::getOptions(declKind) & OnParam) {
SourceLoc AtLoc = consumeToken(tok::at_sign);
SourceLoc AttrLoc = consumeToken(tok::identifier);
diagnose(AtLoc, diag::decl_attribute_applied_to_type)
.fixItRemove(SourceRange(AtLoc, AttrLoc))
.fixItInsert(StartLoc, "@" + nextToken.getText().str()+" ");
}
}

auto type = parseType(diag::expected_parameter_type);
status |= type;
param.Type = type.getPtrOrNull();
Expand Down
2 changes: 0 additions & 2 deletions test/attr/attr_noescape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

@noescape var fn : () -> Int = { 4 } // expected-error {{@noescape may only be used on 'parameter' declarations}} {{1-11=}}

func appliedToType(g: @noescape ()->Void) { g() } // expected-error {{attribute can only be applied to declarations, not types}} {{20-20=@noescape }} {{23-33=}}

func doesEscape(fn : () -> Int) {}

func takesGenericClosure<T>(a : Int, @noescape _ fn : () -> T) {}
Expand Down