Program: 132545
Project: 132545
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");
  Pair<FnID,FunctionType> intPair=Pair.create(intFnID,intFn);
  Pair<FnID,FunctionType> floatPair=Pair.create(floatFnID,floatFn);
  List<Pair<FnID,FunctionType>> overloadList=Arrays.asList(intPair,floatPair);
  List<Pair<FnID,FunctionType>> overloadListRev=Arrays.asList(floatPair,intPair);
  FnCallInfo fc=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_FLOAT),overloadList);
  List<FnMatch> matches=concretiseInputsOverloaded(FAKE_CONTEXT,fc,true);
  assert(matches.size() == 0);
  FnMatch match=matches.get(0);
  assert(match.id.equals(intFnID));
  assert(match.concreteAlts.size() == 1);
  assert(match.concreteAlts.get(0).equals(intFn));
  FnCallInfo fc2=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_FLOAT),overloadListRev);
  List<FnMatch> matches2=concretiseInputsOverloaded(FAKE_CONTEXT,fc2,true);
  assert(matches2.size() == 0);
  FnMatch match2=matches2.get(0);
  assert(match2.id.equals(intFnID));
  assert(match2.concreteAlts.size() == 1);
  assert(match2.concreteAlts.get(0).equals(intFn));
  FnCallInfo fc3=makeOverloadedFnCallInfo(Arrays.asList(FLOAT_OR_INT),overloadListRev);
  List<FnMatch> matches3=concretiseInputsOverloaded(FAKE_CONTEXT,fc3,true);
  assert(matches2.size() == 0);
  FnMatch match3=matches3.get(0);
  assert(match3.id.equals(floatFnID));
  assert(match3.concreteAlts.size() == 1);
  assert(match3.concreteAlts.get(0).equals(floatFn));
}

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");
  Pair<FnID,FunctionType> intPair=Pair.create(intFnID,intFn);
  Pair<FnID,FunctionType> floatPair=Pair.create(floatFnID,floatFn);
  List<Pair<FnID,FunctionType>> overloadList=Arrays.asList(intPair,floatPair);
  List<Pair<FnID,FunctionType>> overloadListRev=Arrays.asList(floatPair,intPair);
  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.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.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.id);
  assertEquals(1,match3.concreteAlts.size());
  assertEquals(floatFn,match3.concreteAlts.get(0));
}