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
6374abcf
Commit
6374abcf
authored
Aug 13, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix substitution of Self type in functions
parent
3b51dc29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
trans/transpiler/phases/typing/expr.py
trans/transpiler/phases/typing/expr.py
+2
-1
trans/transpiler/phases/typing/types.py
trans/transpiler/phases/typing/types.py
+2
-1
No files found.
trans/transpiler/phases/typing/expr.py
View file @
6374abcf
...
@@ -105,7 +105,7 @@ class ScoperExprVisitor(ScoperVisitor):
...
@@ -105,7 +105,7 @@ class ScoperExprVisitor(ScoperVisitor):
def
visit_Call
(
self
,
node
:
ast
.
Call
)
->
BaseType
:
def
visit_Call
(
self
,
node
:
ast
.
Call
)
->
BaseType
:
ftype
=
self
.
visit
(
node
.
func
)
ftype
=
self
.
visit
(
node
.
func
)
if
ftype
.
typevars
:
if
ftype
.
typevars
:
ftype
=
ftype
.
gen_sub
(
Non
e
,
{
v
.
name
:
TypeVariable
(
v
.
name
)
for
v
in
ftype
.
typevars
})
ftype
=
ftype
.
gen_sub
(
ftyp
e
,
{
v
.
name
:
TypeVariable
(
v
.
name
)
for
v
in
ftype
.
typevars
})
rtype
=
self
.
visit_function_call
(
ftype
,
[
self
.
visit
(
arg
)
for
arg
in
node
.
args
])
rtype
=
self
.
visit_function_call
(
ftype
,
[
self
.
visit
(
arg
)
for
arg
in
node
.
args
])
actual
=
rtype
actual
=
rtype
node
.
is_await
=
False
node
.
is_await
=
False
...
@@ -174,6 +174,7 @@ class ScoperExprVisitor(ScoperVisitor):
...
@@ -174,6 +174,7 @@ class ScoperExprVisitor(ScoperVisitor):
attr
.
python_func_used
=
True
attr
.
python_func_used
=
True
return
attr
return
attr
if
meth
:
=
ltype
.
methods
.
get
(
name
):
if
meth
:
=
ltype
.
methods
.
get
(
name
):
meth
=
meth
.
gen_sub
(
ltype
,
{})
if
bound
:
if
bound
:
return
meth
.
remove_self
()
return
meth
.
remove_self
()
else
:
else
:
...
...
trans/transpiler/phases/typing/types.py
View file @
6374abcf
...
@@ -241,9 +241,10 @@ class TypeOperator(BaseType, ABC):
...
@@ -241,9 +241,10 @@ class TypeOperator(BaseType, ABC):
return
me
return
me
if
len
(
self
.
args
)
==
0
:
if
len
(
self
.
args
)
==
0
:
return
self
return
self
assert
all
(
x
is
not
None
for
x
in
self
.
args
)
res
=
object
.
__new__
(
self
.
__class__
)
# todo: ugly... should make a clone()
res
=
object
.
__new__
(
self
.
__class__
)
# todo: ugly... should make a clone()
cache
[
self
]
=
res
cache
[
self
]
=
res
if
isinstance
(
this
,
TypeOperator
):
if
isinstance
(
this
,
TypeOperator
)
and
not
isinstance
(
this
,
FunctionType
)
:
vardict
=
dict
(
zip
(
typevars
.
keys
(),
this
.
args
))
vardict
=
dict
(
zip
(
typevars
.
keys
(),
this
.
args
))
else
:
else
:
vardict
=
typevars
vardict
=
typevars
...
...
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