Skip to content

Commit

Permalink
Merge branch 'xtclang:master' into xunit
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed May 27, 2023
2 parents 08d442d + 48af114 commit dc1a614
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ public static ExceptionHandle invalidType(Frame frame, String sMsg)

public static ExceptionHandle mutableObject(Frame frame, TypeConstant type)
{
return illegalArgument(frame, "Mutable object of type \" "
+ type.removeAccess().getValueString()
type = type.removeAccess().
resolveGenerics(frame.poolContext(), frame.getGenericsResolver(true));
return illegalArgument(frame, "Mutable object of type \" " + type.getValueString()
+ "\" cannot be used for a service call");
}

Expand Down
28 changes: 19 additions & 9 deletions manualTests/src/main/x/reflect.x
Original file line number Diff line number Diff line change
Expand Up @@ -375,23 +375,33 @@ module TestReflection

console.print("\n** testBind");

function void (Int, String) log =
(i, v) -> console.print($"[{i}] {v}");
function void (Int, String, Boolean) log =
(i, v, f) -> console.print($"[{i}] {v} {f}");

Parameter<Int> param0 = log.params[0].as(Parameter<Int>);
Parameter<String> param1 = log.params[1].as(Parameter<String>);
Parameter<Int> param0 = log.params[0].as(Parameter<Int>);
Parameter<String> param1 = log.params[1].as(Parameter<String>);
Parameter<Boolean> param2 = log.params[2].as(Parameter<Boolean>);

// single bind
function void (Int) hello = log.bind(param1, "hello").as(function void (Int));
hello(0);
function void (Int, Boolean) hello = log.bind(param1, "hello").as(function void (Int, Boolean));
hello(0, True);

// multi bind
// multi partial bind
Map<Parameter, Object> paramsPartial = new ListMap();
paramsPartial.put(param0, 1);
paramsPartial.put(param1, "world");

function void (Boolean) fnPartial = log.bind(paramsPartial).as(function void (Boolean));
fnPartial(True);

// multi full bind
Map<Parameter, Object> params = new ListMap();
params.put(param0, 1);
params.put(param1, "world");
params.put(param2, True);

function void () world = log.bind(params);
world();
function void () fn = log.bind(params);
fn();
}

void testChildTypes()
Expand Down

0 comments on commit dc1a614

Please sign in to comment.