From a0983637cf2a61382cefaaf83a7386a361c48fe1 Mon Sep 17 00:00:00 2001 From: George Marques Date: Wed, 3 Jun 2020 10:32:37 -0300 Subject: [PATCH] GDScript: Allow get_script() to be considered a type --- modules/gdscript/gdscript_parser.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index d57da2c4197..2c9c62edc0a 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -7253,6 +7253,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat DataType original_type = base_type; bool is_initializer = callee_name == "new"; + bool is_get_script = p_call->arguments[0]->type == Node::TYPE_SELF && callee_name == "get_script"; bool is_static = false; bool valid = false; @@ -7271,6 +7272,14 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat valid = true; // There's always an initializer, we can assume this is true } + if (is_get_script) { + // get_script() can be considered a meta-type. + return_type.kind = DataType::CLASS; + return_type.class_type = static_cast(head); + return_type.is_meta_type = true; + valid = true; + } + if (!valid) { base_type = original_type; return_type = DataType();