Merge pull request #32923 from vnen/gdscript-type-check-native-singleton

GDScript: Add _ prefix on class name in type compatibility check
This commit is contained in:
Rémi Verschelde 2019-10-21 13:56:35 +02:00 committed by GitHub
commit 6f18c3c6cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: