Skip to content

Commit 85d0c6c

Browse files
SQ fix
1 parent 2cc51f9 commit 85d0c6c

2 files changed

Lines changed: 14 additions & 24 deletions

File tree

SysML2.NET.Semantics/Implied/ImpliedRelationshipProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ public class ImpliedRelationshipProvider : IImpliedRelationshipProvider
8686
/// </summary>
8787
/// <remarks>
8888
/// Every input is fixed for the lifetime of the instance, so the answer is too. Computing it per
89-
/// access allocated a fresh list on a property that reads as a field — and <see cref="IsCoveredByRule" />
90-
/// consults it per constraint, so the copy was on a hot path rather than an occasional one.
89+
/// access allocated a fresh list on a property that reads as a field — and
90+
/// <see cref="IsConstraintCovered" /> consults it per constraint, so the copy was on a hot path
91+
/// rather than an occasional one.
9192
/// </remarks>
9293
private readonly IReadOnlyList<string> notCoveredConstraints;
9394

SysML2.NET.Serializer.TextualNotation/Writers/NameResolutionCache.cs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,11 +1539,8 @@ private List<IMembership> QueryBindingMemberships(INamespace scope, bool visible
15391539

15401540
foreach (var impliedGeneral in this.QueryImpliedGeneralClosure(type, declaredSupertypes))
15411541
{
1542-
if (impliedGeneral is INamespace impliedGeneralAsNamespace)
1543-
{
1544-
memberships.AddRange(QueryOwnedMembershipsSafe(impliedGeneralAsNamespace)
1545-
.Where(ownedMember => ownedMember.Visibility != VisibilityKind.Private && PassesVisibilityFilter(ownedMember, visibleOnly)));
1546-
}
1542+
memberships.AddRange(QueryOwnedMembershipsSafe(impliedGeneral)
1543+
.Where(ownedMember => ownedMember.Visibility != VisibilityKind.Private && PassesVisibilityFilter(ownedMember, visibleOnly)));
15471544

15481545
memberships.AddRange(QueryInheritedMembershipsSafe(impliedGeneral).Where(inheritedMember => PassesVisibilityFilter(inheritedMember, visibleOnly)));
15491546
}
@@ -2207,10 +2204,7 @@ private void BuildInheritedEntries(IType type, Dictionary<string, HashSet<IEleme
22072204
// `pending` feeds INDEX construction only — it is not the traversal that emits output — so
22082205
// indexing the general as a scope in its own right keeps the fix lookup-only while making
22092206
// the names it owns resolvable.
2210-
if (impliedGeneral is INamespace impliedGeneralAsNamespace)
2211-
{
2212-
pending.Enqueue((impliedGeneralAsNamespace, isGlobal));
2213-
}
2207+
pending.Enqueue((impliedGeneral, isGlobal));
22142208

22152209
AddImpliedLookupEntries(impliedGeneral, index, isGlobal);
22162210
}
@@ -2346,22 +2340,17 @@ private List<IType> QueryImpliedGeneralClosure(IType type, List<IType> declaredS
23462340
/// <param name="isGlobal">Whether the owning scope is reached through the global namespace.</param>
23472341
private static void AddImpliedLookupEntries(IType impliedGeneral, Dictionary<string, HashSet<IElement>> index, bool isGlobal)
23482342
{
2349-
var contributed = new List<IMembership>();
2350-
2351-
switch (impliedGeneral)
2343+
if (impliedGeneral == null)
23522344
{
2353-
case null:
2354-
return;
2355-
case INamespace impliedGeneralAsNamespace:
2356-
// Stricter than the declared-supertype walk on purpose: an implied general is reached
2357-
// without any authored relationship, so its private internals are never exposed, even in a
2358-
// non-global scope where PassesVisibilityFilter alone would admit them.
2359-
contributed.AddRange(impliedGeneralAsNamespace.ownedMembership
2360-
.Where(ownedMember => ownedMember.Visibility != VisibilityKind.Private));
2361-
2362-
break;
2345+
return;
23632346
}
23642347

2348+
// Stricter than the declared-supertype walk on purpose: an implied general is reached without
2349+
// any authored relationship, so its private internals are never exposed, even in a non-global
2350+
// scope where PassesVisibilityFilter alone would admit them.
2351+
var contributed = new List<IMembership>(impliedGeneral.ownedMembership
2352+
.Where(ownedMember => ownedMember.Visibility != VisibilityKind.Private));
2353+
23652354
try
23662355
{
23672356
contributed.AddRange(impliedGeneral.inheritedMembership);

0 commit comments

Comments
 (0)