2022-12-18 06:38:53 +01:00
|
|
|
# Inner-outer class lookup
|
|
|
|
class A:
|
2022-12-26 17:24:17 +01:00
|
|
|
const Q: = "right one"
|
2022-12-18 06:38:53 +01:00
|
|
|
|
|
|
|
class X:
|
2022-12-26 17:24:17 +01:00
|
|
|
const Q: = "wrong one"
|
2022-12-18 06:38:53 +01:00
|
|
|
|
|
|
|
class Y extends X:
|
2022-12-26 17:24:17 +01:00
|
|
|
class B extends A:
|
|
|
|
static func check() -> void:
|
|
|
|
print(Q)
|
2022-12-18 06:38:53 +01:00
|
|
|
|
|
|
|
# External class lookup
|
|
|
|
const External: = preload("lookup_class_external.notest.gd")
|
|
|
|
|
|
|
|
class Internal extends External.A:
|
2022-12-26 17:24:17 +01:00
|
|
|
static func check() -> void:
|
|
|
|
print(TARGET)
|
2022-12-18 06:38:53 +01:00
|
|
|
|
2022-12-26 17:24:17 +01:00
|
|
|
class E extends External.E:
|
|
|
|
static func check() -> void:
|
|
|
|
print(TARGET)
|
|
|
|
print(WAITING)
|
2022-12-18 06:38:53 +01:00
|
|
|
|
|
|
|
# Variable lookup
|
|
|
|
class C:
|
2022-12-26 17:24:17 +01:00
|
|
|
var Q := 'right one'
|
2022-12-18 06:38:53 +01:00
|
|
|
|
|
|
|
class D:
|
2022-12-26 17:24:17 +01:00
|
|
|
const Q := 'wrong one'
|
2022-12-18 06:38:53 +01:00
|
|
|
|
|
|
|
class E extends D:
|
2022-12-26 17:24:17 +01:00
|
|
|
class F extends C:
|
|
|
|
func check() -> void:
|
|
|
|
print(Q)
|
2022-12-18 06:38:53 +01:00
|
|
|
|
|
|
|
# Test
|
|
|
|
func test() -> void:
|
2022-12-26 17:24:17 +01:00
|
|
|
# Inner-outer class lookup
|
|
|
|
Y.B.check()
|
|
|
|
print("---")
|
|
|
|
|
|
|
|
# External class lookup
|
|
|
|
Internal.check()
|
|
|
|
Internal.E.check()
|
|
|
|
print("---")
|
|
|
|
|
|
|
|
# Variable lookup
|
|
|
|
var f: = E.F.new()
|
|
|
|
f.check()
|