Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-concurrency
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
Xavier Thompson
typon-concurrency
Commits
a1a9860c
Commit
a1a9860c
authored
Aug 23, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inheritance unification
parent
4a3f371d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
trans/transpiler/phases/typing/types.py
trans/transpiler/phases/typing/types.py
+22
-17
No files found.
trans/transpiler/phases/typing/types.py
View file @
a1a9860c
...
...
@@ -40,6 +40,9 @@ class BaseType(ABC):
for
p
in
cur
.
get_parents
():
queue
.
put
(
p
)
def
inherits_from
(
self
,
other
:
"BaseType"
)
->
bool
:
return
other
in
self
.
iter_hierarchy_recursive
()
def
resolve
(
self
)
->
"BaseType"
:
return
self
...
...
@@ -219,25 +222,27 @@ class TypeOperator(BaseType, ABC):
return
other
.
unify_internal
(
self
)
if
self
.
is_protocol
and
not
other
.
is_protocol
:
return
other
.
matches_protocol
(
self
)
# TODO: doesn't print the correct type in the error message
if
len
(
self
.
args
)
<
len
(
other
.
args
):
return
other
.
unify_internal
(
self
)
assert
self
.
is_protocol
==
other
.
is_protocol
if
type
(
self
)
!=
type
(
other
):
for
parent
in
other
.
get_parents
():
try
:
self
.
unify
(
parent
)
except
TypeMismatchError
:
pass
else
:
return
for
parent
in
self
.
get_parents
():
try
:
parent
.
unify
(
other
)
except
TypeMismatchError
:
pass
else
:
return
if
type
(
self
)
!=
type
(
other
):
# and ((TY_NONE not in {self, other}) or isinstance(({self, other} - {TY_NONE}).pop(), UnionType)):
if
self
.
inherits_from
(
other
)
or
other
.
inherits_from
(
self
):
return
# for parent in other.get_parents():
# try:
# self.unify(parent)
# except TypeMismatchError:
# pass
# else:
# return
# for parent in self.get_parents():
# try:
# parent.unify(other)
# except TypeMismatchError:
# pass
# else:
# return
raise
TypeMismatchError
(
self
,
other
,
TypeMismatchKind
.
DIFFERENT_TYPE
)
if
len
(
self
.
args
)
<
len
(
other
.
args
):
return
other
.
unify_internal
(
self
)
if
len
(
self
.
args
)
==
0
:
if
self
.
name
!=
other
.
name
:
raise
TypeMismatchError
(
self
,
other
,
TypeMismatchKind
.
DIFFERENT_TYPE
)
...
...
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