1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Remove script class checks when getting function signature

This commit is contained in:
Adam Scott
2023-01-26 17:15:51 -05:00
committed by Rémi Verschelde
parent 3f02cf7ced
commit 0fef203b1f
13 changed files with 65 additions and 13 deletions

View File

@@ -0,0 +1,5 @@
const TestClass = preload("gdscript_duplicate_class.notest.gd")
func test():
# (TestClass as GDScript).duplicate() exists
TestClass.duplicate()

View File

@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot call non-static function "duplicate()" on a class directly. Make an instance instead.

View File

@@ -0,0 +1 @@
extends Node

View File

@@ -0,0 +1,6 @@
const TestClass = preload("gdscript_duplicate_class.notest.gd")
func test():
# TestClass.duplicate() fails
@warning_ignore("return_value_discarded")
(TestClass as GDScript).duplicate()

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,13 @@
# https://github.com/godotengine/godot/issues/71994
func test():
pass
class A extends RefCounted:
pass
class B extends A:
# Parsing `duplicate()` here would throw this error:
# Parse Error: The function signature doesn't match the parent. Parent signature is "duplicate(bool = default) -> Resource".
func duplicate():
pass

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,19 @@
const PreloadClass = preload("static_duplicate_preload.notest.gd")
const PreloadClassAlias = PreloadClass
func test():
var dup_preload_one = PreloadClass.duplicate()
print(dup_preload_one == Vector2.ONE)
var dup_preload_two = (PreloadClass as GDScript).duplicate()
print(dup_preload_two is GDScript)
var dup_preload_alias_one = PreloadClassAlias.duplicate()
print(dup_preload_alias_one == Vector2.ONE)
var dup_preload_alias_two = (PreloadClassAlias as GDScript).duplicate()
print(dup_preload_alias_two is GDScript)
var PreloadClassAsGDScript = PreloadClass as GDScript
var dup_preload_class_as_gdscript_one = PreloadClassAsGDScript.duplicate()
print(dup_preload_class_as_gdscript_one is GDScript)

View File

@@ -0,0 +1,9 @@
GDTEST_OK
preload duplicate
true
true
preload duplicate
true
true
preload duplicate
false

View File

@@ -0,0 +1,5 @@
extends RefCounted
static func duplicate() -> Vector2:
print("preload duplicate")
return Vector2.ONE