mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
GDScript: Add return type covariance and parameter type contravariance
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
class A:
|
||||
func f(_p: Object):
|
||||
pass
|
||||
|
||||
class B extends A:
|
||||
func f(_p: Node):
|
||||
pass
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
The function signature doesn't match the parent. Parent signature is "f(Object) -> Variant".
|
||||
@@ -0,0 +1,10 @@
|
||||
class A:
|
||||
func f(_p: Variant):
|
||||
pass
|
||||
|
||||
class B extends A:
|
||||
func f(_p: Node): # No `is_type_compatible()` misuse.
|
||||
pass
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
The function signature doesn't match the parent. Parent signature is "f(Variant) -> Variant".
|
||||
@@ -0,0 +1,10 @@
|
||||
class A:
|
||||
func f(_p: int):
|
||||
pass
|
||||
|
||||
class B extends A:
|
||||
func f(_p: float): # No implicit conversion.
|
||||
pass
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
The function signature doesn't match the parent. Parent signature is "f(int) -> Variant".
|
||||
@@ -0,0 +1,10 @@
|
||||
class A:
|
||||
func f() -> Node:
|
||||
return null
|
||||
|
||||
class B extends A:
|
||||
func f() -> Object:
|
||||
return null
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
The function signature doesn't match the parent. Parent signature is "f() -> Node".
|
||||
@@ -0,0 +1,10 @@
|
||||
class A:
|
||||
func f() -> Node:
|
||||
return null
|
||||
|
||||
class B extends A:
|
||||
func f() -> Variant: # No `is_type_compatible()` misuse.
|
||||
return null
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
The function signature doesn't match the parent. Parent signature is "f() -> Node".
|
||||
@@ -0,0 +1,10 @@
|
||||
class A:
|
||||
func f() -> Node:
|
||||
return null
|
||||
|
||||
class B extends A:
|
||||
func f() -> void: # No `is_type_compatible()` misuse.
|
||||
return
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
The function signature doesn't match the parent. Parent signature is "f() -> Node".
|
||||
@@ -0,0 +1,10 @@
|
||||
class A:
|
||||
func f() -> float:
|
||||
return 0.0
|
||||
|
||||
class B extends A:
|
||||
func f() -> int: # No implicit conversion.
|
||||
return 0
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
The function signature doesn't match the parent. Parent signature is "f() -> float".
|
||||
Reference in New Issue
Block a user