If context != "", type parameters are not permitted.
(context string, tparamList *[]*Field)
| 1359 | |
| 1360 | // If context != "", type parameters are not permitted. |
| 1361 | func (p *parser) funcType(context string, tparamList *[]*Field) *FuncType { |
| 1362 | if trace { |
| 1363 | defer p.trace("funcType")() |
| 1364 | } |
| 1365 | |
| 1366 | typ := new(FuncType) |
| 1367 | typ.pos = p.pos() |
| 1368 | |
| 1369 | if p.allowGenerics() && p.tok == _Lbrack { |
| 1370 | p.async(func() { |
| 1371 | p.next() |
| 1372 | if context != "" { |
| 1373 | // accept but complain |
| 1374 | p.syntaxErrorAt(typ.pos, context+" must have no type parameters") |
| 1375 | } |
| 1376 | if p.tok == _Rbrack { |
| 1377 | p.syntaxError("empty type parameter list") |
| 1378 | p.next() |
| 1379 | } else { |
| 1380 | list := p.paramList(nil, nil, _Rbrack, true) |
| 1381 | if tparamList != nil { |
| 1382 | *tparamList = list |
| 1383 | } |
| 1384 | } |
| 1385 | }) |
| 1386 | } |
| 1387 | |
| 1388 | p.async(func() { |
| 1389 | p.want(_Lparen) |
| 1390 | typ.ParamList = p.paramList(nil, nil, _Rparen, false) |
| 1391 | }) |
| 1392 | typ.ResultList = p.funcResult() |
| 1393 | |
| 1394 | return typ |
| 1395 | } |
| 1396 | |
| 1397 | // "[" has already been consumed, and pos is its position, and open is its tape index. |
| 1398 | // If len != nil it is the already consumed array length. |
no test coverage detected