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
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):
...
@@ -40,6 +40,9 @@ class BaseType(ABC):
for
p
in
cur
.
get_parents
():
for
p
in
cur
.
get_parents
():
queue
.
put
(
p
)
queue
.
put
(
p
)
def
inherits_from
(
self
,
other
:
"BaseType"
)
->
bool
:
return
other
in
self
.
iter_hierarchy_recursive
()
def
resolve
(
self
)
->
"BaseType"
:
def
resolve
(
self
)
->
"BaseType"
:
return
self
return
self
...
@@ -219,25 +222,27 @@ class TypeOperator(BaseType, ABC):
...
@@ -219,25 +222,27 @@ class TypeOperator(BaseType, ABC):
return
other
.
unify_internal
(
self
)
return
other
.
unify_internal
(
self
)
if
self
.
is_protocol
and
not
other
.
is_protocol
:
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
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
assert
self
.
is_protocol
==
other
.
is_protocol
if
type
(
self
)
!=
type
(
other
):
if
type
(
self
)
!=
type
(
other
):
# and ((TY_NONE not in {self, other}) or isinstance(({self, other} - {TY_NONE}).pop(), UnionType)):
for
parent
in
other
.
get_parents
():
if
self
.
inherits_from
(
other
)
or
other
.
inherits_from
(
self
):
try
:
return
self
.
unify
(
parent
)
# for parent in other.get_parents():
except
TypeMismatchError
:
# try:
pass
# self.unify(parent)
else
:
# except TypeMismatchError:
return
# pass
for
parent
in
self
.
get_parents
():
# else:
try
:
# return
parent
.
unify
(
other
)
# for parent in self.get_parents():
except
TypeMismatchError
:
# try:
pass
# parent.unify(other)
else
:
# except TypeMismatchError:
return
# pass
# else:
# return
raise
TypeMismatchError
(
self
,
other
,
TypeMismatchKind
.
DIFFERENT_TYPE
)
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
len
(
self
.
args
)
==
0
:
if
self
.
name
!=
other
.
name
:
if
self
.
name
!=
other
.
name
:
raise
TypeMismatchError
(
self
,
other
,
TypeMismatchKind
.
DIFFERENT_TYPE
)
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