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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
f6a5ca9b
Commit
f6a5ca9b
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
040f00ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
20 deletions
+26
-20
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+26
-20
No files found.
Cython/Compiler/Symtab.py
View file @
f6a5ca9b
...
...
@@ -485,35 +485,34 @@ class Scope(object):
entries
=
self
.
entries
# The index of an overridable overloaded alternative that this declaration will hide.
# Stays -1 if there isn't one.
previous_alternative_index
=
-
1
# The indices of an overridable overloaded alternatives that this declaration will hide.
previous_alternative_indices
=
[]
if
name
and
name
in
entries
and
not
shadow
:
old_entry
=
entries
[
name
]
# Reject redeclared C++ functions only if they have the same type signature.
cpp_override_allowed
=
False
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
()):
if
type
.
compatible_signature_with
(
alt_entry
.
type
):
ccp_override_allowed
=
False
# 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
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.
# 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).
# The default entry is overriden when there is a subsequent entry with a compatible signature.
elif
alt_entry
.
is_default
:
previous_alternative_index
=
index
cpp_override_allowed
=
True
break
else
:
cpp_override_allowed
=
True
previous_alternative_indices
.
append
(
index
)
ccp_override_allowed
=
True
if
cpp_override_allowed
:
# C++ function/method overrides with different signatures are ok.
...
...
@@ -537,18 +536,25 @@ class Scope(object):
if
not
shadow
:
if
name
in
entries
and
self
.
is_cpp_class_scope
and
type
.
is_cfunction
:
if
previous_alternative_index
==
-
1
:
# if no previous alternative is hidden by this one, just add it to the list
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
# sort the indices in decreasing order
previous_alternative_indices
.
reverse
()
else
:
# if the first previous alternative is now hidden, replace it
# remplace the first hidden entry with the new entry
if
previous_alternative_indices
:
first_index
=
previous_alternative_indices
.
pop
()
if
first_index
==
0
:
entry
.
overloaded_alternatives
=
entries
[
name
].
overloaded_alternatives
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
:
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