[vala] Genie: Fix functions can take only one Generic as argument (611191)



commit 8558316a4c40fa8efbf6a7e128fddb9d864ce432
Author: Jamie McCracken <jamie mccrack gmail com>
Date:   Tue Aug 28 23:24:20 2012 -0400

    Genie: Fix functions can take only one Generic as argument (611191)

 vala/valagenieparser.vala |   58 ++++++++++++++++++++++++++++++--------------
 1 files changed, 39 insertions(+), 19 deletions(-)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index fe23c5f..77fbd1c 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -3732,33 +3732,53 @@ public class Vala.Genie.Parser : CodeVisitor {
 
 	void skip_type_argument_list () throws ParseError {
 		if (accept (TokenType.OF)) {
-			do {
-				skip_type ();
-			} while (accept (TokenType.COMMA));
+    		if (accept (TokenType.OPEN_PARENS)) {
+			    do {
+		            skip_type ();
+			    } while (accept (TokenType.COMMA));
+			    expect (TokenType.CLOSE_PARENS);
+    		} else {
+			    do {
+		            skip_type ();
+			    } while (accept (TokenType.COMMA));
+			}
 		}
 	}
 
+    
 	// try to parse type argument list
 	List<DataType>? parse_type_argument_list (bool maybe_expression) throws ParseError {
 		var begin = get_location ();
 		if (accept (TokenType.OF)) {
 			var list = new ArrayList<DataType> ();
-			do {
-				switch (current ()) {
-				case TokenType.VOID:
-				case TokenType.DYNAMIC:
-				case TokenType.UNOWNED:
-				case TokenType.WEAK:
-				case TokenType.IDENTIFIER:
-					var type = parse_type ();
-
-					list.add (type);
-					break;
-				default:
-					rollback (begin);
-					return null;
-				}
-			} while (accept (TokenType.COMMA));
+			var inParens = false;
+
+			// Optional parens allow multi arg types in function signature: "dict of (int, string)"
+			// See: https://bugzilla.gnome.org/show_bug.cgi?id=611191
+			if (accept (TokenType.OPEN_PARENS)) {
+			    inParens = true;
+			}
+			    			
+		    do {
+			    switch (current ()) {
+			    case TokenType.VOID:
+			    case TokenType.DYNAMIC:
+			    case TokenType.UNOWNED:
+			    case TokenType.WEAK:
+			    case TokenType.IDENTIFIER:
+				    var type = parse_type ();
+
+				    list.add (type);
+				    break;
+			    default:
+				    rollback (begin);
+				    return null;
+			    }
+		    } while (accept (TokenType.COMMA));
+		    
+		    if (inParens) {
+			    expect (TokenType.CLOSE_PARENS);
+			}
 
 			return list;
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]