Follow up from #632.
While normal subtyping of methods is working fine thanks to my fix, intersection is still buggy.
According to the current implementation, two method types intersect if and only if:
I agree that it is important to have intersecting return types. A method cannot return int and bool at the same time.
But the last condition is wrong. An intersecting method can easily specify any for each parameter type, then it will be in the set of both types and therefore in their intersection. (I hereby assume that parameter types in all methods must not be void).
The complement of two types intersect almost every time, except if both types are any. So the current implementation does not think that type method(any)->() intersects with itself.
Consider this program:
type t is method(any)->()
method test(any x):
!t m = &test
It should not compile because &test is in type t and therefore not a subtype of !t.
But it compiles due to this bug.