Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 3e3030f

Browse files
authored
Fix nullref in SpecializedNamespace and arg-null ProtocolInfo dict access (microsoft#451)
Fixes microsoft#449. Also fixes an ArgumentNullException in a dictionary TryGetValue in ProtocolInfo. I'm not sure why that one is happening, but it's also showing up as frequently as the SpecializedNamespace issue.
1 parent 85c1ed7 commit 3e3030f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Analysis/Engine/Impl/Values/ProtocolInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ internal override void AddReference(Node node, AnalysisUnit analysisUnit)
134134

135135
public override IEnumerable<ILocationInfo> Locations {
136136
get {
137-
if (!_references.TryGetValue(DeclaringModule, out var defns)) {
137+
if (DeclaringModule == null || !_references.TryGetValue(DeclaringModule, out var defns)) {
138138
return Enumerable.Empty<ILocationInfo>();
139139
}
140140
return defns.Definitions.Select(l => l.GetLocationInfo()).ExcludeDefault();

src/Analysis/Engine/Impl/Values/SpecializedNamespace.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ public override bool IsOfType(IAnalysisSet klass) {
209209
return _original.IsOfType(klass);
210210
}
211211

212-
public override IEnumerable<ILocationInfo> Locations => _original?.Locations?.MaybeEnumerate();
212+
public override IEnumerable<ILocationInfo> Locations => _original?.Locations.MaybeEnumerate();
213213

214214
public override string Name => _original == null ? base.Name : _original.Name;
215215

216-
public override IEnumerable<OverloadResult> Overloads =>_original.Overloads.MaybeEnumerate();
216+
public override IEnumerable<OverloadResult> Overloads => _original?.Overloads.MaybeEnumerate();
217217

218218
public override IPythonType PythonType => _original?.PythonType;
219219

220-
internal override IEnumerable<ILocationInfo> References => _original.References?.MaybeEnumerate();
220+
internal override IEnumerable<ILocationInfo> References => _original?.References.MaybeEnumerate();
221221

222222
public override PythonMemberType MemberType => _original == null ? PythonMemberType.Unknown : _original.MemberType;
223223

0 commit comments

Comments
 (0)