Skip to content

Commit

Permalink
Rollback of null handling in RowAtom.
Browse files Browse the repository at this point in the history
  • Loading branch information
ygra committed Aug 15, 2020
1 parent b6582a3 commit ff1bbfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/WpfMath/Atoms/RowAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ static RowAtom()
ligatureKernChangeSet.Set((int)TexAtomType.Punctuation, true);
}

public RowAtom(SourceSpan? source, Atom baseAtom)
public RowAtom(SourceSpan? source, Atom? baseAtom)
: this(
source,
baseAtom is RowAtom
? (IEnumerable<Atom>) ((RowAtom) baseAtom).Elements
: new[] { baseAtom })
: new[] { baseAtom! }) // Nullable: Seems to require some sort of non-null assertion to make the analyzer happy
{
}

Expand All @@ -56,9 +56,10 @@ private RowAtom(SourceSpan? source, DummyAtom? previousAtom, ReadOnlyCollection<
this.Elements = elements;
}

internal RowAtom(SourceSpan? source, IEnumerable<Atom> elements)
internal RowAtom(SourceSpan? source, IEnumerable<Atom?> elements)
: base(source) =>
this.Elements = elements.ToList().AsReadOnly();
this.Elements = elements.Where(x => x != null).ToList().AsReadOnly()!;
// TODO[F]: Fix this with C# 8 migration: there shouldn't be nullable atoms in this collection

public DummyAtom? PreviousAtom { get; }

Expand Down
2 changes: 1 addition & 1 deletion src/WpfMath/Atoms/StyledAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class StyledAtom : Atom, IRow
public StyledAtom(SourceSpan? source, Atom? atom, Brush? backgroundColor, Brush? foregroundColor)
: base(source)
{
this.RowAtom = new RowAtom(source, atom!); // Nullable TODO: This definitely needs null checking and is currently wrong
this.RowAtom = new RowAtom(source, atom);
this.Background = backgroundColor;
this.Foreground = foregroundColor;
}
Expand Down

0 comments on commit ff1bbfa

Please sign in to comment.