Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Make tuples with different arguments different types #198

Merged
merged 3 commits into from
Oct 5, 2018
Merged
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions src/Analysis/Engine/Impl/Values/Protocols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,13 @@ protected override Protocol UnionMergeTypes(Protocol p) {
}

class TupleProtocol : IterableProtocol {
internal readonly IAnalysisSet[] _values;
private readonly IAnalysisSet[] _values;

public TupleProtocol(ProtocolInfo self, IEnumerable<IAnalysisSet> values) : base(self, AnalysisSet.UnionAll(values)) {
_values = values.Select(s => s.AsUnion(1)).ToArray();

var argTypes = _values.SelectMany(e => e.Select(v => v is IHasQualifiedName qn ? qn.FullyQualifiedName : v.ShortDescription));
Name = "tuple[{0}]".FormatInvariant(string.Join(", ", argTypes));
}

protected override void EnsureMembers(IDictionary<string, IAnalysisSet> members) {
Expand All @@ -415,7 +418,7 @@ public override IAnalysisSet GetIndex(Node node, AnalysisUnit unit, IAnalysisSet
return AnalysisSet.UnionAll(constants.Select(GetItem));
}

public override string Name => "tuple";
public override string Name { get; }

public override IEnumerable<KeyValuePair<string, string>> GetRichDescription() {
if (_values.Any()) {
Expand Down