-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70246 from adamscott/fix-class-lookup-redux
Fix GDScript base and outer classes, signals and functions lookup order
- Loading branch information
Showing
15 changed files
with
263 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
modules/gdscript/tests/scripts/analyzer/errors/outer_class_constants.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Outer: | ||
const OUTER_CONST: = 0 | ||
class Inner: | ||
pass | ||
|
||
func test() -> void: | ||
var type: = Outer.Inner | ||
print(type.OUTER_CONST) |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/errors/outer_class_constants.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
GDTEST_RUNTIME_ERROR | ||
>> SCRIPT ERROR | ||
>> on function: test() | ||
>> analyzer/errors/outer_class_constants.gd | ||
>> 8 | ||
>> Invalid get index 'OUTER_CONST' (on base: 'GDScript'). |
9 changes: 9 additions & 0 deletions
9
modules/gdscript/tests/scripts/analyzer/errors/outer_class_constants_as_variant.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Outer: | ||
const OUTER_CONST: = 0 | ||
class Inner: | ||
pass | ||
|
||
func test() -> void: | ||
var type: = Outer.Inner | ||
var type_v: Variant = type | ||
print(type_v.OUTER_CONST) |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/errors/outer_class_constants_as_variant.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
GDTEST_RUNTIME_ERROR | ||
>> SCRIPT ERROR | ||
>> on function: test() | ||
>> analyzer/errors/outer_class_constants_as_variant.gd | ||
>> 9 | ||
>> Invalid get index 'OUTER_CONST' (on base: 'GDScript'). |
8 changes: 8 additions & 0 deletions
8
modules/gdscript/tests/scripts/analyzer/errors/outer_class_instance_constants.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Outer: | ||
const OUTER_CONST: = 0 | ||
class Inner: | ||
pass | ||
|
||
func test() -> void: | ||
var instance: = Outer.Inner.new() | ||
print(instance.OUTER_CONST) |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/errors/outer_class_instance_constants.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
GDTEST_RUNTIME_ERROR | ||
>> SCRIPT ERROR | ||
>> on function: test() | ||
>> analyzer/errors/outer_class_instance_constants.gd | ||
>> 8 | ||
>> Invalid get index 'OUTER_CONST' (on base: 'RefCounted (Inner)'). |
9 changes: 9 additions & 0 deletions
9
modules/gdscript/tests/scripts/analyzer/errors/outer_class_instance_constants_as_variant.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Outer: | ||
const OUTER_CONST: = 0 | ||
class Inner: | ||
pass | ||
|
||
func test() -> void: | ||
var instance: = Outer.Inner.new() | ||
var instance_v: Variant = instance | ||
print(instance_v.OUTER_CONST) |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/errors/outer_class_instance_constants_as_variant.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
GDTEST_RUNTIME_ERROR | ||
>> SCRIPT ERROR | ||
>> on function: test() | ||
>> analyzer/errors/outer_class_instance_constants_as_variant.gd | ||
>> 9 | ||
>> Invalid get index 'OUTER_CONST' (on base: 'RefCounted (Inner)'). |
50 changes: 50 additions & 0 deletions
50
modules/gdscript/tests/scripts/analyzer/features/lookup_class.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Inner-outer class lookup | ||
class A: | ||
const Q: = "right one" | ||
|
||
class X: | ||
const Q: = "wrong one" | ||
|
||
class Y extends X: | ||
class B extends A: | ||
static func check() -> void: | ||
print(Q) | ||
|
||
# External class lookup | ||
const External: = preload("lookup_class_external.notest.gd") | ||
|
||
class Internal extends External.A: | ||
static func check() -> void: | ||
print(TARGET) | ||
|
||
class E extends External.E: | ||
static func check() -> void: | ||
print(TARGET) | ||
print(WAITING) | ||
|
||
# Variable lookup | ||
class C: | ||
var Q := 'right one' | ||
|
||
class D: | ||
const Q := 'wrong one' | ||
|
||
class E extends D: | ||
class F extends C: | ||
func check() -> void: | ||
print(Q) | ||
|
||
# Test | ||
func test() -> void: | ||
# 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() |
8 changes: 8 additions & 0 deletions
8
modules/gdscript/tests/scripts/analyzer/features/lookup_class.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
GDTEST_OK | ||
right one | ||
--- | ||
wrong | ||
right | ||
godot | ||
--- | ||
right one |
15 changes: 15 additions & 0 deletions
15
modules/gdscript/tests/scripts/analyzer/features/lookup_class_external.notest.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class A: | ||
const TARGET: = "wrong" | ||
|
||
class B: | ||
const TARGET: = "wrong" | ||
const WAITING: = "godot" | ||
|
||
class D extends C: | ||
pass | ||
|
||
class C: | ||
const TARGET: = "right" | ||
|
||
class E extends A.B.D: | ||
pass |
Oops, something went wrong.