mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-05 03:10:54 +01:00
Store class type definitionLocation
This commit is contained in:
parent
259e509038
commit
e83948b4db
5 changed files with 9 additions and 6 deletions
Analysis
|
@ -511,10 +511,11 @@ struct ClassType
|
|||
Tags tags;
|
||||
std::shared_ptr<ClassUserData> userData;
|
||||
ModuleName definitionModuleName;
|
||||
Location definitionLocation;
|
||||
std::optional<TableIndexer> indexer;
|
||||
|
||||
ClassType(Name name, Props props, std::optional<TypeId> parent, std::optional<TypeId> metatable, Tags tags,
|
||||
std::shared_ptr<ClassUserData> userData, ModuleName definitionModuleName)
|
||||
std::shared_ptr<ClassUserData> userData, ModuleName definitionModuleName, Location definitionLocation)
|
||||
: name(name)
|
||||
, props(props)
|
||||
, parent(parent)
|
||||
|
@ -522,11 +523,12 @@ struct ClassType
|
|||
, tags(tags)
|
||||
, userData(userData)
|
||||
, definitionModuleName(definitionModuleName)
|
||||
, definitionLocation(definitionLocation)
|
||||
{
|
||||
}
|
||||
|
||||
ClassType(Name name, Props props, std::optional<TypeId> parent, std::optional<TypeId> metatable, Tags tags,
|
||||
std::shared_ptr<ClassUserData> userData, ModuleName definitionModuleName, std::optional<TableIndexer> indexer)
|
||||
std::shared_ptr<ClassUserData> userData, ModuleName definitionModuleName, Location definitionLocation, std::optional<TableIndexer> indexer)
|
||||
: name(name)
|
||||
, props(props)
|
||||
, parent(parent)
|
||||
|
@ -534,6 +536,7 @@ struct ClassType
|
|||
, tags(tags)
|
||||
, userData(userData)
|
||||
, definitionModuleName(definitionModuleName)
|
||||
, definitionLocation(definitionLocation)
|
||||
, indexer(indexer)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1341,7 +1341,7 @@ ControlFlow ConstraintGenerator::visit(const ScopePtr& scope, AstStatDeclareClas
|
|||
|
||||
Name className(declaredClass->name.value);
|
||||
|
||||
TypeId classTy = arena->addType(ClassType(className, {}, superTy, std::nullopt, {}, {}, module->name));
|
||||
TypeId classTy = arena->addType(ClassType(className, {}, superTy, std::nullopt, {}, {}, module->name, declaredClass->location));
|
||||
ClassType* ctv = getMutable<ClassType>(classTy);
|
||||
|
||||
TypeId metaTy = arena->addType(TableType{TableState::Sealed, scope->level, scope.get()});
|
||||
|
|
|
@ -118,7 +118,7 @@ static TypeId shallowClone(TypeId ty, TypeArena& dest, const TxnLog* log, bool a
|
|||
{
|
||||
if (alwaysClone)
|
||||
{
|
||||
ClassType clone{a.name, a.props, a.parent, a.metatable, a.tags, a.userData, a.definitionModuleName, a.indexer};
|
||||
ClassType clone{a.name, a.props, a.parent, a.metatable, a.tags, a.userData, a.definitionModuleName, a.definitionLocation, a.indexer};
|
||||
return dest.addType(std::move(clone));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -964,7 +964,7 @@ BuiltinTypes::BuiltinTypes()
|
|||
, threadType(arena->addType(Type{PrimitiveType{PrimitiveType::Thread}, /*persistent*/ true}))
|
||||
, bufferType(arena->addType(Type{PrimitiveType{PrimitiveType::Buffer}, /*persistent*/ true}))
|
||||
, functionType(arena->addType(Type{PrimitiveType{PrimitiveType::Function}, /*persistent*/ true}))
|
||||
, classType(arena->addType(Type{ClassType{"class", {}, std::nullopt, std::nullopt, {}, {}, {}}, /*persistent*/ true}))
|
||||
, classType(arena->addType(Type{ClassType{"class", {}, std::nullopt, std::nullopt, {}, {}, {}, {}}, /*persistent*/ true}))
|
||||
, tableType(arena->addType(Type{PrimitiveType{PrimitiveType::Table}, /*persistent*/ true}))
|
||||
, emptyTableType(arena->addType(Type{TableType{TableState::Sealed, TypeLevel{}, nullptr}, /*persistent*/ true}))
|
||||
, trueType(arena->addType(Type{SingletonType{BooleanSingleton{true}}, /*persistent*/ true}))
|
||||
|
|
|
@ -1733,7 +1733,7 @@ void TypeChecker::prototype(const ScopePtr& scope, const AstStatDeclareClass& de
|
|||
|
||||
Name className(declaredClass.name.value);
|
||||
|
||||
TypeId classTy = addType(ClassType(className, {}, superTy, std::nullopt, {}, {}, currentModule->name));
|
||||
TypeId classTy = addType(ClassType(className, {}, superTy, std::nullopt, {}, {}, currentModule->name, declaredClass.location));
|
||||
ClassType* ctv = getMutable<ClassType>(classTy);
|
||||
TypeId metaTy = addType(TableType{TableState::Sealed, scope->level});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue