summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd7
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd2
4 files changed, 21 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 7d14bcf3c4..3bbe71fb90 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -3148,6 +3148,16 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
case GDScriptParser::ClassNode::Member::FUNCTION:
p_identifier->set_datatype(make_callable_type(member.function->info));
break;
+ case GDScriptParser::ClassNode::Member::CLASS:
+ if (p_base != nullptr && p_base->is_constant) {
+ Error err = OK;
+ GDScript *scr = GDScriptCache::get_full_script(base.script_path, err).ptr();
+ ERR_FAIL_COND_MSG(err != OK, "Error while getting subscript full script.");
+ scr = scr->find_class(p_identifier->get_datatype().class_type->fqcn);
+ p_identifier->reduced_value = scr;
+ p_identifier->is_constant = true;
+ }
+ break;
default:
break; // Type already set.
}
diff --git a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd
new file mode 100644
index 0000000000..ed5fb18b73
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd
@@ -0,0 +1,7 @@
+const External = preload("inner_class_constant_assignment_external.notest.gd")
+const ExternalInnerClass = External.InnerClass
+
+func test():
+ var inst_external: ExternalInnerClass = ExternalInnerClass.new()
+ inst_external.x = 4.0
+ print(inst_external.x)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out
new file mode 100644
index 0000000000..15666c46ad
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+4
diff --git a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd
new file mode 100644
index 0000000000..788c99d469
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd
@@ -0,0 +1,2 @@
+class InnerClass:
+ var x: = 3.0