GNOME Bugzilla – Bug 760031
vala allows access to protected constructors
Last modified: 2016-10-08 20:16:22 UTC
Created attachment 318081 [details] Reproducer See attached reproducer. valac doesn't complain if one calls a protected constructor from outside the class or a child class.
Created attachment 318082 [details] [review] Deny access to protected constructors
Created attachment 320302 [details] [review] Updated patch
Review of attachment 318082 [details] [review]: Patch no longer applies against master and a new patch has been supplied
Review of attachment 320302 [details] [review]: Patch works against reproducer. The error message is: test20.vala:15.11-15.22: error: Access to private member `Foobar.new' denied I think this would be better if it was: test20.vala:15.11-15.22: error: Access to protected member `Foobar.new' denied There is already an access to protected member denied elsewhere in libvala. So I think it should be here as well to be consistent. Now that tests for invalid code are supported ( https://git.gnome.org/browse/vala/commit/?id=2f924f63f6d7bcaa3df13e2ee9d365b25b5a00b4 ) I think a test case should be with the patch. See https://git.gnome.org/browse/vala/commit/?id=97de315bb903014975347949e513421599e76c9c for an example. The test case can be reduced significantly. All you need is: class Foobar { protected Foobar(){} } void main () { new Foobar(); }
Created attachment 337252 [details] [review] Deny access to protected constructors
Attachment 337252 [details] pushed as 588c00e - Deny access to protected constructors