GDScript: Allow out of order member resolution
This commit is contained in:
parent
97df6de4a7
commit
2dfc6d5b69
30 changed files with 797 additions and 233 deletions
|
|
@ -1,2 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
The member "Vector2" cannot have the same name as a builtin type.
|
||||
Class "Vector2" hides a built-in type.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
func test():
|
||||
print(InnerA.new())
|
||||
|
||||
class InnerA extends InnerB:
|
||||
pass
|
||||
|
||||
class InnerB extends InnerA:
|
||||
pass
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Cyclic inheritance.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
func test():
|
||||
print(c1)
|
||||
|
||||
const c1 = c2
|
||||
const c2 = c1
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "c1": Cyclic reference.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
func test():
|
||||
print(E1.V)
|
||||
|
||||
enum E1 {V = E2.V}
|
||||
enum E2 {V = E1.V}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "E1": Cyclic reference.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
func test():
|
||||
print(EV1)
|
||||
|
||||
enum {EV1 = EV2}
|
||||
enum {EV2 = EV1}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "EV1": Cyclic reference.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
func test():
|
||||
print(v)
|
||||
|
||||
var v = A.v
|
||||
|
||||
const A = preload("cyclic_ref_external_a.notest.gd")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "v".
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
const B = preload("cyclic_ref_external.gd")
|
||||
|
||||
var v = B.v
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
func test():
|
||||
print(f1())
|
||||
print(f2())
|
||||
|
||||
static func f1(p := f2()) -> int:
|
||||
return 1
|
||||
|
||||
static func f2(p := f1()) -> int:
|
||||
return 2
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "f1": Cyclic reference.
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
func test():
|
||||
print(v)
|
||||
|
||||
var v := InnerA.new().f()
|
||||
|
||||
class InnerA:
|
||||
func f(p := InnerB.new().f()) -> int:
|
||||
return 1
|
||||
|
||||
class InnerB extends InnerA:
|
||||
func f(p := 1) -> int:
|
||||
return super.f()
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "f": Cyclic reference.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
func test():
|
||||
print(v1)
|
||||
|
||||
var v1 := v2
|
||||
var v2 := v1
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "v1": Cyclic reference.
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
func test():
|
||||
print("v1: ", v1)
|
||||
print("v1 is String: ", v1 is String)
|
||||
print("v2: ", v2)
|
||||
print("v2 is bool: ", v2 is bool)
|
||||
print("c1: ", c1)
|
||||
print("c1 is int: ", c1 is int)
|
||||
print("c2: ", c2)
|
||||
print("c2 is int: ", c2 is int)
|
||||
print("E1.V1: ", E1.V1)
|
||||
print("E1.V2: ", E1.V2)
|
||||
print("E2.V: ", E2.V)
|
||||
print("EV1: ", EV1)
|
||||
print("EV2: ", EV2)
|
||||
print("EV3: ", EV3)
|
||||
|
||||
var v1 := InnerA.new().fn()
|
||||
|
||||
class InnerA extends InnerAB:
|
||||
func fn(p2 := E1.V2) -> String:
|
||||
return "%s, p2=%s" % [super.fn(), p2]
|
||||
|
||||
class InnerAB:
|
||||
func fn(p1 := c1) -> String:
|
||||
return "p1=%s" % p1
|
||||
|
||||
var v2 := f()
|
||||
|
||||
func f() -> bool:
|
||||
return true
|
||||
|
||||
const c1 := E1.V1
|
||||
|
||||
enum E1 {
|
||||
V1 = E2.V + 2,
|
||||
V2 = V1 - 1
|
||||
}
|
||||
|
||||
enum E2 {V = 2}
|
||||
|
||||
const c2 := EV2
|
||||
|
||||
enum {
|
||||
EV1 = 42,
|
||||
EV2 = EV3 + 1
|
||||
}
|
||||
|
||||
enum {
|
||||
EV3 = EV1 + 1
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
GDTEST_OK
|
||||
v1: p1=4, p2=3
|
||||
v1 is String: true
|
||||
v2: true
|
||||
v2 is bool: true
|
||||
c1: 4
|
||||
c1 is int: true
|
||||
c2: 44
|
||||
c2 is int: true
|
||||
E1.V1: 4
|
||||
E1.V2: 3
|
||||
E2.V: 2
|
||||
EV1: 42
|
||||
EV2: 44
|
||||
EV3: 43
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
const B = preload("out_of_order_external_a.notest.gd")
|
||||
|
||||
func test():
|
||||
print("v1: ", v1)
|
||||
print("v1 is String: ", v1 is String)
|
||||
print("v2: ", v2)
|
||||
print("v2 is bool: ", v2 is bool)
|
||||
print("c1: ", c1)
|
||||
print("c1 is int: ", c1 is int)
|
||||
print("c2: ", c2)
|
||||
print("c2 is int: ", c2 is int)
|
||||
print("E1.V1: ", E1.V1)
|
||||
print("E1.V2: ", E1.V2)
|
||||
print("B.E2.V: ", B.E2.V)
|
||||
print("EV1: ", EV1)
|
||||
print("EV2: ", EV2)
|
||||
print("B.EV3: ", B.EV3)
|
||||
|
||||
var v1 := Inner.new().fn()
|
||||
|
||||
class Inner extends B.Inner:
|
||||
func fn(p2 := E1.V2) -> String:
|
||||
return "%s, p2=%s" % [super.fn(), p2]
|
||||
|
||||
var v2 := B.new().f()
|
||||
|
||||
const c1 := E1.V1
|
||||
|
||||
enum E1 {
|
||||
V1 = B.E2.V + 2,
|
||||
V2 = V1 - 1
|
||||
}
|
||||
|
||||
const c2 := EV2
|
||||
|
||||
enum {
|
||||
EV1 = 42,
|
||||
EV2 = B.EV3 + 1
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
GDTEST_OK
|
||||
v1: p1=4, p2=3
|
||||
v1 is String: true
|
||||
v2: true
|
||||
v2 is bool: true
|
||||
c1: 4
|
||||
c1 is int: true
|
||||
c2: 44
|
||||
c2 is int: true
|
||||
E1.V1: 4
|
||||
E1.V2: 3
|
||||
B.E2.V: 2
|
||||
EV1: 42
|
||||
EV2: 44
|
||||
B.EV3: 43
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
const A = preload("out_of_order_external.gd")
|
||||
|
||||
class Inner:
|
||||
func fn(p1 := A.c1) -> String:
|
||||
return "p1=%s" % p1
|
||||
|
||||
func f(p := A.c1) -> bool:
|
||||
return p is int
|
||||
|
||||
enum E2 {V = 2}
|
||||
|
||||
enum {EV3 = A.EV1 + 1}
|
||||
Loading…
Add table
Add a link
Reference in a new issue