From 34288b24a6d43d0f9a314f4aaccbebe454f9f23e Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 12 Oct 2021 10:41:04 -0300 Subject: GDScript: Fix typed array with custom classes --- modules/gdscript/gdscript_analyzer.cpp | 1 + .../scripts/analyzer/features/typed_array_with_custom_class.gd | 10 ++++++++++ .../analyzer/features/typed_array_with_custom_class.out | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.out (limited to 'modules/gdscript') diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index fd7664049a..9ae8323680 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -470,6 +470,7 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type GDScriptParser::DataType container_type = resolve_datatype(p_type->container_type); if (container_type.kind != GDScriptParser::DataType::VARIANT) { + container_type.is_meta_type = false; result.set_container_element_type(container_type); } } diff --git a/modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.gd b/modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.gd new file mode 100644 index 0000000000..9502f6e196 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.gd @@ -0,0 +1,10 @@ +class Inner: + var prop = "Inner" + + +var array: Array[Inner] = [Inner.new()] + + +func test(): + var element: Inner = array[0] + print(element.prop) diff --git a/modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.out b/modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.out new file mode 100644 index 0000000000..8f250d2632 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/typed_array_with_custom_class.out @@ -0,0 +1,2 @@ +GDTEST_OK +Inner -- cgit v1.2.3