Open nadako opened 5 years ago
Multiple expected types could in theory be represented as haxe.extern.EitherType
, but that's probably too hacky? :) The language server already looks for that, but it doesn't tend to work very well because of #7262.
This is not actually an issue specific to completion. We don't apply top-down inference in these cases because the order is inverse: We type the operands of the array access, then find the appropriate field on the abstract.
We could type the index expression and then filter those array-access-write functions which accept its type as the first argument. This would make something like this work too:
class Main {
static function main() {
var x = new Map<String, Array<Dynamic>>();
x[""] = [1, "foo"];
}
}
no
{fields...}
😢Works with Array, didn't test with custom/non-multiType abstracts, but I suspect it's a general abstract operator overloading issue. Could we at least provide the expected type when there's only one
@:op([])
?