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
0da5c3e1
Commit
0da5c3e1
authored
Jul 07, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect non-covariant return types in overriding cypclass methods
parent
cdfe4a08
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+20
-11
No files found.
Cython/Compiler/Symtab.py
View file @
0da5c3e1
...
@@ -554,8 +554,14 @@ class Scope(object):
...
@@ -554,8 +554,14 @@ class Scope(object):
cpp_override_allowed
=
True
cpp_override_allowed
=
True
continue
continue
# in a cypclass, if the arguments are compatible
# Any inherited method is visible
# then the whole signature must be identical (return type excluded)
# until overloaded by a method with the same signature
if
alt_entry
.
is_inherited
:
if
self
.
is_cyp_class_scope
:
# in a cypclass, if the arguments are compatible, then the new method must actually
# override the inherited method: the whole signature must be identical
old_declarator
=
alt_entry
.
type
.
declarator_code
(
name
,
for_display
=
1
).
strip
()
old_declarator
=
alt_entry
.
type
.
declarator_code
(
name
,
for_display
=
1
).
strip
()
new_declarator
=
type
.
declarator_code
(
name
,
for_display
=
1
).
strip
()
new_declarator
=
type
.
declarator_code
(
name
,
for_display
=
1
).
strip
()
if
not
new_declarator
==
old_declarator
:
if
not
new_declarator
==
old_declarator
:
...
@@ -565,9 +571,12 @@ class Scope(object):
...
@@ -565,9 +571,12 @@ class Scope(object):
if
alt_entry
.
pos
is
not
None
:
if
alt_entry
.
pos
is
not
None
:
error
(
alt_entry
.
pos
,
"Conflicting method is defined here"
)
error
(
alt_entry
.
pos
,
"Conflicting method is defined here"
)
# Any inherited method is visible
# also, the return type must be covariant
# until overloaded by a method with the same signature
elif
not
type
.
return_type
.
subtype_of_resolved_type
(
alt_entry
.
type
.
return_type
):
if
alt_entry
.
is_inherited
:
error
(
pos
,
"Cypclass method overrides another with incompatible return type"
)
if
alt_entry
.
pos
is
not
None
:
error
(
alt_entry
.
pos
,
"Conflicting method is defined here"
)
previous_alternative_indices
.
append
(
index
)
previous_alternative_indices
.
append
(
index
)
cpp_override_allowed
=
True
cpp_override_allowed
=
True
continue
continue
...
...
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