Class inheritance "Could not resolve"

Godot Version

Godot 4.4

Question

I am having trouble tracking an issue I am having with inheritance

extends RigidBody2D
class_name CurrencyBody

enum VARIANT {SINGLE_PAGE, SCROLL_STACK}
const SCENE_PATHS: Dictionary[VARIANT, PackedScene] = {
	VARIANT.SINGLE_PAGE: preload("res://scenes/objects/pickables/currency_single_page.tscn"),
	VARIANT.SCROLL_STACK: preload("res://scenes/objects/pickables/currency_scroll_stack.tscn")
}

static func new_currency_body(variant:VARIANT) -> CurrencyBody:
	var new_currency_body: CurrencyBody = SCENE_PATHS[variant].instantiate()
	return new_currency_body

this leads to Parser Error: Could not resolve class "CurrencyBody".

but if I comment any of the two variants out in the dictionary, it works…

const SCENE_PATHS: Dictionary[VARIANT, PackedScene] = {
	VARIANT.SINGLE_PAGE: preload("res://scenes/objects/pickables/currency_single_page.tscn"),
	#VARIANT.SCROLL_STACK: preload("res://scenes/objects/pickables/currency_scroll_stack.tscn")
}

Each scene root node is a new class which extends CurrencyBody.

Any help would be greatly appreciated!

You may have a cyclical dependency. Try storing the file paths and load dynamically

enum VARIANT {SINGLE_PAGE, SCROLL_STACK}
const SCENE_PATHS: Dictionary[VARIANT, String] = {
	VARIANT.SINGLE_PAGE: "res://scenes/objects/pickables/currency_single_page.tscn",
	VARIANT.SCROLL_STACK: "res://scenes/objects/pickables/currency_scroll_stack.tscn"
}

static func new_currency_body(variant:VARIANT) -> CurrencyBody:
	var new_currency_body: CurrencyBody = load(SCENE_PATHS[variant]).instantiate()
	return new_currency_body

Yeah that was the solution I went for for now, but it’s not ideal as I’m instantiating many of the objects per frame often. But thanks for the suggestion!