diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-21 23:35:18 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-21 23:35:18 +0100 |
commit | 49c1902a04d961a75b964404da0beb15853d63ec (patch) | |
tree | e2fc8ffe8e036c39a20d73c856a3fbf4f73c3db3 /modules/gdscript | |
parent | 35f0be2e92906a6d18a110ae371c247a3eab1a13 (diff) | |
parent | d076c765511c9a500d7f60a75e7ed816a2e6aacb (diff) |
Merge pull request #73689 from vnen/gdscript-fix-inheritance-native-class
GDScript: Fix setting native type with script inheritance
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index efa75528fc..35c9946bc1 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -2265,13 +2265,15 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri GDScriptDataType base_type = _gdtype_from_datatype(p_class->base_type, p_script); + int native_idx = GDScriptLanguage::get_singleton()->get_global_map()[base_type.native_type]; + p_script->native = GDScriptLanguage::get_singleton()->get_global_array()[native_idx]; + ERR_FAIL_COND_V(p_script->native.is_null(), ERR_BUG); + // Inheritance switch (base_type.kind) { - case GDScriptDataType::NATIVE: { - int native_idx = GDScriptLanguage::get_singleton()->get_global_map()[base_type.native_type]; - p_script->native = GDScriptLanguage::get_singleton()->get_global_array()[native_idx]; - ERR_FAIL_COND_V(p_script->native.is_null(), ERR_BUG); - } break; + case GDScriptDataType::NATIVE: + // Nothing more to do. + break; case GDScriptDataType::GDSCRIPT: { Ref<GDScript> base = Ref<GDScript>(base_type.script_type); if (base.is_null()) { @@ -2303,7 +2305,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri p_script->base = base; p_script->_base = base.ptr(); p_script->member_indices = base->member_indices; - p_script->native = base->native; } break; default: { _set_error("Parser bug: invalid inheritance.", nullptr); |