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
Kirill Smelkov
cython
Commits
6dd263aa
Commit
6dd263aa
authored
Nov 15, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't infer unbond function types for bound methods.
This fixes #551.
parent
5796b9b0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-0
tests/run/type_inference.pyx
tests/run/type_inference.pyx
+23
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
6dd263aa
...
@@ -6309,6 +6309,10 @@ class AttributeNode(ExprNode):
...
@@ -6309,6 +6309,10 @@ class AttributeNode(ExprNode):
# builtin types cannot be inferred as C functions as
# builtin types cannot be inferred as C functions as
# that would prevent their use as bound methods
# that would prevent their use as bound methods
return
py_object_type
return
py_object_type
elif
self
.
entry
and
self
.
entry
.
is_cmethod
:
# special case: bound methods should not be inferred
# as their unbound method types
return
py_object_type
return
self
.
type
return
self
.
type
def
analyse_target_declaration
(
self
,
env
):
def
analyse_target_declaration
(
self
,
env
):
...
...
tests/run/type_inference.pyx
View file @
6dd263aa
...
@@ -722,3 +722,26 @@ cdef class InferInProperties:
...
@@ -722,3 +722,26 @@ cdef class InferInProperties:
d
=
enum_y
d
=
enum_y
c
=
d
c
=
d
return
typeof
(
a
),
typeof
(
b
),
typeof
(
c
),
typeof
(
d
)
return
typeof
(
a
),
typeof
(
b
),
typeof
(
c
),
typeof
(
d
)
cdef
class
WithMethods
:
cdef
int
offset
def
__init__
(
self
,
offset
):
self
.
offset
=
offset
cpdef
int
one_arg
(
self
,
int
x
):
return
x
+
self
.
offset
cpdef
int
default_arg
(
self
,
int
x
,
int
y
=
0
):
return
x
+
y
+
self
.
offset
def
test_bound_methods
():
"""
>>> test_bound_methods()
"""
o
=
WithMethods
(
10
)
assert
typeof
(
o
)
==
'WithMethods'
,
typeof
(
o
)
one_arg
=
o
.
one_arg
assert
one_arg
(
2
)
==
12
,
one_arg
(
2
)
default_arg
=
o
.
default_arg
assert
default_arg
(
2
)
==
12
,
default_arg
(
2
)
assert
default_arg
(
2
,
3
)
==
15
,
default_arg
(
2
,
2
)
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