GDScript: Add _ prefix on class name in type compatibility check
This makes sure that the classes internally represented with an
underscore (_) prefix, such as singletons, are still properly checked
for inheritance in the ClassDB.
(cherry picked from commit 05465b9693
)
This commit is contained in:
parent
37f7dcf3bc
commit
c9a5ca7ca5
|
@ -5949,12 +5949,18 @@ bool GDScriptParser::_is_type_compatible(const DataType &p_container, const Data
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some classes are prefixed with `_` internally
|
||||||
|
if (!ClassDB::class_exists(expr_native)) {
|
||||||
|
expr_native = "_" + expr_native;
|
||||||
|
}
|
||||||
|
|
||||||
switch (p_container.kind) {
|
switch (p_container.kind) {
|
||||||
case DataType::NATIVE: {
|
case DataType::NATIVE: {
|
||||||
if (p_container.is_meta_type) {
|
if (p_container.is_meta_type) {
|
||||||
return ClassDB::is_parent_class(expr_native, GDScriptNativeClass::get_class_static());
|
return ClassDB::is_parent_class(expr_native, GDScriptNativeClass::get_class_static());
|
||||||
} else {
|
} 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;
|
} break;
|
||||||
case DataType::SCRIPT:
|
case DataType::SCRIPT:
|
||||||
|
|
Loading…
Reference in New Issue