Beispiel #1
0
        private Tests MakeTestsAndBindingsForListPattern(BoundDagTemp input, BoundListPattern list, out BoundDagTemp output, ArrayBuilder <BoundPatternBinding> bindings)
        {
            Debug.Assert(input.Type.IsErrorType() || list.HasErrors || list.InputType.IsErrorType() ||
                         input.Type.Equals(list.InputType, TypeCompareKind.AllIgnoreOptions) &&
                         input.Type.StrippedType().Equals(list.NarrowedType, TypeCompareKind.ConsiderEverything) &&
                         list.Subpatterns.Count(p => p.Kind == BoundKind.SlicePattern) == (list.HasSlice ? 1 : 0) &&
                         list.LengthAccess is not null);

            var syntax      = list.Syntax;
            var subpatterns = list.Subpatterns;
            var tests       = ArrayBuilder <Tests> .GetInstance(4 + subpatterns.Length * 2);

            output = input = MakeConvertToType(input, list.Syntax, list.NarrowedType, isExplicitTest: false, tests);

            if (list.HasErrors)
            {
                tests.Add(new Tests.One(new BoundDagTypeTest(list.Syntax, ErrorType(), input, hasErrors: true)));
            }
            else if (list.HasSlice &&
                     subpatterns.Length == 1 &&
                     subpatterns[0] is BoundSlicePattern {
                Pattern : null
            })
 public override BoundNode VisitListPattern(BoundListPattern node)
 {
     VisitAndUnsplitAll(node.Subpatterns);
     Visit(node.VariableAccess);
     return(null);
 }