-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing expansions on recursive generic types
- Loading branch information
1 parent
2bc37d4
commit b8546f9
Showing
15 changed files
with
106 additions
and
524 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
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
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
513 changes: 0 additions & 513 deletions
513
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/builtin/BasicTypeMembers.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
|
||
val a = [5, 1, 2, 4, 3]; | ||
a.sort(); | ||
println(a); | ||
println(a); |
1 change: 0 additions & 1 deletion
1
ScriptingEngineTester/src/main/resources/zencode_tests/arrays/sort_2.zc
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
33 changes: 33 additions & 0 deletions
33
ScriptingEngineTester/src/main/resources/zencode_tests/expansions/expand_generic.zc
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,33 @@ | ||
#output: T-5 | ||
#output: T-3 | ||
#output: T-3 | ||
#output: T-4 | ||
#output: T-2 | ||
|
||
interface Comparable<T> { | ||
compareTo(other: T): int; | ||
} | ||
|
||
expand <T : Comparable<T>> T[] { | ||
sort(): void {} | ||
} | ||
|
||
public class TicketNumber { | ||
private var value as int; | ||
|
||
public implements Comparable<TicketNumber> { | ||
compareTo(other) => this.value - other.value; | ||
} | ||
|
||
public implicit as string => "T-" + value; | ||
} | ||
|
||
val a = [ | ||
new TicketNumber(5), | ||
new TicketNumber(3), | ||
new TicketNumber(3), | ||
new TicketNumber(4), | ||
new TicketNumber(2), | ||
]; | ||
a.sort(); | ||
for ticket in a println(ticket); |
35 changes: 35 additions & 0 deletions
35
ScriptingEngineTester/src/main/resources/zencode_tests/expansions/expand_generic_2.zc
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,35 @@ | ||
#output: T-5 | ||
#output: T-3 | ||
#output: T-3 | ||
#output: T-4 | ||
#output: T-2 | ||
|
||
interface Comparable<T> { | ||
compareTo(other: T): int; | ||
} | ||
|
||
expand <T : Comparable<T>> T[] { | ||
sort(): void {} | ||
} | ||
|
||
public class TicketNumber { | ||
private var value as int; | ||
|
||
public implicit as string => "T-" + value; | ||
} | ||
|
||
expand TicketNumber { | ||
public implements Comparable<TicketNumber> { | ||
compareTo(other) => this.value - other.value; | ||
} | ||
} | ||
|
||
val a = [ | ||
new TicketNumber(5), | ||
new TicketNumber(3), | ||
new TicketNumber(3), | ||
new TicketNumber(4), | ||
new TicketNumber(2), | ||
]; | ||
a.sort(); | ||
for ticket in a println(ticket); |