On Wednesday, 14 May 2014 at 11:06:43 UTC, Yuriy wrote:
bearophile, good point. What do you think of the following solution: 1. Declaring member variable with __monitor identifier is disallowed. 2. class may be defined with @__monitor attribute, in which case a __monitor variable will be added to it's beginning. 3. Subclass of such class may again be defined with @__monitor attar, in which case it will be simply ignored, as it already inherits __monitor from super.
These would be breaking changes. I see the benefit but... If the compiler recognizes the class using synchronized, it could use a little magic and add a monitor variable itself, this would not cause any breaking change.