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
bca614e2
Commit
bca614e2
authored
Jul 03, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforce stricter cypclass overloading rules
parent
02a57572
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
24 deletions
+20
-24
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+9
-5
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+11
-19
No files found.
Cython/Compiler/PyrexTypes.py
View file @
bca614e2
...
@@ -3094,8 +3094,8 @@ class CFuncType(CType):
...
@@ -3094,8 +3094,8 @@ class CFuncType(CType):
return
rhs_type
.
same_c_signature_as_resolved_type
(
self
,
exact_semantics
=
False
)
\
return
rhs_type
.
same_c_signature_as_resolved_type
(
self
,
exact_semantics
=
False
)
\
and
not
(
self
.
nogil
and
not
rhs_type
.
nogil
)
and
not
(
self
.
nogil
and
not
rhs_type
.
nogil
)
def
declarat
ion
_code
(
self
,
entity_code
,
def
declarat
or
_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
,
for_display
=
0
,
pyrex
=
0
,
with_calling_convention
=
1
):
with_calling_convention
=
1
):
arg_decl_list
=
[]
arg_decl_list
=
[]
for
arg
in
self
.
args
[:
len
(
self
.
args
)
-
self
.
optional_arg_count
]:
for
arg
in
self
.
args
[:
len
(
self
.
args
)
-
self
.
optional_arg_count
]:
...
@@ -3132,9 +3132,13 @@ class CFuncType(CType):
...
@@ -3132,9 +3132,13 @@ class CFuncType(CType):
cc
=
""
cc
=
""
if
self
.
is_const_method
:
if
self
.
is_const_method
:
trailer
+=
" const"
trailer
+=
" const"
return
self
.
return_type
.
declaration_code
(
return
"%s%s(%s)%s"
%
(
cc
,
entity_code
,
arg_decl_code
,
trailer
)
"%s%s(%s)%s"
%
(
cc
,
entity_code
,
arg_decl_code
,
trailer
),
for_display
,
dll_linkage
,
pyrex
)
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
,
with_calling_convention
=
1
):
declarator_code
=
self
.
declarator_code
(
entity_code
,
for_display
,
pyrex
,
with_calling_convention
)
return
self
.
return_type
.
declaration_code
(
declarator_code
,
for_display
,
dll_linkage
,
pyrex
)
def
function_header_code
(
self
,
func_name
,
arg_code
):
def
function_header_code
(
self
,
func_name
,
arg_code
):
if
self
.
is_const_method
:
if
self
.
is_const_method
:
...
...
Cython/Compiler/Symtab.py
View file @
bca614e2
...
@@ -554,28 +554,20 @@ class Scope(object):
...
@@ -554,28 +554,20 @@ class Scope(object):
cpp_override_allowed
=
True
cpp_override_allowed
=
True
continue
continue
# in a cypclass, if the arguments are compatible
# then the whole signature must be identical (return type excluded)
old_declarator
=
alt_entry
.
type
.
declarator_code
(
name
,
for_display
=
1
).
strip
()
new_declarator
=
type
.
declarator_code
(
name
,
for_display
=
1
).
strip
()
if
not
new_declarator
==
old_declarator
:
comparison_message
=
" ---> %s
\
n
vs -> %s"
%
(
new_declarator
,
old_declarator
)
error
(
pos
,
"Cypclass method with compatible arguments but incompatible signature:
\
n
%s"
%
comparison_message
)
if
alt_entry
.
pos
is
not
None
:
error
(
alt_entry
.
pos
,
"Conflicting method is defined here"
)
# Any inherited method is visible
# Any inherited method is visible
# until overloaded by a method with the same signature
# until overloaded by a method with the same signature
if
alt_entry
.
is_inherited
:
if
alt_entry
.
is_inherited
:
# in a cypclass, if the arguments are compatible
# then the whole signature must also be compatible
if
self
.
is_cyp_class_scope
:
if
not
type
.
compatible_signature_with
(
alt_entry
.
type
,
skip_args
=
1
):
error
(
pos
,
"Cypclass overriding method with incompatible return type"
)
if
alt_entry
.
pos
is
not
None
:
error
(
alt_entry
.
pos
,
"Overriden method is defined here"
)
# 'CFuncType.compatible_signature_with' doesn't compare constness, so we're doing it here.
# TODO: Maybe it should.
elif
(
type
.
is_const_method
and
not
alt_entry
.
type
.
is_const_method
or
not
type
.
is_const_method
and
alt_entry
.
type
.
is_const_method
):
print
(
type
.
is_const_method
)
print
(
alt_entry
.
type
.
is_const_method
)
error
(
pos
,
"Cypclass overriding method with conflicting constness"
)
if
alt_entry
.
pos
is
not
None
:
error
(
alt_entry
.
pos
,
"Overriden 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