diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index e3c61d877de02..2294a70f66fbf 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -8746,12 +8746,12 @@ ParserResult Parser::parseDeclFunc(SourceLoc StaticLoc, SourceLoc NameLoc; if (Tok.isAnyOperator() || Tok.isAny(tok::exclaim_postfix, tok::amp_prefix)) { // If the name is an operator token that ends in '<' and the following token - // is an identifier, split the '<' off as a separate token. This allows - // things like 'func ==(x:T, y:T) {}' to parse as '==' with generic type - // variable '' as expected. + // is an identifier or 'let', split the '<' off as a separate token. This + // allows things like 'func ==(x:T, y:T) {}' to parse as '==' with + // generic type variable '' as expected. auto NameStr = Tok.getText(); if (NameStr.size() > 1 && NameStr.back() == '<' && - peekToken().is(tok::identifier)) { + peekToken().isAny(tok::identifier, tok::kw_let)) { NameStr = NameStr.slice(0, NameStr.size() - 1); } SimpleName = Context.getIdentifier(NameStr); diff --git a/test/Sema/value_generics.swift b/test/Sema/value_generics.swift index 38d17ef39fc85..369c19372ff5e 100644 --- a/test/Sema/value_generics.swift +++ b/test/Sema/value_generics.swift @@ -51,6 +51,8 @@ func c(with a: A) {} // OK func d(with a: A) {} // expected-error {{cannot pass type 'T' as a value for generic value 'N'}} func e(with a: A) {} // expected-error {{cannot pass type 'Int' as a value for generic value 'N'}} +func *(l: A, r: A) -> Int { l.int * r.int } + struct Generic {} struct GenericWithIntParam {}