Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f704291
Re-add static interface trimming with more testing
jtschuster May 9, 2022
68c530d
Add static interface tests for library mode
jtschuster May 12, 2022
97cd617
Add sanity check for overrides
jtschuster May 12, 2022
8190bf7
Add sanity check for overrides
jtschuster May 12, 2022
9a5fe0f
Merge branch 'main' into overrideSanityCheck
jtschuster May 12, 2022
3a560d4
Merge branch 'overrideSanityCheck' into staticInterfacesBack
jtschuster May 12, 2022
733bf90
Update comment on override removal in sweep step
jtschuster May 12, 2022
47104d9
Add attributes
jtschuster May 12, 2022
c2f4fd1
formatting
jtschuster May 12, 2022
3d577ce
formatting
jtschuster May 12, 2022
8ac16bb
Merge branch 'overrideSanityCheck' into staticInterfacesBack
jtschuster May 13, 2022
cccca4c
Modify override removal logic and update comment
jtschuster May 13, 2022
c380027
Mark override on explicit implementation
jtschuster May 13, 2022
4813047
Tweak override removal comment
jtschuster May 13, 2022
332e79f
wip
jtschuster May 13, 2022
9f64a32
Merge branch 'main' into staticInterfacesBack
jtschuster May 25, 2022
9d27c3b
Merge remote-tracking branch 'upstream/main' into staticInterfacesBack
jtschuster May 25, 2022
7f1064d
Choose correct merge conflict
jtschuster May 25, 2022
15db395
use FullName in comparison
jtschuster May 26, 2022
1751697
wip
jtschuster Jun 1, 2022
b10cd5f
Update docs/removal-behavior.md
jtschuster Jun 1, 2022
e3fbf12
Add explanation for workaround to remove interface implementation
jtschuster Jun 1, 2022
098cb24
Merge branch 'staticInterfacesBack' of https://github.com/jtschuster/…
jtschuster Jun 1, 2022
7467d82
wip
jtschuster Jun 2, 2022
4efa5f2
Mark static interface implmentations in ProcessOverride
jtschuster Jun 2, 2022
c3a26ca
Format and update comment
jtschuster Jun 2, 2022
62e3cc8
Use separate list for static interface methods
jtschuster Jun 3, 2022
4359792
Add clarifying comments
jtschuster Jun 3, 2022
060345e
Roll early exit case into function
jtschuster Jun 3, 2022
a050fdf
Move check back outside of interface override method
jtschuster Jun 7, 2022
95df541
formatting
jtschuster Jun 7, 2022
2b7a7cc
Use Override pair to store logic for IsStaticInterfaceMethodPair
jtschuster Jun 7, 2022
c00e1d1
Formatting
jtschuster Jun 8, 2022
358b010
Move interfaceImpl marking out of ProcessOverride
jtschuster Jun 13, 2022
5672f0f
Merge remote-tracking branch 'upstream/main' into staticInterfacesBack
jtschuster Jun 14, 2022
432375d
PR Feedback
jtschuster Jun 14, 2022
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
Prev Previous commit
Next Next commit
Modify override removal logic and update comment
  • Loading branch information
jtschuster committed May 13, 2022
commit cccca4c14a8ab0c7adaeeffac960e2e66cc22d85
22 changes: 12 additions & 10 deletions src/linker/Linker.Steps/SweepStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,17 @@ void SweepOverrides (MethodDefinition method)
// We can't rely on the context resolution cache anymore, since it may remember methods which are already removed
// So call the direct Resolve here and avoid the cache.
// We want to remove a method from the list of Overrides if:
// Resolve() is null. This can happen for a couple of reasons, but it indicates the method isn't in the final assembly.
// Resolve() is null
// This can happen for a couple of reasons, but it indicates the method isn't in the final assembly.
// Resolve also may return a removed value if method.Overrides[i] is a MethodDefinition. In this case, Resolve short circuits and returns `this`.
// OR
// ShouldRemove(ov) returns false
// AND ov.DeclaringType is not null
// AND ov.DeclaringType is in a `link` scope (i.e. !IgnoreScope).
// If ShouldRemove(ov) returns false we are removing the method from the assembly if it is a `link` assembly.
// ov.DeclaringType may be null if `ov` is a MethodDefinition already and just returns `this` even though it shouldn't exist.
// If the override is not in a `link` scope, ShouldRemove may return true even though the method will not be removed.
if (method.Overrides[i].Resolve () is not MethodDefinition ov || ShouldRemove (ov) && ov.DeclaringType is not null && !IgnoreScope (ov.DeclaringType.Scope))
// ov.DeclaringType is null
// ov.DeclaringType may be null if Resolve short circuited and returned a removed method. In this case, we want to remove the override.
// OR
// ov is in a `link` scope and is unmarked
// We need to make sure the override is in a link scope.
// Only things in a link scope are marked, so ShouldRemove is only valid for items in a `link` scope.
if (method.Overrides[i].Resolve () is not MethodDefinition ov || ov.DeclaringType is null || (IsLinkScope (ov.DeclaringType.Scope) && ShouldRemove (ov)))
method.Overrides.RemoveAt (i);
else
i++;
Expand All @@ -493,10 +495,10 @@ void SweepOverrides (MethodDefinition method)
/// <summary>
/// Returns true if the assembly of the <paramref name="scope"></paramref> is not set to link (e.g. action=copy is set for that assembly)
/// </summary>
private bool IgnoreScope (IMetadataScope scope)
private bool IsLinkScope (IMetadataScope scope)
{
AssemblyDefinition? assembly = Context.Resolve (scope);
return assembly != null && Annotations.GetAction (assembly) != AssemblyAction.Link;
return assembly != null && Annotations.GetAction (assembly) == AssemblyAction.Link;
}

void SweepDebugInfo (Collection<MethodDefinition> methods)
Expand Down