@@ -415,7 +415,8 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
415415 push_error (" Could not resolve an empty super class path." , p_class);
416416 return ERR_PARSE_ERROR;
417417 }
418- const StringName &name = p_class->extends [extends_index++];
418+ GDScriptParser::IdentifierNode *id = p_class->extends [extends_index++];
419+ const StringName &name = id->name ;
419420 base.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
420421
421422 if (ScriptServer::is_global_class (name)) {
@@ -426,33 +427,33 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
426427 } else {
427428 Ref<GDScriptParserRef> base_parser = get_parser_for (base_path);
428429 if (base_parser.is_null ()) {
429- push_error (vformat (R"( Could not resolve super class "%s".)" , name), p_class );
430+ push_error (vformat (R"( Could not resolve super class "%s".)" , name), id );
430431 return ERR_PARSE_ERROR;
431432 }
432433
433434 Error err = base_parser->raise_status (GDScriptParserRef::INHERITANCE_SOLVED);
434435 if (err != OK) {
435- push_error (vformat (R"( Could not resolve super class inheritance from "%s".)" , name), p_class );
436+ push_error (vformat (R"( Could not resolve super class inheritance from "%s".)" , name), id );
436437 return err;
437438 }
438439 base = base_parser->get_parser ()->head ->get_datatype ();
439440 }
440441 } else if (ProjectSettings::get_singleton ()->has_autoload (name) && ProjectSettings::get_singleton ()->get_autoload (name).is_singleton ) {
441442 const ProjectSettings::AutoloadInfo &info = ProjectSettings::get_singleton ()->get_autoload (name);
442443 if (info.path .get_extension ().to_lower () != GDScriptLanguage::get_singleton ()->get_extension ()) {
443- push_error (vformat (R"( Singleton %s is not a GDScript.)" , info.name ), p_class );
444+ push_error (vformat (R"( Singleton %s is not a GDScript.)" , info.name ), id );
444445 return ERR_PARSE_ERROR;
445446 }
446447
447448 Ref<GDScriptParserRef> info_parser = get_parser_for (info.path );
448449 if (info_parser.is_null ()) {
449- push_error (vformat (R"( Could not parse singleton from "%s".)" , info.path ), p_class );
450+ push_error (vformat (R"( Could not parse singleton from "%s".)" , info.path ), id );
450451 return ERR_PARSE_ERROR;
451452 }
452453
453454 Error err = info_parser->raise_status (GDScriptParserRef::INHERITANCE_SOLVED);
454455 if (err != OK) {
455- push_error (vformat (R"( Could not resolve super class inheritance from "%s".)" , name), p_class );
456+ push_error (vformat (R"( Could not resolve super class inheritance from "%s".)" , name), id );
456457 return err;
457458 }
458459 base = info_parser->get_parser ()->head ->get_datatype ();
@@ -467,7 +468,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
467468 for (GDScriptParser::ClassNode *look_class : script_classes) {
468469 if (look_class->identifier && look_class->identifier ->name == name) {
469470 if (!look_class->get_datatype ().is_set ()) {
470- Error err = resolve_class_inheritance (look_class, p_class );
471+ Error err = resolve_class_inheritance (look_class, id );
471472 if (err) {
472473 return err;
473474 }
@@ -477,35 +478,34 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
477478 break ;
478479 }
479480 if (look_class->has_member (name)) {
480- resolve_class_member (look_class, name, p_class );
481+ resolve_class_member (look_class, name, id );
481482 base = look_class->get_member (name).get_datatype ();
482483 found = true ;
483484 break ;
484485 }
485486 }
486487
487488 if (!found) {
488- push_error (vformat (R"( Could not find base class "%s".)" , name), p_class );
489+ push_error (vformat (R"( Could not find base class "%s".)" , name), id );
489490 return ERR_PARSE_ERROR;
490491 }
491492 }
492493 }
493494
494495 for (int index = extends_index; index < p_class->extends .size (); index++) {
496+ GDScriptParser::IdentifierNode *id = p_class->extends [index];
497+
495498 if (base.kind != GDScriptParser::DataType::CLASS) {
496- push_error (R"( Super type "%s" is not a GDScript. Cannot get nested types .)" , p_class );
499+ push_error (vformat ( R"( Cannot get nested types for extension from non- GDScript type "%s" .)" , base. to_string ()), id );
497500 return ERR_PARSE_ERROR;
498501 }
499502
500- // TODO: Extends could use identifier nodes. That way errors can be pointed out properly and it can be used here.
501- GDScriptParser::IdentifierNode *id = parser->alloc_node <GDScriptParser::IdentifierNode>();
502- id->name = p_class->extends [index];
503-
504503 reduce_identifier_from_base (id, &base);
505-
506504 GDScriptParser::DataType id_type = id->get_datatype ();
505+
507506 if (!id_type.is_set ()) {
508- push_error (vformat (R"( Could not find type "%s" under base "%s".)" , id->name , base.to_string ()), p_class);
507+ push_error (vformat (R"( Could not find nested type "%s".)" , id->name ), id);
508+ return ERR_PARSE_ERROR;
509509 }
510510
511511 base = id_type;
0 commit comments