Why doesn't an argument of type Any match an Int64

I must be missing something about the Julia language, because my perhaps naive logic tells me a parameter of type Any should match an argument of a concrete type. Still, I am getting this message:

Closest candidates are:
  calculate_statistic(::ProgramParameters, ::Tuple{Int64, Dict{String, Any}}, ::UnitRange{Int64}, ::Int64)```

The argument ```::Tuple{Int64, Dict{String, Any}}``` appears in red. If I remove this argument's type qualification the program runs fine, so this question is more to satisfy my curiosity and perhaps avoid future errors.

```ProgramParameters``` is a struct. It is not related to this problem, which existed in a previous version where a Dictionary was the first argument.

Types in Julia are invariant. Dict{String, X} is a subtype of Dict{String, Any} only when X=Any. You want to define your function to take Dict{String, <:Any}.

4 Likes

Thanks. Your suggestion worked.