Repository navigation
Compiler: a closure is used only where its captures and delegate are - #2585
Merged
Merged
Conversation
A closure's type is its delegate's, from the delegate's project (corlib
for most), and IsTypeAccessible and IsTypeUsed checked a tuple's fields
and a delegate's signature but neither for a closure: its captures were
never scanned, and as a BfClosureType is no BfDelegateType it has no
delegate info of its own. So a closure capturing a type of a project an
executable does not reference passed as accessible, its module was
marked used whenever a used module reached it, and the executable's
vdata named it: the link failed on the other project's symbols.
namespace SharedGlobals
{
static // in LibC, which TestsB does not reference
{
public static int32 LibCCaptures(LibCCaptured captured)
{
delegate int32() get = scope () => captured.mValue;
return get();
}
}
}
With LibA holding globals of the same namespace and TestsB calling them,
TestsB failed to link on LibCCaptured.__Equals. A closure now counts as
accessible and used only when its captured fields' types and its source
delegate are.
Seen in a game engine where every executable that did not reference its
GUI library failed to link once a second GUI library added globals to the
GUI's namespace.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A closure's type is its delegate's, from the delegate's project (corlib for most), and IsTypeAccessible and IsTypeUsed checked a tuple's fields and a delegate's signature but neither for a closure: its captures were never scanned, and as a BfClosureType is no BfDelegateType it has no delegate info of its own. So a closure capturing a type of a project an executable does not reference passed as accessible, its module was marked used whenever a used module reached it, and the executable's vdata named it: the link failed on the other project's symbols.
With LibA holding globals of the same namespace and TestsB calling them, TestsB failed to link on LibCCaptured.__Equals. A closure now counts as accessible and used only when its captured fields' types and its source delegate are.
Seen in a game engine where every executable that did not reference its GUI library failed to link once a second GUI library added globals to the GUI's namespace.