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
fb8e2af1
Commit
fb8e2af1
authored
May 29, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify handling of inherited methods hidden by a subclass method
parent
7c9beb0a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
29 deletions
+19
-29
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+19
-29
No files found.
Cython/Compiler/Symtab.py
View file @
fb8e2af1
...
...
@@ -481,11 +481,9 @@ class Scope(object):
entries
=
self
.
entries
# The index of an inherited c method among the overloaded alternatives in a cpp class
old_index
=
-
1
# The index of the predeclared default constructor among the alternative constructors in a cypclass
cpp_no_args_constructor_index
=
-
1
# The index of an overridable overloaded alternative that this declaration will hide.
# Stays -1 if there isn't one.
previous_alternative_index
=
-
1
if
name
and
name
in
entries
and
not
shadow
:
old_entry
=
entries
[
name
]
...
...
@@ -495,17 +493,18 @@ class Scope(object):
for
index
,
alt_entry
in
enumerate
(
old_entry
.
all_alternatives
()):
if
type
.
compatible_signature_with
(
alt_entry
.
type
):
# If we're not in a cypclass, keep the same behaviour as before
# If we're not in a cypclass, any inherited method is visible
# until overloaded by a method with the same siganture
if
not
(
self
.
type
and
self
.
type
.
is_cyp_class
):
if
alt_entry
.
is_inherited
:
old
_index
=
index
previous_alternative
_index
=
index
# In a cypclass, only the predeclared default constructor is 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)
elif
name
==
'<constructor>'
and
(
not
type
.
args
or
len
(
type
.
args
)
==
type
.
optional_arg_count
):
# Cython pre-declares the no-args constructor - allow later user definitions.
cpp_no_args_constructor
_index
=
index
previous_alternative
_index
=
index
cpp_override_allowed
=
True
break
...
...
@@ -534,27 +533,18 @@ class Scope(object):
if
not
shadow
:
if
name
in
entries
and
self
.
is_cpp_class_scope
and
type
.
is_cfunction
:
# If we're not in a cypclass, keep the same behaviour as before
if
not
(
self
.
type
and
self
.
type
.
is_cyp_class
):
if
old_index
>
-
1
:
if
old_index
>
0
:
entries
[
name
].
overloaded_alternatives
[
old_index
-
1
]
=
entry
else
:
entry
.
overloaded_alternatives
=
entries
[
name
].
overloaded_alternatives
entries
[
name
]
=
entry
else
:
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
)
# In a cypclass, only the predeclared default constructor might need to be replaced
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
:
if
cpp_no_args_constructor_index
==
0
:
# if the first previous alternative is now hidden, replace it
entry
.
overloaded_alternatives
=
entries
[
name
].
overloaded_alternatives
entries
[
name
]
=
entry
elif
cpp_no_args_constructor_index
>
0
:
entries
[
name
].
overloaded_alternatives
[
cpp_no_args_constructor_index
-
1
]
=
entry
else
:
entries
[
name
].
overloaded_alternatives
.
append
(
entry
)
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