Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
818d1aa9
Commit
818d1aa9
authored
Jun 10, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove *all* overriden entries from the overloaded alternatives (not just the first)
parent
28f904d3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
19 deletions
+25
-19
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+25
-19
No files found.
Cython/Compiler/Symtab.py
View file @
818d1aa9
...
@@ -513,34 +513,33 @@ class Scope(object):
...
@@ -513,34 +513,33 @@ class Scope(object):
entries
=
self
.
entries
entries
=
self
.
entries
# The index of an overridable overloaded alternative that this declaration will hide.
# The indices of an overridable overloaded alternatives that this declaration will hide.
# Stays -1 if there isn't one.
previous_alternative_indices
=
[]
previous_alternative_index
=
-
1
if
name
and
name
in
entries
and
not
shadow
:
if
name
and
name
in
entries
and
not
shadow
:
old_entry
=
entries
[
name
]
old_entry
=
entries
[
name
]
# Reject redeclared C++ functions only if they have the same type signature.
# Reject redeclared C++ functions only if they have the same type signature.
cpp_override_allowed
=
False
cpp_override_allowed
=
False
if
type
.
is_cfunction
and
old_entry
.
type
.
is_cfunction
and
self
.
is_cpp
():
if
type
.
is_cfunction
and
old_entry
.
type
.
is_cfunction
and
self
.
is_cpp
():
cpp_override_allowed
=
True
for
index
,
alt_entry
in
enumerate
(
old_entry
.
all_alternatives
()):
for
index
,
alt_entry
in
enumerate
(
old_entry
.
all_alternatives
()):
if
type
.
compatible_signature_with
(
alt_entry
.
type
):
if
type
.
compatible_signature_with
(
alt_entry
.
type
):
cpp_override_allowed
=
False
# If we're not in a cypclass, any inherited method is visible
# If we're not in a cypclass, any inherited method is visible
# until overloaded by a method with the same sig
an
ture
# until overloaded by a method with the same sig
na
ture
if
not
(
self
.
type
and
self
.
type
.
is_cyp_class
):
if
not
(
self
.
type
and
self
.
type
.
is_cyp_class
):
if
alt_entry
.
is_inherited
:
if
alt_entry
.
is_inherited
:
previous_alternative_index
=
index
previous_alternative_indices
.
append
(
index
)
cpp_override_allowed
=
True
# In a cypclass, only the predeclared default constructor and __alloc__ are allowed to be redeclared.
# In a cypclass, only the predeclared default constructor and __alloc__ are allowed to be redeclared.
# We don't have to deal with inherited entries because they are hidden as soon as the subclass has a method
# We don't have to deal with inherited entries because they are hidden as soon as the subclass has a method
# of the same name, regardless of the exact signature (this is also C++ behavior by default).
# of the same name, regardless of the exact signature (this is also C++ behavior by default).
# The default entry is overriden when there is a subsequent entry with a compatible signature.
# The default entry is overriden when there is a subsequent entry with a compatible signature.
elif
alt_entry
.
is_default
:
elif
alt_entry
.
is_default
:
previous_alternative_index
=
index
previous_alternative_indices
.
append
(
index
)
cpp_override_allowed
=
True
break
else
:
cpp_override_allowed
=
True
cpp_override_allowed
=
True
if
cpp_override_allowed
:
if
cpp_override_allowed
:
...
@@ -565,18 +564,25 @@ class Scope(object):
...
@@ -565,18 +564,25 @@ class Scope(object):
if
not
shadow
:
if
not
shadow
:
if
name
in
entries
and
self
.
is_cpp_class_scope
and
type
.
is_cfunction
:
if
name
in
entries
and
self
.
is_cpp_class_scope
and
type
.
is_cfunction
:
if
previous_alternative_index
==
-
1
:
# sort the indices in decreasing order
# if no previous alternative is hidden by this one, just add it to the list
previous_alternative_indices
.
reverse
()
entries
[
name
].
overloaded_alternatives
.
append
(
entry
)
elif
previous_alternative_index
>
0
:
# if there is a now hidden previous alternative, replace it
entries
[
name
].
overloaded_alternatives
[
previous_alternative_index
-
1
]
=
entry
else
:
# remplace the first hidden entry with the new entry
# if the first previous alternative is now hidden, replace it
if
previous_alternative_indices
:
first_index
=
previous_alternative_indices
.
pop
()
if
first_index
==
0
:
entry
.
overloaded_alternatives
=
entries
[
name
].
overloaded_alternatives
entry
.
overloaded_alternatives
=
entries
[
name
].
overloaded_alternatives
entries
[
name
]
=
entry
entries
[
name
]
=
entry
else
:
entries
[
name
].
overloaded_alternatives
[
first_index
-
1
]
=
entry
# if no entries are hidden by the new entry, just add it to the alternatives
else
:
entries
[
name
].
overloaded_alternatives
.
append
(
entry
)
# outright remove the entries for the remaining indices (the first index was removed)
for
index
in
previous_alternative_indices
:
del
entries
[
name
].
overloaded_alternatives
[
index
-
1
]
else
:
else
:
entries
[
name
]
=
entry
entries
[
name
]
=
entry
...
...
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