Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Do not put a dummy method in object types #1620
Dummy methods are inserted in object types to prevent scope escapes (and, a fortiori, mistakenly closing an object type).
This check is known to be brittle:
However, while that check is important for classes, there seem to be no reason to do it for objects: we always close the type of an object.
So in theory, we could fix the first issue by simply not adding a dummy method when "initializing" the type of an object. This is what is done in commit 1096f57. On its own however, it is not enough to fix the test cases produced in MPR#7391. This is because a dummy method makes its way inside the object type through inheritance. This also seems wrong: the dummy method should be made absent when finalizing the class declaration. This is done by commit 77cefbd .
These two changes taken together are enough to fix the first class of issues. But it also paves the way to fixing the second set of issues: having done the changes described above, if we ever find a dummy method inside the type of an object it means that the type of that object has been unified with the type of a class which hasn't been fully defined yet. That means we shouldn't close our object type, because it would imply closing the self type of the class being defined which isn't allowed. Commit 5333a22 implements that new check, which does indeed fix the example added by commit c3027c1 .