Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ref reification #462

Merged
merged 2 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions plugin/src/Reconciler/reify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function reifyInner(instanceMap, virtualInstances, id, parentInstance, unapplied
for propertyName, virtualValue in pairs(virtualInstance.Properties) do
-- Because refs may refer to instances that we haven't constructed yet,
-- we defer applying any ref properties until all instances are created.
if virtualValue.Type == "Ref" then
if next(virtualValue) == "Ref" then
table.insert(deferredRefs, {
id = id,
instance = instance,
Expand Down Expand Up @@ -136,23 +136,23 @@ function applyDeferredRefs(instanceMap, deferredRefs, unappliedPatch)
end

for _, entry in ipairs(deferredRefs) do
local virtualValue = entry.virtualValue
local _, refId = next(entry.virtualValue)

if virtualValue.Value == nil then
if refId == nil then
continue
end

local targetInstance = instanceMap.fromIds[virtualValue.Value]
local targetInstance = instanceMap.fromIds[refId]
if targetInstance == nil then
markFailed(entry.id, entry.propertyName, virtualValue)
markFailed(entry.id, entry.propertyName, entry.virtualValue)
continue
end

local ok = setProperty(entry.instance, entry.propertyName, targetInstance)
if not ok then
markFailed(entry.id, entry.propertyName, virtualValue)
markFailed(entry.id, entry.propertyName, entry.virtualValue)
end
end
end

return reify
return reify
7 changes: 2 additions & 5 deletions plugin/src/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ local strict = require(script.Parent.strict)

local RbxId = t.string

local ApiValue = t.interface({
Type = t.string,
Value = t.optional(t.any),
})
local ApiValue = t.keys(t.string)

local ApiInstanceMetadata = t.interface({
ignoreUnknownInstances = t.optional(t.boolean),
Expand Down Expand Up @@ -96,4 +93,4 @@ return strict("Types", {
VirtualInstance = ApiInstance,
VirtualMetadata = ApiInstanceMetadata,
VirtualValue = ApiValue,
})
})