diff --git a/luau b/luau index db809395..47543e5d 160000 --- a/luau +++ b/luau @@ -1 +1 @@ -Subproject commit db809395bf5739c895a24dc73960b9e9ab6468c5 +Subproject commit 47543e5df11bb4e7e9f7b653c65cee54d957b307 diff --git a/src/Flags.cpp b/src/Flags.cpp index 586727a0..e1749844 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -4,6 +4,10 @@ #include +LUAU_FASTFLAG(LuauSolverV2) +LUAU_FASTFLAG(LuauNewSolverPopulateTableLocations) +LUAU_FASTFLAG(LuauNewSolverPrePopulateClasses) + void registerFastFlags(std::unordered_map& fastFlags, ErrorCallback onError, ErrorCallback onWarning) { for (Luau::FValue* flag = Luau::FValue::list; flag; flag = flag->next) @@ -50,6 +54,13 @@ void registerFastFlags(std::unordered_map& fastFlags, { onWarning(std::string("Unknown FFlag: ") + key); } + + // These are required flags for internal functionality. + if (FFlag::LuauSolverV2) + { + FFlag::LuauNewSolverPopulateTableLocations.value = true; + FFlag::LuauNewSolverPrePopulateClasses.value = true; + } } void registerFastFlagsCLI(std::unordered_map& fastFlags) diff --git a/src/LuauExt.cpp b/src/LuauExt.cpp index 143d40be..4aadabf5 100644 --- a/src/LuauExt.cpp +++ b/src/LuauExt.cpp @@ -429,39 +429,6 @@ lsp::Diagnostic createParseErrorDiagnostic(const Luau::ParseError& error, const return diagnostic; } -// TODO: Dirty hack for invalid definitionModuleName on type aliases for solver v2! -// Remove after https://github.com/luau-lang/luau/issues/1441 is closed! -std::optional lookupTypeDefinitionModule(Luau::TypeId type) -{ - if (!FFlag::LuauSolverV2) - { - return Luau::getDefinitionModuleName(type); - } - - type = Luau::follow(type); - if (auto ttv = Luau::get(type); ttv && ttv->definitionModuleName.empty()) - { - if (type->owningArena && type->owningArena->owningModule) - return type->owningArena->owningModule->name; - } - - return Luau::getDefinitionModuleName(type); -} - -std::optional lookupTypeDefinitionModuleLocation(Luau::TypeId type, Luau::ModulePtr module) -{ - type = Luau::follow(type); - auto types = module->astResolvedTypes; - for (auto it = types.begin(); it != types.end(); ++it) - { - if (it->second == type) - { - return it->first->location; - } - } - return std::nullopt; -} - // Based on upstream, except we use containsClosed struct FindExprOrLocalClosed : public Luau::AstVisitor { diff --git a/src/include/LSP/LuauExt.hpp b/src/include/LSP/LuauExt.hpp index 8d65b74b..821c7df9 100644 --- a/src/include/LSP/LuauExt.hpp +++ b/src/include/LSP/LuauExt.hpp @@ -68,9 +68,6 @@ bool isRequire(const Luau::AstExpr* expr); bool isMethod(const Luau::FunctionType* ftv); bool isOverloadedMethod(Luau::TypeId ty); -std::optional lookupTypeDefinitionModule(Luau::TypeId type); -std::optional lookupTypeDefinitionModuleLocation(Luau::TypeId type, Luau::ModulePtr module); - struct FindImportsVisitor : public Luau::AstVisitor { private: diff --git a/src/operations/Completion.cpp b/src/operations/Completion.cpp index 681a587b..9f97653f 100644 --- a/src/operations/Completion.cpp +++ b/src/operations/Completion.cpp @@ -375,9 +375,9 @@ std::optional WorkspaceFolder::getDocumentationForAutocompleteEntry // parentTy might be an intersected type, find the actual base ttv auto followedTy = Luau::follow(*parentTy); if (auto propInformation = lookupProp(followedTy, name)) - definitionModuleName = lookupTypeDefinitionModule(propInformation->first); + definitionModuleName = Luau::getDefinitionModuleName(propInformation->first); else - definitionModuleName = lookupTypeDefinitionModule(followedTy); + definitionModuleName = Luau::getDefinitionModuleName(followedTy); } } } diff --git a/src/operations/Hover.cpp b/src/operations/Hover.cpp index 6e3bdaa8..ed7ff740 100644 --- a/src/operations/Hover.cpp +++ b/src/operations/Hover.cpp @@ -163,17 +163,6 @@ std::optional WorkspaceFolder::hover(const lsp::HoverParams& params) if (!typeFun) return std::nullopt; - // TODO: Dirty hack for invalid definitionModuleName on type aliases for solver v2! - // Remove after https://github.com/luau-lang/luau/issues/1441 is closed! - if (FFlag::LuauSolverV2 && typeFun->type) - { - auto followedType = Luau::follow(typeFun->type); - auto name = lookupTypeDefinitionModule(followedType); - auto location = lookupTypeDefinitionModuleLocation(followedType, module); - if (name && location) - documentationLocation = {name.value(), location.value()}; - } - typeAliasInformation = std::make_pair(typeName, *typeFun); type = typeFun->type; } @@ -189,7 +178,7 @@ std::optional WorkspaceFolder::hover(const lsp::HoverParams& params) if (prop.location.containsClosed(position)) { auto parentType = Luau::follow(*tableTy); - if (auto definitionModuleName = lookupTypeDefinitionModule(parentType)) + if (auto definitionModuleName = Luau::getDefinitionModuleName(parentType)) documentationLocation = {definitionModuleName.value(), prop.location}; auto resolvedProperty = lookupProp(parentType, prop.name.value); if (resolvedProperty) @@ -209,20 +198,7 @@ std::optional WorkspaceFolder::hover(const lsp::HoverParams& params) else if (auto local = exprOrLocal.getLocal()) // TODO: can we just use node here instead of also calling exprOrLocal? { type = scope->lookup(local); - // TODO: Dirty hack for invalid definitionModuleName on type aliases for solver v2! - // Remove after https://github.com/luau-lang/luau/issues/1441 is closed! - if (FFlag::LuauSolverV2 && type) - { - auto followedType = Luau::follow(*type); - auto name = lookupTypeDefinitionModule(followedType); - auto location = lookupTypeDefinitionModuleLocation(followedType, module); - if (name && location) - documentationLocation = {name.value(), location.value()}; - else - documentationLocation = {moduleName, local->location}; - } - else - documentationLocation = {moduleName, local->location}; + documentationLocation = {moduleName, local->location}; } else if (auto expr = exprOrLocal.getExpr()) { @@ -258,7 +234,7 @@ std::optional WorkspaceFolder::hover(const lsp::HoverParams& params) { auto [baseTy, prop] = propInformation.value(); type = prop.type(); - if (auto definitionModuleName = lookupTypeDefinitionModule(baseTy)) + if (auto definitionModuleName = Luau::getDefinitionModuleName(baseTy)) { if (prop.location) documentationLocation = {definitionModuleName.value(), prop.location.value()};