hasAnyType recursively checks if the given attribute uses the Any type.
(att *expr.AttributeExpr)
| 1463 | |
| 1464 | // hasAnyType recursively checks if the given attribute uses the Any type. |
| 1465 | func hasAnyType(att *expr.AttributeExpr) bool { |
| 1466 | if att == nil { |
| 1467 | return false |
| 1468 | } |
| 1469 | if att.Type.Kind() == expr.AnyKind { |
| 1470 | return true |
| 1471 | } |
| 1472 | switch dt := att.Type.(type) { |
| 1473 | case expr.UserType: |
| 1474 | return hasAnyType(dt.Attribute()) |
| 1475 | case *expr.Object: |
| 1476 | for _, nat := range *dt { |
| 1477 | if hasAnyType(nat.Attribute) { |
| 1478 | return true |
| 1479 | } |
| 1480 | } |
| 1481 | case *expr.Array: |
| 1482 | return hasAnyType(dt.ElemType) |
| 1483 | case *expr.Map: |
| 1484 | return hasAnyType(dt.KeyType) || hasAnyType(dt.ElemType) |
| 1485 | case *expr.Union: |
| 1486 | for _, nat := range dt.Values { |
| 1487 | if hasAnyType(nat.Attribute) { |
| 1488 | return true |
| 1489 | } |
| 1490 | } |
| 1491 | } |
| 1492 | return false |
| 1493 | } |