Fixed tables in script runtime functions breaking

This commit is contained in:
Deukhoofd 2019-01-26 14:03:22 +01:00
parent 65ae6f6f06
commit ee36060dd6
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 22 additions and 13 deletions

View File

@ -47,32 +47,41 @@ namespace Upsilon.BaseTypes.ScriptFunction
for (var index = 0; index < variables.Length; index++)
{
var parameter = option.Parameters[index];
var parameterSymbol = ((UserDataVariableSymbol) parameter.VariableSymbol);
var v = variables[index];
if (v == null)
{
continue;
}
System.Type parameterType;
if (v is GenericUserData ud)
parameterType = ud.GetCSharpType();
else
parameterType = v.GetType();
if (parameterSymbol.BoundTypeDefinition != null)
if (parameter.VariableSymbol is UserDataVariableSymbol parameterSymbol)
{
var validSymbol =
parameterSymbol.BoundTypeDefinition.ValidInternalTypes.Any(validType =>
if (parameterSymbol.BoundTypeDefinition != null)
{
var validSymbol =
parameterSymbol.BoundTypeDefinition.ValidInternalTypes.Any(validType =>
{
var b = validType.IsAssignableFrom(parameterType);
if (b) return true;
if (parameterType.IsGenericType &&
validType.IsAssignableFrom(parameterType.GetGenericTypeDefinition()))
return true;
return false;
});
if (!validSymbol)
{
var b = validType.IsAssignableFrom(parameterType);
if (b) return true;
if (parameterType.IsGenericType &&
validType.IsAssignableFrom(parameterType.GetGenericTypeDefinition()))
return true;
return false;
});
if (!validSymbol)
isCompatible = false;
break;
}
}
}
else if (parameter.VariableSymbol is TableVariableSymbol tableVariableSymbol)
{
if (parameterType.GetScriptType() != BaseTypes.Type.Table)
{
isCompatible = false;
break;