Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
944721b8
Commit
944721b8
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `Self` handling in classes
parent
af719a0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
trans/transpiler/phases/typing/annotations.py
trans/transpiler/phases/typing/annotations.py
+4
-1
trans/transpiler/phases/typing/block.py
trans/transpiler/phases/typing/block.py
+3
-2
No files found.
trans/transpiler/phases/typing/annotations.py
View file @
944721b8
...
...
@@ -15,7 +15,10 @@ class TypeAnnotationVisitor(NodeVisitorSeq):
def
visit_str
(
self
,
node
:
str
)
->
BaseType
:
if
node
in
(
"Self"
,
"self"
)
and
self
.
cur_class
:
return
TY_SELF
if
isinstance
(
self
.
cur_class
.
type_object
,
abc
.
ABCMeta
)
or
self
.
cur_class
.
type_object
.
is_protocol_gen
or
self
.
cur_class
.
type_object
.
is_protocol
:
return
TY_SELF
else
:
return
self
.
cur_class
.
type_object
if
existing
:
=
self
.
scope
.
get
(
node
):
ty
=
existing
.
type
if
isinstance
(
ty
,
TypeType
)
and
isinstance
(
ty
.
type_object
,
TypeVariable
):
...
...
trans/transpiler/phases/typing/block.py
View file @
944721b8
...
...
@@ -116,13 +116,14 @@ class ScoperBlockVisitor(ScoperVisitor):
def
visit_ClassDef
(
self
,
node
:
ast
.
ClassDef
):
ctype
=
UserType
(
node
.
name
)
self
.
scope
.
vars
[
node
.
name
]
=
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
ctype
))
cttype
=
TypeType
(
ctype
)
self
.
scope
.
vars
[
node
.
name
]
=
VarDecl
(
VarKind
.
LOCAL
,
cttype
)
scope
=
self
.
scope
.
child
(
ScopeKind
.
CLASS
)
scope
.
obj_type
=
ctype
scope
.
class_
=
scope
node
.
inner_scope
=
scope
node
.
type
=
ctype
visitor
=
ScoperClassVisitor
(
scope
)
visitor
=
ScoperClassVisitor
(
scope
,
cur_class
=
cttype
)
visitor
.
visit_block
(
node
.
body
)
def
visit_If
(
self
,
node
:
ast
.
If
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment