Program: 132603
Project: 132603
Buggy source:
/** 
 * Check that union args are handled correctly when they could match multiple overloads
 * @throws TypeMismatchException
 */
@Test public void testSelectOverloadUnion2() throws TypeMismatchException {
  FunctionType intFn=makeSimpleFT(Types.F_INT);
  FunctionType floatFn=makeSimpleFT(Types.F_FLOAT);
  FnID intFnID=new FnID("String_Node_Str","String_Node_Str");
  FnID floatFnID=new FnID("String_Node_Str","String_Node_Str");
  FnOverload intOverload=new FnOverload(intFnID,intFn);
  FnOverload floatOverload=new FnOverload(floatFnID,floatFn);
  List<FnOverload> overloadList=Arrays.asList(intOverload,floatOverload);
  List<FnOverload> overloadListRev=Arrays.asList(floatOverload,intOverload);
  FnCallInfo fc=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_FLOAT),overloadList);
  List<FnMatch> matches=concretiseInputsOverloaded(FAKE_CONTEXT,fc,true);
  assertEquals(1,matches.size());
  FnMatch match=matches.get(0);
  assertEquals(intFnID,match.overload.id);
  assertEquals(1,match.concreteAlts.size());
  assertEquals(intFn,match.concreteAlts.get(0));
  FnCallInfo fc2=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_FLOAT),overloadListRev);
  List<FnMatch> matches2=concretiseInputsOverloaded(FAKE_CONTEXT,fc2,true);
  assertEquals(1,matches2.size());
  FnMatch match2=matches2.get(0);
  assertEquals(intFnID,match2.overload.id);
  assertEquals(1,match2.concreteAlts.size());
  assertEquals(intFn,match2.concreteAlts.get(0));
  FnCallInfo fc3=makeOverloadedFnCallInfo(Arrays.asList(FLOAT_OR_INT),overloadListRev);
  List<FnMatch> matches3=concretiseInputsOverloaded(FAKE_CONTEXT,fc3,true);
  assertEquals(1,matches2.size());
  FnMatch match3=matches3.get(0);
  assertEquals(floatFnID,match3.overload.id);
  assertEquals(1,match3.concreteAlts.size());
  assertEquals(floatFn,match3.concreteAlts.get(0));
}

Fixed version (ground truth):
/** 
 * Check that union args are handled correctly when they could match multiple overloads
 * @throws TypeMismatchException
 */
@Test public void testSelectOverloadUnion2() throws TypeMismatchException {
  FunctionType intFn=makeSimpleFT(Types.F_INT);
  FunctionType floatFn=makeSimpleFT(Types.F_FLOAT);
  FnID intFnID=new FnID("String_Node_Str","String_Node_Str");
  FnID floatFnID=new FnID("String_Node_Str","String_Node_Str");
  FnOverload intOverload=new FnOverload(intFnID,intFn);
  FnOverload floatOverload=new FnOverload(floatFnID,floatFn);
  List<FnOverload> overloadList=Arrays.asList(intOverload,floatOverload);
  List<FnOverload> overloadListRev=Arrays.asList(floatOverload,intOverload);
  FnCallInfo fc=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_FLOAT),overloadList);
  FnMatch match=concretiseInputsOverloaded(FAKE_CONTEXT,fc);
  assertEquals(intFnID,match.overload.id);
  assertEquals(1,match.concreteAlts.size());
  assertEquals(intFn,match.concreteAlts.get(0));
  FnCallInfo fc2=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_FLOAT),overloadListRev);
  FnMatch match2=concretiseInputsOverloaded(FAKE_CONTEXT,fc2);
  assertEquals(intFnID,match2.overload.id);
  assertEquals(1,match2.concreteAlts.size());
  assertEquals(intFn,match2.concreteAlts.get(0));
  FnCallInfo fc3=makeOverloadedFnCallInfo(Arrays.asList(FLOAT_OR_INT),overloadListRev);
  FnMatch match3=concretiseInputsOverloaded(FAKE_CONTEXT,fc3);
  assertEquals(floatFnID,match3.overload.id);
  assertEquals(1,match3.concreteAlts.size());
  assertEquals(floatFn,match3.concreteAlts.get(0));
}