@Test public void shouldBindStructMatch() { VariableType t = t(0); Scope scope = mock(Scope.class); when(scope.reserveType()).thenReturn(t); PatternMatch struct = struct("(,)", t, asList( field("_0", t, capture("a", t(1))), field("_1", t, capture("b", t(2))) )); assertThat(struct.bind(arg("#0", t), scope), is(struct(arg("#0", t), "(,)", t, asList( field("_0", t, capture(access(arg("#0", t), "_0", t), "a", t(1))), field("_1", t, capture(access(arg("#0", t), "_1", t), "b", t(2))) )))); }
@Override public PatternMatch bind(Value argument, Scope scope) { return withArgument(argument).map(field -> field.bind(argument, scope)); }
StructMatch extends PatternMatch { @Override public PatternMatch bind(Value argument, Scope scope) { return withArgument(argument).map(field -> field.bind(argument, scope)); } }
StructMatch extends PatternMatch { @Override public PatternMatch bind(Value argument, Scope scope) { return withArgument(argument).map(field -> field.bind(argument, scope)); } StructMatch(SourceLocation sourceLocation, Optional<Value> argument, Symbol constructor, Type type, List<StructField> fields); }
StructMatch extends PatternMatch { @Override public PatternMatch bind(Value argument, Scope scope) { return withArgument(argument).map(field -> field.bind(argument, scope)); } StructMatch(SourceLocation sourceLocation, Optional<Value> argument, Symbol constructor, Type type, List<StructField> fields); static Builder builder(); @Override PatternMatch accumulateDependencies(DependencyAccumulator state); @Override PatternMatch accumulateNames(NameAccumulator state); @Override PatternMatch bind(Value argument, Scope scope); @Override PatternMatch bindMethods(TypeChecker state); @Override PatternMatch bindTypes(TypeChecker state); @Override PatternMatch checkTypes(TypeChecker state); @Override PatternMatch qualifyNames(NameQualifier state); @Override void reducePatterns(PatternReducer reducer); @Override StructMatch withType(Type type); }
StructMatch extends PatternMatch { @Override public PatternMatch bind(Value argument, Scope scope) { return withArgument(argument).map(field -> field.bind(argument, scope)); } StructMatch(SourceLocation sourceLocation, Optional<Value> argument, Symbol constructor, Type type, List<StructField> fields); static Builder builder(); @Override PatternMatch accumulateDependencies(DependencyAccumulator state); @Override PatternMatch accumulateNames(NameAccumulator state); @Override PatternMatch bind(Value argument, Scope scope); @Override PatternMatch bindMethods(TypeChecker state); @Override PatternMatch bindTypes(TypeChecker state); @Override PatternMatch checkTypes(TypeChecker state); @Override PatternMatch qualifyNames(NameQualifier state); @Override void reducePatterns(PatternReducer reducer); @Override StructMatch withType(Type type);  }