Hey guys,

I just realised that vala-list is not the proper place for patches, so I'll try 
here 
instead – sorry for cross-posting.

Here are three patches I'd like to see in master.
The first adds two missing cases in TokenType's to_string method.

The second fixes a type checker bug that allows generic classes that are 
applied to the
wrong number of type arguments to pass type checking. Example:
class Foo<T> {}
void main(string[] args) {
Foo<Foo<string, string> > foo = null;
}

The third sets the parent_node correctly for base types in a class declaration.
I haven't found an actual bug caused by this, but it clearly seems like the 
right
thing to do.

Let me know what you think!
Cheers,
Matthias
>From 79aa26e2f37cc10a4c256de4a4377f260411ea9d Mon Sep 17 00:00:00 2001
From: Matthias Berndt <matthias_ber...@gmx.de>
Date: Sun, 15 May 2016 01:01:15 +0200
Subject: [PATCH 1/3] add missing tokens to TokenType's to_string method

---
 vala/valatokentype.vala | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/vala/valatokentype.vala b/vala/valatokentype.vala
index 91b50b9..e9bf4d4 100644
--- a/vala/valatokentype.vala
+++ b/vala/valatokentype.vala
@@ -192,7 +192,9 @@ public enum Vala.TokenType {
 		case DELETE: return "`delete'";
 		case DIV: return "`/'";
 		case DO: return "`do'";
+		case DOUBLE_COLON: return "`::'";
 		case DOT: return "`.'";
+		case DYNAMIC: return "`dynamic'";
 		case ELLIPSIS: return "`...'";
 		case ELSE: return "`else'";
 		case ENUM: return "`enum'";
-- 
2.5.5

>From 42b83d4fe6a21e229c571cff52def007b46aa78b Mon Sep 17 00:00:00 2001
From: Matthias Berndt <matthias_ber...@gmx.de>
Date: Mon, 16 May 2016 12:21:06 +0200
Subject: [PATCH 2/3] check type parameters recursively

This fixes error checking for code like this:

class Foo<T> {}
void main(string[] args) {
  Foo<Foo<string, string> > foo = null;
}
---
 vala/valaobjecttype.vala | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/vala/valaobjecttype.vala b/vala/valaobjecttype.vala
index 7019719..3d79edd 100644
--- a/vala/valaobjecttype.vala
+++ b/vala/valaobjecttype.vala
@@ -109,6 +109,11 @@ public class Vala.ObjectType : ReferenceType {
 			return false;
 		}
 
+		foreach (DataType type in get_type_arguments ()) {
+			if (! type.check (context))
+				return false;
+		}
+
 		return true;
 	}
 }
-- 
2.5.5

>From 09e6caf5305dabc237a8f8562f4c92fe117b398c Mon Sep 17 00:00:00 2001
From: Matthias Berndt <matthias_ber...@gmx.de>
Date: Mon, 16 May 2016 14:30:55 +0200
Subject: [PATCH 3/3] set parent_node properly for base types

---
 vala/valaclass.vala     | 1 +
 vala/valainterface.vala | 1 +
 2 files changed, 2 insertions(+)

diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 5dc7c1a..b983319 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -561,6 +561,7 @@ public class Vala.Class : ObjectTypeSymbol {
 		for (int i = 0; i < base_types.size; i++) {
 			if (base_types[i] == old_type) {
 				base_types[i] = new_type;
+				new_type.parent_node = this;
 				return;
 			}
 		}
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index 43c6f5c..621c6e8 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -356,6 +356,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 		for (int i = 0; i < prerequisites.size; i++) {
 			if (prerequisites[i] == old_type) {
 				prerequisites[i] = new_type;
+				new_type.parent_node = this;
 				return;
 			}
 		}
-- 
2.5.5

_______________________________________________
vala-devel-list mailing list
vala-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-devel-list

Reply via email to