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