feat: check import return type
This PR is draft because definitely not yet complete. But I need some advice as to how to proceed from here.
I've plumbed the return type through the AST to the resolver. The check on this line is clearly wrong, but I'm not sure what the right way to check that the declared return value matches the method is?
https://github.com/paulbutcher/flix/blob/import-retval/main/src/ca/uwaterloo/flix/language/phase/Resolver.scala#L2507
Also not done yet: the same functionality for constructors and field access.
Looks ok to me, but lets ask @mlutze if he agrees.
Looks ok to me, but lets ask @mlutze if he agrees.
Well, it causes (as you can see!) plenty of failed tests, so I assume that there's a better approach...
It should at least be a subtype check, I guess. But more seems to be wrong than that?
We're importing methods that return arrays with regions. A normal (regionless) array is Array[a, Static] so even a subtype check would be insufficient because Static is not a subtype of r: Region.
I'm not sure what the best solution is. In principle, we ought not to allow import XYZ: Array[Int32, r], but it seems like a very convenient feature.
Ah- I did not think of that complication.
Until I understand regions properly (which I currently don't), I think I need to rely on one of you to tell me what the right way forwards is here?
Lets be practical and incremental. How about we start by doing the check for: (1) any primitive type and (2) any Java type. For all other types (arrays, enums, other Flix types) we skip the check. Once this works, we can think deeper about it or defer, since we will catch most issues anyway.
We can add the more advanced checks once we have actually figured out how to integrate (1) generics, (2) regions, (3) effects, (4) function types with Java. For now a 90% solution seems like a great improvement.
This is now ready to be merged, I think.
Merged! Thanks
Fixes #4395