vala r2437 - in trunk: . ccode vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2437 - in trunk: . ccode vala
- Date: Thu, 12 Feb 2009 23:38:42 +0000 (UTC)
Author: juergbi
Date: Thu Feb 12 23:38:42 2009
New Revision: 2437
URL: http://svn.gnome.org/viewvc/vala?rev=2437&view=rev
Log:
2009-02-12 JÃrg Billeter <j bitron ch>
* vala/valaclass.vala:
* vala/valaconstant.vala:
* vala/valafield.vala:
* vala/valamember.vala:
* vala/valamethod.vala:
* vala/valaproperty.vala:
* vala/valastruct.vala:
Warn when hiding members, support `new' keyword to suppress
warning, based on patch by Andreas Brauchli, fixes bug 567743
* vala/valacodenode.vala:
* vala/valacreationmethod.vala:
* vala/valaenum.vala:
* vala/valaerrordomain.vala:
* vala/valanamespace.vala:
* ccode/valaccodelinedirective.vala:
Avoid hidden members
Modified:
trunk/ChangeLog
trunk/ccode/valaccodelinedirective.vala
trunk/vala/valaclass.vala
trunk/vala/valacodenode.vala
trunk/vala/valaconstant.vala
trunk/vala/valacreationmethod.vala
trunk/vala/valaenum.vala
trunk/vala/valaerrordomain.vala
trunk/vala/valafield.vala
trunk/vala/valamember.vala
trunk/vala/valamethod.vala
trunk/vala/valanamespace.vala
trunk/vala/valaproperty.vala
trunk/vala/valastruct.vala
Modified: trunk/ccode/valaccodelinedirective.vala
==============================================================================
--- trunk/ccode/valaccodelinedirective.vala (original)
+++ trunk/ccode/valaccodelinedirective.vala Thu Feb 12 23:38:42 2009
@@ -34,18 +34,18 @@
/**
* The line number in the source file to be presumed.
*/
- public int line { get; set; }
+ public int line_number { get; set; }
public CCodeLineDirective (string _filename, int _line) {
filename = _filename;
- line = _line;
+ line_number = _line;
}
public override void write (CCodeWriter writer) {
if (!writer.bol) {
writer.write_newline ();
}
- writer.write_string ("#line %d \"%s\"".printf (line, filename));
+ writer.write_string ("#line %d \"%s\"".printf (line_number, filename));
writer.write_newline ();
}
}
Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala (original)
+++ trunk/vala/valaclass.vala Thu Feb 12 23:38:42 2009
@@ -329,9 +329,9 @@
}
var cm = (CreationMethod) m;
- if (cm.type_name != null && cm.type_name != name) {
- // type_name is null for constructors generated by GIdlParser
- Report.error (m.source_reference, "missing return type in method `%s.%sÂ".printf (get_full_name (), cm.type_name));
+ if (cm.class_name != null && cm.class_name != name) {
+ // class_name is null for constructors generated by GIdlParser
+ Report.error (m.source_reference, "missing return type in method `%s.%sÂ".printf (get_full_name (), cm.class_name));
m.error = true;
return;
}
Modified: trunk/vala/valacodenode.vala
==============================================================================
--- trunk/vala/valacodenode.vala (original)
+++ trunk/vala/valacodenode.vala Thu Feb 12 23:38:42 2009
@@ -45,6 +45,10 @@
* Contains all attributes that have been specified for this code node.
*/
public GLib.List<Attribute> attributes;
+
+ public string type_name {
+ get { return Type.from_instance (this).name (); }
+ }
/**
* Generated CCodeNode that corresponds to this code node.
@@ -189,8 +193,4 @@
public string get_temp_name () {
return "." + (++last_temp_nr).to_string ();
}
-
- public weak string get_type_name () {
- return Type.from_instance (this).name ();
- }
}
Modified: trunk/vala/valaconstant.vala
==============================================================================
--- trunk/vala/valaconstant.vala (original)
+++ trunk/vala/valaconstant.vala Thu Feb 12 23:38:42 2009
@@ -181,6 +181,10 @@
}
}
+ if (!external_package && !hides && get_hidden_member () != null) {
+ Report.warning (source_reference, "%s hides inherited constant `%s'. Use the `new' keyword if hiding was intentional".printf (get_full_name (), get_hidden_member ().get_full_name ()));
+ }
+
analyzer.current_source_file = old_source_file;
analyzer.current_symbol = old_symbol;
Modified: trunk/vala/valacreationmethod.vala
==============================================================================
--- trunk/vala/valacreationmethod.vala (original)
+++ trunk/vala/valacreationmethod.vala Thu Feb 12 23:38:42 2009
@@ -31,7 +31,7 @@
/**
* Specifies the name of the type this creation method belongs to.
*/
- public string type_name { get; set; }
+ public string class_name { get; set; }
/**
* Specifies the number of parameters this creation method sets.
@@ -59,9 +59,9 @@
* @param source_reference reference to source code
* @return newly created method
*/
- public CreationMethod (string? type_name, string? name, SourceReference? source_reference = null) {
+ public CreationMethod (string? class_name, string? name, SourceReference? source_reference = null) {
base (name, new VoidType (), source_reference);
- this.type_name = type_name;
+ this.class_name = class_name;
carray_length_parameter_position = -3;
cdelegate_target_parameter_position = -3;
@@ -125,9 +125,9 @@
process_attributes ();
- if (type_name != null && type_name != parent_symbol.name) {
- // type_name is null for constructors generated by GIdlParser
- Report.error (source_reference, "missing return type in method `%s.%sÂ".printf (analyzer.current_symbol.get_full_name (), type_name));
+ if (class_name != null && class_name != parent_symbol.name) {
+ // class_name is null for constructors generated by GIdlParser
+ Report.error (source_reference, "missing return type in method `%s.%sÂ".printf (analyzer.current_symbol.get_full_name (), class_name));
error = true;
return false;
}
Modified: trunk/vala/valaenum.vala
==============================================================================
--- trunk/vala/valaenum.vala (original)
+++ trunk/vala/valaenum.vala Thu Feb 12 23:38:42 2009
@@ -165,13 +165,7 @@
return false;
}
- /**
- * Returns the string to be prepended to the name of members of this
- * enum when used in C code.
- *
- * @return the prefix to be used in C code
- */
- public string get_cprefix () {
+ public override string get_cprefix () {
if (cprefix == null) {
cprefix = "%s_".printf (get_upper_case_cname ());
}
Modified: trunk/vala/valaerrordomain.vala
==============================================================================
--- trunk/vala/valaerrordomain.vala (original)
+++ trunk/vala/valaerrordomain.vala Thu Feb 12 23:38:42 2009
@@ -148,13 +148,7 @@
this.cname = cname;
}
- /**
- * Returns the string to be prepended to the name of members of this
- * error domain when used in C code.
- *
- * @return the prefix to be used in C code
- */
- public string get_cprefix () {
+ public override string get_cprefix () {
if (cprefix == null) {
cprefix = "%s_".printf (get_upper_case_cname (null));
}
Modified: trunk/vala/valafield.vala
==============================================================================
--- trunk/vala/valafield.vala (original)
+++ trunk/vala/valafield.vala Thu Feb 12 23:38:42 2009
@@ -321,6 +321,10 @@
}
}
+ if (!external_package && !hides && get_hidden_member () != null) {
+ Report.warning (source_reference, "%s hides inherited field `%s'. Use the `new' keyword if hiding was intentional".printf (get_full_name (), get_hidden_member ().get_full_name ()));
+ }
+
if (field_in_header) {
if (field_type is ValueType) {
analyzer.current_source_file.add_type_dependency (field_type, SourceFileDependencyType.HEADER_FULL);
Modified: trunk/vala/valamember.vala
==============================================================================
--- trunk/vala/valamember.vala (original)
+++ trunk/vala/valamember.vala Thu Feb 12 23:38:42 2009
@@ -68,6 +68,32 @@
public void add_cheader_filename (string filename) {
cheader_filenames.add (filename);
}
+
+ public Symbol? get_hidden_member () {
+ Symbol sym = null;
+
+ if (parent_symbol is Class) {
+ var cl = ((Class) parent_symbol).base_class;
+ while (cl != null) {
+ sym = cl.scope.lookup (name);
+ if (sym != null && sym.access != SymbolAccessibility.PRIVATE) {
+ return sym;
+ }
+ cl = cl.base_class;
+ }
+ } else if (parent_symbol is Struct) {
+ var st = ((Struct) parent_symbol).base_struct;
+ while (st != null) {
+ sym = st.scope.lookup (name);
+ if (sym != null && sym.access != SymbolAccessibility.PRIVATE) {
+ return sym;
+ }
+ st = st.base_struct;
+ }
+ }
+
+ return null;
+ }
}
public enum MemberBinding {
Modified: trunk/vala/valamethod.vala
==============================================================================
--- trunk/vala/valamethod.vala (original)
+++ trunk/vala/valamethod.vala Thu Feb 12 23:38:42 2009
@@ -744,6 +744,10 @@
Report.error (source_reference, "%s: no suitable method found to override".printf (get_full_name ()));
}
+ if (!external_package && !overrides && !hides && get_hidden_member () != null) {
+ Report.warning (source_reference, "%s hides inherited method `%s'. Use the `new' keyword if hiding was intentional".printf (get_full_name (), get_hidden_member ().get_full_name ()));
+ }
+
// check whether return type is at least as accessible as the method
if (!analyzer.is_type_accessible (this, return_type)) {
error = true;
Modified: trunk/vala/valanamespace.vala
==============================================================================
--- trunk/vala/valanamespace.vala (original)
+++ trunk/vala/valanamespace.vala Thu Feb 12 23:38:42 2009
@@ -86,7 +86,7 @@
foreach (Enum en in ns.get_enums ()) {
old_ns.add_enum (en);
}
- foreach (ErrorDomain ed in ns.get_error_types ()) {
+ foreach (ErrorDomain ed in ns.get_error_domains ()) {
old_ns.add_error_domain (ed);
}
foreach (Constant c in ns.get_constants ()) {
@@ -254,7 +254,7 @@
*
* @return error domain list
*/
- public Gee.List<ErrorDomain> get_error_types () {
+ public Gee.List<ErrorDomain> get_error_domains () {
return new ReadOnlyList<ErrorDomain> (error_domains);
}
Modified: trunk/vala/valaproperty.vala
==============================================================================
--- trunk/vala/valaproperty.vala (original)
+++ trunk/vala/valaproperty.vala Thu Feb 12 23:38:42 2009
@@ -448,6 +448,10 @@
Report.error (source_reference, "%s: no suitable property found to override".printf (get_full_name ()));
}
+ if (!external_package && !overrides && !hides && get_hidden_member () != null) {
+ Report.warning (source_reference, "%s hides inherited property `%s'. Use the `new' keyword if hiding was intentional".printf (get_full_name (), get_hidden_member ().get_full_name ()));
+ }
+
/* construct properties must be public */
if (set_accessor != null && set_accessor.construction) {
if (access != SymbolAccessibility.PUBLIC) {
Modified: trunk/vala/valastruct.vala
==============================================================================
--- trunk/vala/valastruct.vala (original)
+++ trunk/vala/valastruct.vala Thu Feb 12 23:38:42 2009
@@ -177,9 +177,9 @@
}
var cm = (CreationMethod) m;
- if (cm.type_name != null && cm.type_name != name) {
+ if (cm.class_name != null && cm.class_name != name) {
// type_name is null for constructors generated by GIdlParser
- Report.error (m.source_reference, "missing return type in method `%s.%sÂ".printf (get_full_name (), cm.type_name));
+ Report.error (m.source_reference, "missing return type in method `%s.%sÂ".printf (get_full_name (), cm.class_name));
m.error = true;
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]