summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-10-21 13:56:35 +0200
committerGitHub <noreply@github.com>2019-10-21 13:56:35 +0200
commit6f18c3c6cf7cffc1a9b98c7cffd334b7c5c5ab67 (patch)
tree737c7217b82f3e6c0caaeaade855f04f7357007f
parent9c1faadcf9bac6f5c3100e0165e395d1abb20dcb (diff)
parent05465b96933c295c15323802e9184889857227a1 (diff)
Merge pull request #32923 from vnen/gdscript-type-check-native-singleton
GDScript: Add _ prefix on class name in type compatibility check
-rw-r--r--modules/gdscript/gdscript_parser.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index cf326bef36..282bb45c3f 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -6109,12 +6109,18 @@ bool GDScriptParser::_is_type_compatible(const DataType &p_container, const Data
break;
}
+ // Some classes are prefixed with `_` internally
+ if (!ClassDB::class_exists(expr_native)) {
+ expr_native = "_" + expr_native;
+ }
+
switch (p_container.kind) {
case DataType::NATIVE: {
if (p_container.is_meta_type) {
return ClassDB::is_parent_class(expr_native, GDScriptNativeClass::get_class_static());
} else {
- return ClassDB::is_parent_class(expr_native, p_container.native_type);
+ StringName container_native = ClassDB::class_exists(p_container.native_type) ? p_container.native_type : StringName("_" + p_container.native_type);
+ return ClassDB::is_parent_class(expr_native, container_native);
}
} break;
case DataType::SCRIPT: