Merge pull request #39260 from vnen/get_script_is_type

Allow get_script() to be considered a type
This commit is contained in:
Rémi Verschelde 2020-06-03 17:37:18 +02:00 committed by GitHub
commit a29318a5bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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<ClassNode *>(head);
return_type.is_meta_type = true;
valid = true;
}
if (!valid) {
base_type = original_type;
return_type = DataType();