From c7c8c0700f9f72663102167f739219faa04d7c56 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Wed, 20 Mar 2019 17:23:11 +0100 Subject: [PATCH] Fix parsing of generic type declarations in C# source files. (cherry picked from commit 34366bc27fddd69539562c12579b3207b23676fe) --- modules/mono/editor/script_class_parser.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp index 6b2ec5cc20a..dfb652a7aa6 100644 --- a/modules/mono/editor/script_class_parser.cpp +++ b/modules/mono/editor/script_class_parser.cpp @@ -266,6 +266,20 @@ Error ScriptClassParser::_skip_generic_type_params() { if (tk == TK_IDENTIFIER) { tk = get_token(); + // Type specifications can end with "?" to denote nullable types, such as IList + if (tk == TK_SYMBOL) { + tk = get_token(); + if (value.operator String() != "?") { + error_str = "Expected " + get_token_name(TK_IDENTIFIER) + ", found unexpected symbol '" + value + "'"; + error = true; + return ERR_PARSE_ERROR; + } + if (tk != TK_OP_GREATER && tk != TK_COMMA) { + error_str = "Nullable type symbol '?' is only allowed after an identifier, but found " + get_token_name(tk) + " next."; + error = true; + return ERR_PARSE_ERROR; + } + } if (tk == TK_PERIOD) { while (true) {