| 146 | } |
| 147 | |
| 148 | static StarlarkType type(Object value) { |
| 149 | if (value instanceof StarlarkValue val) { |
| 150 | StarlarkType type = val.getStarlarkType(); |
| 151 | // Workaround for test mocks that generate getStarlarkType returning null |
| 152 | return Objects.requireNonNullElse(type, Types.ANY); |
| 153 | } |
| 154 | if (value instanceof Boolean) { |
| 155 | return Types.BOOL; |
| 156 | } |
| 157 | if (value instanceof String) { |
| 158 | return Types.STR; |
| 159 | } |
| 160 | throw new IllegalArgumentException("Expected a valid Starlark value."); |
| 161 | } |
| 162 | |
| 163 | private static class ParameterizedTypeImpl implements ParameterizedType { |
| 164 | private final Type rawType; |