Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An inner class cannot be extended out of its script file #10304

Closed
Geequlim opened this issue Aug 12, 2017 · 5 comments
Closed

An inner class cannot be extended out of its script file #10304

Geequlim opened this issue Aug 12, 2017 · 5 comments

Comments

@Geequlim
Copy link
Contributor

Operating system or device - Godot version:
Godot 3.0 alpha1

Issue description:

I cannot inherit a inner class in other script files.

The file named ItemListEnhanced.gd with a inner class ListItemProvider as below:

tool
extends ItemList

class ListItemProvider:
	func sort(p_item, p_item):
		return true
	
	func item_fit_filter(p_item, p_filter):
		return true
	
	func get_item_text(p_item):
		return str(p_item)
	
	func get_item_color(p_item):
		return Color(0, 0, 0, 0)

The editor complains Parser Error: Unknown class 'ListItemProvider' with the script code below

extends 'ItemListEnhanced.gd'

class MyItemProvider extends ListItemProvider:
	func get_item_text(p_item):
		return p_item.name

May #4472 related?

@leonkrause
Copy link
Contributor

ListItemProvider exists in the scope of the file ItemListEnhanced.gd, so you'll have to reference it like this:

class MyItemProvider extends 'ItemListEnhanced.gd'.ListItemProvider:

@Geequlim
Copy link
Contributor Author

This grammar is really strange.

@Geequlim
Copy link
Contributor Author

Just like a string with a member ListItemProvider

@bojidar-bg
Copy link
Contributor

@eska014 I think that the problem in this issue is that the script in the question
extends 'ItemListEnhanced.gd', and thus should have inherited the other scripts's scope as well.

@akien-mga
Copy link
Member

akien-mga commented Nov 20, 2017

Fixed by #12507.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants