Material static switch connected to boolean parameters broken in nested functions

When a static switch is connected to a boolean parameter, that parameters doesn’t function properly

I isolated a simple case. Here the Mat:

Here’s the incorrect result from that in its Material Instance:

215123-amat6.jpg

First of all the “UseOption” parameter is missing (Note that “UseMasterOption” is set to false in TestMat), and the incorrect secondary parameter shows up: “HowWhite” instead of the correct “HowBlack”.

If I setup the switch like this instead it fixes the problem:

and correctly displays the proper parameters and results.

EDIT: This seems to be an unhandled case in FMaterialEditorUtilities::GetStaticSwitchExpressionValue. Adding the following lines fixes it, by recursing on a static-bool within a switch (after the FunctionInputExpression block):

UMaterialExpressionStaticSwitch* StaticSwitchExpression = Cast<UMaterialExpressionStaticSwitch>(SwitchValueExpression);
if (StaticSwitchExpression)
{
	bool bValue = StaticSwitchExpression->DefaultValue;
	return GetStaticSwitchExpressionValue(MaterialInstance, StaticSwitchExpression->Value.Expression, bValue, OutExpressionID, FunctionStack);
}