| 325 | } |
| 326 | |
| 327 | experimental::Type TypeEnvironment::fresh(Type _type) |
| 328 | { |
| 329 | std::unordered_map<size_t, Type> mapping; |
| 330 | auto freshImpl = [&](Type _type, auto _recurse) -> Type { |
| 331 | return std::visit(util::GenericVisitor{ |
| 332 | [&](TypeConstant const& _type) -> Type { |
| 333 | return TypeConstant{ |
| 334 | _type.constructor, |
| 335 | _type.arguments | ranges::views::transform([&](Type _argType) { |
| 336 | return _recurse(_argType, _recurse); |
| 337 | }) | ranges::to<std::vector<Type>> |
| 338 | }; |
| 339 | }, |
| 340 | [&](TypeVariable const& _var) -> Type { |
| 341 | if (auto* mapped = util::valueOrNullptr(mapping, _var.index())) |
| 342 | { |
| 343 | auto* typeVariable = std::get_if<TypeVariable>(mapped); |
| 344 | solAssert(typeVariable); |
| 345 | // TODO: can there be a mismatch? |
| 346 | solAssert(typeVariable->sort() == _var.sort()); |
| 347 | return *mapped; |
| 348 | } |
| 349 | return mapping[_var.index()] = m_typeSystem.freshTypeVariable(_var.sort()); |
| 350 | }, |
| 351 | [](std::monostate) -> Type { solAssert(false); } |
| 352 | }, resolve(_type)); |
| 353 | }; |
| 354 | return freshImpl(_type, freshImpl); |
| 355 | } |
| 356 | |
| 357 | std::optional<std::string> TypeSystem::instantiateClass(Type _instanceVariable, Arity _arity) |
| 358 | { |
no test coverage detected