[vala/0.50] girparser: Minor improvement to field getter detection
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.50] girparser: Minor improvement to field getter detection
- Date: Sun, 28 Feb 2021 08:58:19 +0000 (UTC)
commit ae92b5dacec3fec78528ebc4aec069f51518d835
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Jan 14 17:55:34 2021 +0100
girparser: Minor improvement to field getter detection
Allow DataType.compatible() to be called without initialized SemanticAnalyzer
Additionally report a warning if field collides with method
vala/valadatatype.vala | 6 ++++--
vala/valagirparser.vala | 10 +++++++---
2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index ada2c1dd4..bb00ff8cf 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -282,12 +282,14 @@ public abstract class Vala.DataType : CodeNode {
}
if (context.profile == Profile.GOBJECT && target_type.type_symbol != null) {
- if (target_type.type_symbol.is_subtype_of (context.analyzer.gvalue_type.type_symbol))
{
+ unowned DataType? gvalue_type = context.analyzer.gvalue_type;
+ if (gvalue_type != null && target_type.type_symbol.is_subtype_of
(gvalue_type.type_symbol)) {
// allow implicit conversion to GValue
return true;
}
- if (target_type.type_symbol.is_subtype_of
(context.analyzer.gvariant_type.type_symbol)) {
+ unowned DataType? gvariant_type = context.analyzer.gvariant_type;
+ if (gvariant_type != null && target_type.type_symbol.is_subtype_of
(gvariant_type.type_symbol)) {
// allow implicit conversion to GVariant
return true;
}
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 5bd8406c7..d32462090 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -914,9 +914,13 @@ public class Vala.GirParser : CodeVisitor {
var colliding = parent.lookup_all (name);
foreach (var node in colliding) {
var sym = node.symbol;
- if (sym is Field && !(m.return_type is VoidType) &&
m.get_parameters().size == 0) {
- // assume method is getter
- merged = true;
+ if (sym is Field) {
+ if (m.return_type.compatible (((Field)
sym).variable_type) && m.get_parameters ().size == 0) {
+ // assume method is getter
+ merged = true;
+ } else {
+ Report.warning (symbol.source_reference,
"Field `%s' conflicts with method of the same name".printf (get_full_name ()));
+ }
} else if (sym is Signal) {
node.process (parser);
var sig = (Signal) sym;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]