-
Notifications
You must be signed in to change notification settings - Fork 0
fix: nested types remaining fixes (#591–#594) #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
df3dce1
feat: add decorator support to EnumDef for access modifiers (#592)
antonsynd 2feaeef
fix: resolve generic nested types via dotted-name lookup (#594)
antonsynd 4e6e60c
fix: allow nested types to access enclosing type's private/protected …
antonsynd 345ee12
feat: serialize/deserialize nested types in SymbolSerializer (#591)
antonsynd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/Sharpy.Compiler.Tests/Integration/TestFixtures/errors/dataclass_on_enum.error
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| Decorators can only be applied to functions, classes, structs, interfaces, properties, events, or field declarations | ||
| The '@dataclass' decorator can only be applied to classes, not to enum 'Color'. |
1 change: 1 addition & 0 deletions
1
...iler.Tests/Integration/TestFixtures/nested_types/nested_access_enclosing_private.expected
This file contains hidden or 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 @@ | ||
| 42 |
15 changes: 15 additions & 0 deletions
15
....Compiler.Tests/Integration/TestFixtures/nested_types/nested_access_enclosing_private.spy
This file contains hidden or 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 Outer: | ||
| __secret: int | ||
|
|
||
| def __init__(self, val: int): | ||
| self.__secret = val | ||
|
|
||
| @public | ||
| class Inner: | ||
| def reveal(self, outer: Outer) -> int: | ||
| return outer.__secret | ||
|
|
||
| def main(): | ||
| o: Outer = Outer(42) | ||
| i: Outer.Inner = Outer.Inner() | ||
| print(i.reveal(o)) |
1 change: 1 addition & 0 deletions
1
...er.Tests/Integration/TestFixtures/nested_types/nested_access_enclosing_protected.expected
This file contains hidden or 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 @@ | ||
| 99 |
15 changes: 15 additions & 0 deletions
15
...ompiler.Tests/Integration/TestFixtures/nested_types/nested_access_enclosing_protected.spy
This file contains hidden or 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 Base: | ||
| _value: int | ||
|
|
||
| def __init__(self, val: int): | ||
| self._value = val | ||
|
|
||
| @public | ||
| class Helper: | ||
| def get_value(self, b: Base) -> int: | ||
| return b._value | ||
|
|
||
| def main(): | ||
| b: Base = Base(99) | ||
| h: Base.Helper = Base.Helper() | ||
| print(h.get_value(b)) |
1 change: 1 addition & 0 deletions
1
src/Sharpy.Compiler.Tests/Integration/TestFixtures/nested_types/nested_enum.spy
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| class TrafficLight: | ||
| @public | ||
| enum State: | ||
| Red = 1 | ||
| Yellow = 2 | ||
|
|
||
3 changes: 3 additions & 0 deletions
3
src/Sharpy.Compiler.Tests/Integration/TestFixtures/nested_types/nested_enum_public.expected
This file contains hidden or 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,3 @@ | ||
| Blue | ||
| Square | ||
| Green |
22 changes: 22 additions & 0 deletions
22
src/Sharpy.Compiler.Tests/Integration/TestFixtures/nested_types/nested_enum_public.spy
This file contains hidden or 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,22 @@ | ||
| class Container: | ||
| @public | ||
| enum Color: | ||
| Red = 1 | ||
| Blue = 2 | ||
| Green = 3 | ||
|
|
||
| enum Shape: | ||
| Circle = 1 | ||
| Square = 2 | ||
|
|
||
| def show_color(self) -> str: | ||
| return str(Container.Color.Blue) | ||
|
|
||
| def show_shape(self) -> str: | ||
| return str(Container.Shape.Square) | ||
|
|
||
| def main(): | ||
| c: Container = Container() | ||
| print(c.show_color()) | ||
| print(c.show_shape()) | ||
| print(Container.Color.Green) |
1 change: 0 additions & 1 deletion
1
src/Sharpy.Compiler.Tests/Integration/TestFixtures/nested_types/nested_generic.skip
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nested generic instantiation path uses
NameMangler.ToPascalCaseand a string-basedouterName+ParseName(...)to build the type name. This can diverge from existing nested-type codegen (BuildNestedTypeName) which usesNameMangler.Transform(..., NameContext.Type)to handle keywords/backtick-escaped identifiers consistently. Consider reusingBuildNestedTypeName(or the sameNameMangler.Transformlogic) when formingqualifiedGenericNameso nested generic types emit the same mangled names as non-generic nested types.