Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic IEnumerable missintepreted #217

Closed
waclaw66 opened this issue Dec 20, 2021 · 1 comment · Fixed by #218
Closed

Generic IEnumerable missintepreted #217

waclaw66 opened this issue Dec 20, 2021 · 1 comment · Fixed by #218
Labels

Comments

@waclaw66
Copy link

The last test fails with
Expression of type 'System.Collections.Generic.IEnumerable`1[T]' cannot be used for parameter of type 'System.Collections.Generic.IEnumerable`1[System.Object]' of method 'Boolean Any[Object](System.Collections.Generic.IEnumerable`1[System.Object])'

public class Utils
{
    public static bool Any<T>(IEnumerable<T> collection)
    {
        return false;
    }

    public static bool Any(IEnumerable collection)
    {
        return false;
    }
}

var target = new Interpreter();
target.Reference(typeof(Utils));
target.Reference(typeof(IEnumerable<>));

Assert.DoesNotThrow(() => Utils.Any((IEnumerable<object>)null));
Assert.DoesNotThrow(() => Utils.Any(null));
Assert.DoesNotThrow(() => target.Eval("Utils.Any(list)", new Parameter("list", typeof(IEnumerable<object>), null)));
Assert.DoesNotThrow(() => target.Eval("Utils.Any(null)"));
@metoule metoule added the bug label Dec 20, 2021
@metoule
Copy link
Contributor

metoule commented Dec 20, 2021

After PR #210, there's a different exception:

System.ArgumentException : Type System.Collections.Generic.IEnumerable`1[T] contains generic parameters (Parameter 'type')
  TypeUtils.ValidateType(Type type, String paramName, Int32 index)
  TypeUtils.ValidateType(Type type, String paramName, Boolean allowByRef, Boolean allowPointer)
  Expression.Constant(Object value, Type type)
  Parser.PromoteExpression(Expression expr, Type type, Boolean exact) line 2182

metoule added a commit to metoule/DynamicExpresso that referenced this issue Dec 20, 2021
metoule added a commit that referenced this issue Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants