From 306db6fb598be5f754f4b8c9e11426cd563b6126 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Wed, 11 Jan 2023 15:53:34 +0000 Subject: [PATCH] Track table definition location --- Analysis/include/Luau/Type.h | 1 + Analysis/src/Instantiation.cpp | 1 + Analysis/src/TypeInfer.cpp | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/Analysis/include/Luau/Type.h b/Analysis/include/Luau/Type.h index 734d40ea..9d4d9940 100644 --- a/Analysis/include/Luau/Type.h +++ b/Analysis/include/Luau/Type.h @@ -375,6 +375,7 @@ struct TableType std::vector instantiatedTypeParams; std::vector instantiatedTypePackParams; ModuleName definitionModuleName; + Location definitionLocation; std::optional boundTo; Tags tags; diff --git a/Analysis/src/Instantiation.cpp b/Analysis/src/Instantiation.cpp index 209ba7e9..912c4155 100644 --- a/Analysis/src/Instantiation.cpp +++ b/Analysis/src/Instantiation.cpp @@ -116,6 +116,7 @@ TypeId ReplaceGenerics::clean(TypeId ty) { TableType clone = TableType{ttv->props, ttv->indexer, level, scope, TableState::Free}; clone.definitionModuleName = ttv->definitionModuleName; + clone.definitionLocation = ttv->definitionLocation; return addType(std::move(clone)); } else diff --git a/Analysis/src/TypeInfer.cpp b/Analysis/src/TypeInfer.cpp index 5c1ee388..25fe37ec 100644 --- a/Analysis/src/TypeInfer.cpp +++ b/Analysis/src/TypeInfer.cpp @@ -1535,6 +1535,7 @@ void TypeChecker::check(const ScopePtr& scope, const AstStatTypeAlias& typealias // This is a shallow clone, original recursive links to self are not updated TableType clone = TableType{ttv->props, ttv->indexer, ttv->level, ttv->state}; clone.definitionModuleName = ttv->definitionModuleName; + clone.definitionLocation = ttv->definitionLocation; clone.name = name; for (auto param : binding->typeParams) @@ -2370,6 +2371,7 @@ TypeId TypeChecker::checkExprTable( TableState state = TableState::Unsealed; TableType table = TableType{std::move(props), indexer, scope->level, state}; table.definitionModuleName = currentModuleName; + table.definitionLocation = expr.location; return addType(table); } @@ -5371,6 +5373,7 @@ TypeId TypeChecker::resolveTypeWorker(const ScopePtr& scope, const AstType& anno TableType ttv{props, tableIndexer, scope->level, TableState::Sealed}; ttv.definitionModuleName = currentModuleName; + ttv.definitionLocation = annotation.location; return addType(std::move(ttv)); } else if (const auto& func = annotation.as()) @@ -5572,6 +5575,7 @@ TypeId TypeChecker::instantiateTypeFun(const ScopePtr& scope, const TypeFun& tf, ttv->instantiatedTypeParams = typeParams; ttv->instantiatedTypePackParams = typePackParams; ttv->definitionModuleName = currentModuleName; + ttv->definitionLocation = location; } return instantiated;