@Test public void shouldBubbleUpMethodBindingWithPattern() { compile( "module scotch.test", "import scotch.data.num", "fn a b = a + b" ); String num = "scotch.data.num.Num"; Type t = t(12, asList(num)); InstanceType instance = instance(num, t(12)); shouldNotHaveErrors(); shouldHaveValue("scotch.test.fn", fn("scotch.test.(fn#0)", asList(arg("#0i", instance), arg("#0", t), arg("#1", t)), scope("scotch.test.(fn#0#0)", let(t, "a", arg("#0", t), let(t, "b", arg("#1", t), apply( apply( apply( method("scotch.data.num.(+)", asList(instance), fn(instance, fn(t, fn(t, t)))), arg("#0i", instance), fn(t, fn(t, t)) ), arg("a", t), fn(t, t) ), arg("b", t), t )))) )); }
public Scope scope() { return scopes.peek(); }
TypeChecker implements TypeScope { public Scope scope() { return scopes.peek(); } }
TypeChecker implements TypeScope { public Scope scope() { return scopes.peek(); } TypeChecker(DefinitionGraph graph); }
TypeChecker implements TypeScope { public Scope scope() { return scopes.peek(); } TypeChecker(DefinitionGraph graph); static SyntaxError ambiguousTypeInstance(Symbol typeClass, List<Type> parameters, Set<TypeInstanceDescriptor> typeInstances, SourceLocation location); static SyntaxError typeInstanceNotFound(Symbol typeClass, List<Type> parameters, SourceLocation location); void addLocal(Symbol symbol); Definition bind(ValueDefinition definition); @Override Unification bind(VariableType variableType, Type targetType); void capture(Symbol symbol); DefinitionGraph checkTypes(); Optional<DataTypeDescriptor> getDataType(Type type); Optional<DataConstructorDescriptor> getDataConstructor(Symbol symbol); T enclose(T scoped, Supplier<T> supplier); void error(SyntaxError error); @Override void extendContext(Type type, Set<Symbol> additionalContext); Optional<Value> findArgument(InstanceType type); Value findInstance(Method method, InstanceType instanceType); @Override void generalize(Type type); @Override Type generate(Type type); @Override Set<Symbol> getContext(Type type); Optional<Type> getDataConstructorType(Symbol constructor); Optional<Definition> getDefinition(DefinitionReference reference); Optional<Type> getRawValue(ValueReference valueRef); @Override Type getTarget(Type type); Type getType(ValueDefinition definition); @Override void implement(Symbol typeClass, SumType type); @Override boolean isBound(VariableType variableType); @Override boolean isGeneric(VariableType variableType); @Override boolean isImplemented(Symbol typeClass, SumType type); Definition keep(Definition definition); List<DefinitionReference> map(List<DefinitionReference> references, BiFunction<? super Definition, TypeChecker, ? extends Definition> function); void redefine(ValueDefinition definition); void redefine(ValueSignature signature); VariableType reserveType(); Scope scope(); T scoped(T scoped, Supplier<T> supplier); @Override void specialize(Type type); List<Value> bindMethods(List<Value> values); @SuppressWarnings("unchecked") List<T> bindTypes(List<T> values); List<Value> checkTypes(List<Value> values); }
TypeChecker implements TypeScope { public Scope scope() { return scopes.peek(); } TypeChecker(DefinitionGraph graph); static SyntaxError ambiguousTypeInstance(Symbol typeClass, List<Type> parameters, Set<TypeInstanceDescriptor> typeInstances, SourceLocation location); static SyntaxError typeInstanceNotFound(Symbol typeClass, List<Type> parameters, SourceLocation location); void addLocal(Symbol symbol); Definition bind(ValueDefinition definition); @Override Unification bind(VariableType variableType, Type targetType); void capture(Symbol symbol); DefinitionGraph checkTypes(); Optional<DataTypeDescriptor> getDataType(Type type); Optional<DataConstructorDescriptor> getDataConstructor(Symbol symbol); T enclose(T scoped, Supplier<T> supplier); void error(SyntaxError error); @Override void extendContext(Type type, Set<Symbol> additionalContext); Optional<Value> findArgument(InstanceType type); Value findInstance(Method method, InstanceType instanceType); @Override void generalize(Type type); @Override Type generate(Type type); @Override Set<Symbol> getContext(Type type); Optional<Type> getDataConstructorType(Symbol constructor); Optional<Definition> getDefinition(DefinitionReference reference); Optional<Type> getRawValue(ValueReference valueRef); @Override Type getTarget(Type type); Type getType(ValueDefinition definition); @Override void implement(Symbol typeClass, SumType type); @Override boolean isBound(VariableType variableType); @Override boolean isGeneric(VariableType variableType); @Override boolean isImplemented(Symbol typeClass, SumType type); Definition keep(Definition definition); List<DefinitionReference> map(List<DefinitionReference> references, BiFunction<? super Definition, TypeChecker, ? extends Definition> function); void redefine(ValueDefinition definition); void redefine(ValueSignature signature); VariableType reserveType(); Scope scope(); T scoped(T scoped, Supplier<T> supplier); @Override void specialize(Type type); List<Value> bindMethods(List<Value> values); @SuppressWarnings("unchecked") List<T> bindTypes(List<T> values); List<Value> checkTypes(List<Value> values);  }