[vala/tintou/ptr-array-foreach: 1/3] vala: Move base class checks in Class together with some minor API changes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/tintou/ptr-array-foreach: 1/3] vala: Move base class checks in Class together with some minor API changes
- Date: Mon, 3 May 2021 07:11:37 +0000 (UTC)
commit 3c51c8de42f1676347ff1f977116d57e7b00d939
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat May 1 15:56:58 2021 +0200
vala: Move base class checks in Class together with some minor API changes
Provide Class.base_class_type property for convenience.
vala/valaclass.vala | 23 ++++++++++++++++++++++-
vala/valasymbolresolver.vala | 7 -------
2 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 88339dec1..8411fd025 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -29,7 +29,19 @@ public class Vala.Class : ObjectTypeSymbol {
/**
* Specifies the base class.
*/
- public Class base_class { get; set; }
+ public Class? base_class {
+ get {
+ if (base_class_type != null) {
+ return base_class_type.class_symbol;
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Specifies the base class type.
+ */
+ public ClassType? base_class_type { get; private set; }
/**
* Specifies whether this class is abstract. Abstract classes may not be
@@ -238,6 +250,15 @@ public class Vala.Class : ObjectTypeSymbol {
* @param type a class or interface reference
*/
public void add_base_type (DataType type) {
+ if (type.type_symbol is Class) {
+ if (base_class != null) {
+ error = true;
+ Report.error (type.source_reference, "%s: Classes cannot have multiple base
classes (`%s' and `%s')", get_full_name (), base_class.get_full_name (), type.type_symbol.get_full_name ());
+ return;
+ }
+ base_class_type = (ClassType) type;
+ }
+
base_types.add (type);
type.parent_node = this;
}
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index b5594bfe0..0b573aeee 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -62,15 +62,8 @@ public class Vala.SymbolResolver : CodeVisitor {
cl.accept_children (this);
- cl.base_class = null;
foreach (DataType type in cl.get_base_types ()) {
if (type.type_symbol is Class) {
- if (cl.base_class != null) {
- cl.error = true;
- Report.error (type.source_reference, "%s: Classes cannot have
multiple base classes (`%s' and `%s')", cl.get_full_name (), cl.base_class.get_full_name (),
type.type_symbol.get_full_name ());
- return;
- }
- cl.base_class = (Class) type.type_symbol;
if (cl.base_class.is_subtype_of (cl)) {
cl.error = true;
Report.error (type.source_reference, "Base class cycle (`%s' and
`%s')", cl.get_full_name (), cl.base_class.get_full_name ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]