vala r2068 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2068 - in trunk: . vala
- Date: Fri, 28 Nov 2008 12:25:24 +0000 (UTC)
Author: juergbi
Date: Fri Nov 28 12:25:24 2008
New Revision: 2068
URL: http://svn.gnome.org/viewvc/vala?rev=2068&view=rev
Log:
2008-11-28 JÃrg Billeter <j bitron ch>
* vala/valaclass.vala:
* vala/valadatatype.vala:
* vala/valagenerictype.vala:
* vala/valainterface.vala:
* vala/valamethod.vala:
* vala/valaobjecttypesymbol.vala:
* vala/valasymbolresolver.vala:
Fix method checking with generic base types, fixes bug 511286
Modified:
trunk/ChangeLog
trunk/vala/valaclass.vala
trunk/vala/valadatatype.vala
trunk/vala/valagenerictype.vala
trunk/vala/valainterface.vala
trunk/vala/valamethod.vala
trunk/vala/valaobjecttypesymbol.vala
trunk/vala/valasymbolresolver.vala
Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala (original)
+++ trunk/vala/valaclass.vala Fri Nov 28 12:25:24 2008
@@ -99,8 +99,6 @@
private bool _is_compact;
private bool _is_immutable;
- private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
-
private Gee.List<DataType> base_types = new ArrayList<DataType> ();
private Gee.List<Constant> constants = new ArrayList<Constant> ();
@@ -231,26 +229,6 @@
}
/**
- * Appends the specified parameter to the list of type parameters.
- *
- * @param p a type parameter
- */
- public void add_type_parameter (TypeParameter p) {
- type_parameters.add (p);
- p.type = this;
- scope.add (p.name, p);
- }
-
- /**
- * Returns a copy of the type parameter list.
- *
- * @return list of type parameters
- */
- public Gee.List<TypeParameter> get_type_parameters () {
- return new ReadOnlyList<TypeParameter> (type_parameters);
- }
-
- /**
* Adds the specified constant as a member to this class.
*
* @param c a constant
@@ -433,7 +411,7 @@
type.accept (visitor);
}
- foreach (TypeParameter p in type_parameters) {
+ foreach (TypeParameter p in get_type_parameters ()) {
p.accept (visitor);
}
@@ -795,17 +773,6 @@
return false;
}
- public override int get_type_parameter_index (string name) {
- int i = 0;
- foreach (TypeParameter parameter in type_parameters) {
- if (parameter.name == name) {
- return i;
- }
- i++;
- }
- return -1;
- }
-
public override void replace_type (DataType old_type, DataType new_type) {
for (int i = 0; i < base_types.size; i++) {
if (base_types[i] == old_type) {
@@ -888,7 +855,7 @@
type.check (analyzer);
}
- foreach (TypeParameter p in type_parameters) {
+ foreach (TypeParameter p in get_type_parameters ()) {
p.check (analyzer);
}
Modified: trunk/vala/valadatatype.vala
==============================================================================
--- trunk/vala/valadatatype.vala (original)
+++ trunk/vala/valadatatype.vala Fri Nov 28 12:25:24 2008
@@ -179,8 +179,6 @@
} else {
s = data_type.get_full_name ();
}
- } else if (type_parameter != null) {
- s = type_parameter.name;
} else {
s = "null";
}
Modified: trunk/vala/valagenerictype.vala
==============================================================================
--- trunk/vala/valagenerictype.vala (original)
+++ trunk/vala/valagenerictype.vala Fri Nov 28 12:25:24 2008
@@ -28,6 +28,8 @@
public class Vala.GenericType : DataType {
public GenericType (TypeParameter type_parameter) {
this.type_parameter = type_parameter;
+ // type parameters are always considered nullable
+ this.nullable = true;
}
public override DataType copy () {
@@ -51,4 +53,8 @@
public override string? get_type_id () {
return "G_TYPE_POINTER";
}
+
+ public override string to_qualified_string (Scope? scope = null) {
+ return type_parameter.name;
+ }
}
Modified: trunk/vala/valainterface.vala
==============================================================================
--- trunk/vala/valainterface.vala (original)
+++ trunk/vala/valainterface.vala Fri Nov 28 12:25:24 2008
@@ -27,8 +27,6 @@
* Represents a class declaration in the source code.
*/
public class Vala.Interface : ObjectTypeSymbol {
- private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
-
private Gee.List<DataType> prerequisites = new ArrayList<DataType> ();
private Gee.List<Method> methods = new ArrayList<Method> ();
@@ -95,26 +93,6 @@
}
/**
- * Appends the specified parameter to the list of type parameters.
- *
- * @param p a type parameter
- */
- public void add_type_parameter (TypeParameter p) {
- type_parameters.add (p);
- p.type = this;
- scope.add (p.name, p);
- }
-
- /**
- * Returns a copy of the type parameter list.
- *
- * @return list of type parameters
- */
- public Gee.List<TypeParameter> get_type_parameters () {
- return new ReadOnlyList<TypeParameter> (type_parameters);
- }
-
- /**
* Adds the specified interface or class to the list of prerequisites of
* this interface.
*
@@ -355,7 +333,7 @@
type.accept (visitor);
}
- foreach (TypeParameter p in type_parameters) {
+ foreach (TypeParameter p in get_type_parameters ()) {
p.accept (visitor);
}
@@ -502,17 +480,6 @@
return type_id;
}
- public override int get_type_parameter_index (string name) {
- int i = 0;
- foreach (TypeParameter parameter in type_parameters) {
- if (parameter.name == name) {
- return i;
- }
- i++;
- }
- return -1;
- }
-
public override void replace_type (DataType old_type, DataType new_type) {
for (int i = 0; i < prerequisites.size; i++) {
if (prerequisites[i] == old_type) {
@@ -594,7 +561,7 @@
type.check (analyzer);
}
- foreach (TypeParameter p in type_parameters) {
+ foreach (TypeParameter p in get_type_parameters ()) {
p.check (analyzer);
}
Modified: trunk/vala/valamethod.vala
==============================================================================
--- trunk/vala/valamethod.vala (original)
+++ trunk/vala/valamethod.vala Fri Nov 28 12:25:24 2008
@@ -414,7 +414,18 @@
* @return true if the specified method is compatible to this method
*/
public bool compatible (Method base_method, out string? invalid_match) {
- if (!return_type.equals (base_method.return_type)) {
+ ObjectType object_type = null;
+ if (parent_symbol is ObjectTypeSymbol) {
+ object_type = new ObjectType ((ObjectTypeSymbol) parent_symbol);
+ foreach (TypeParameter type_parameter in object_type.type_symbol.get_type_parameters ()) {
+ var type_arg = new GenericType (type_parameter);
+ type_arg.value_owned = true;
+ object_type.add_type_argument (type_arg);
+ }
+ }
+
+ var actual_base_type = base_method.return_type.get_actual_type (object_type, this);
+ if (!return_type.equals (actual_base_type)) {
invalid_match = "incompatible return type";
return false;
}
@@ -428,7 +439,8 @@
return false;
}
- if (!base_param.parameter_type.equals (method_params_it.get ().parameter_type)) {
+ actual_base_type = base_param.parameter_type.get_actual_type (object_type, this);
+ if (!actual_base_type.equals (method_params_it.get ().parameter_type)) {
invalid_match = "incompatible type of parameter %d".printf (param_index);
return false;
}
Modified: trunk/vala/valaobjecttypesymbol.vala
==============================================================================
--- trunk/vala/valaobjecttypesymbol.vala (original)
+++ trunk/vala/valaobjecttypesymbol.vala Fri Nov 28 12:25:24 2008
@@ -1,5 +1,6 @@
/* valaobjecttypesymbol.vala
*
+ * Copyright (C) 2008 JÃrg Billeter
* Copyright (C) 2008 Philip Van Hoof
*
* This library is free software; you can redistribute it and/or
@@ -17,10 +18,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
+ * JÃrg Billeter <j bitron ch>
* Philip Van Hoof <pvanhoof gnome org>
*/
-using GLib;
using Gee;
/**
@@ -29,11 +30,44 @@
* Vala API file.
*/
public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
+ private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
+
+ public ObjectTypeSymbol (string name, SourceReference? source_reference = null) {
+ base (name, source_reference);
+ }
+
public abstract Gee.List<Method> get_methods ();
public abstract Gee.List<Signal> get_signals ();
public abstract Gee.List<Property> get_properties ();
- public ObjectTypeSymbol (string name, SourceReference? source_reference = null) {
- base (name, source_reference);
+ /**
+ * Appends the specified parameter to the list of type parameters.
+ *
+ * @param p a type parameter
+ */
+ public void add_type_parameter (TypeParameter p) {
+ type_parameters.add (p);
+ p.type = this;
+ scope.add (p.name, p);
+ }
+
+ /**
+ * Returns a copy of the type parameter list.
+ *
+ * @return list of type parameters
+ */
+ public Gee.List<TypeParameter> get_type_parameters () {
+ return new ReadOnlyList<TypeParameter> (type_parameters);
+ }
+
+ public override int get_type_parameter_index (string name) {
+ int i = 0;
+ foreach (TypeParameter parameter in type_parameters) {
+ if (parameter.name == name) {
+ return i;
+ }
+ i++;
+ }
+ return -1;
}
}
Modified: trunk/vala/valasymbolresolver.vala
==============================================================================
--- trunk/vala/valasymbolresolver.vala (original)
+++ trunk/vala/valasymbolresolver.vala Fri Nov 28 12:25:24 2008
@@ -294,7 +294,15 @@
type.source_reference = unresolved_type.source_reference;
type.value_owned = unresolved_type.value_owned;
- type.nullable = unresolved_type.nullable;
+
+ if (type is GenericType) {
+ // type parameters are always considered nullable
+ // actual type argument may or may not be nullable
+ type.nullable = true;
+ } else {
+ type.nullable = unresolved_type.nullable;
+ }
+
type.is_dynamic = unresolved_type.is_dynamic;
foreach (DataType type_arg in unresolved_type.get_type_arguments ()) {
type.add_type_argument (type_arg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]