Commit af1300f7 authored by Stefan Behnel's avatar Stefan Behnel

Keep AnnotationNode instead of the bare annotation expression in...

Keep AnnotationNode instead of the bare annotation expression in "entry.annotation" to get access to the string representation.
parent cf89182f
......@@ -1998,7 +1998,7 @@ class NameNode(AtomicExprNode):
if atype.is_fused and env.fused_to_specific:
atype = atype.specialize(env.fused_to_specific)
self.entry = env.declare_var(name, atype, self.pos, is_cdef=not as_target)
self.entry.annotation = annotation.expr
self.entry.annotation = annotation
def analyse_as_module(self, env):
# Try to interpret this as a reference to a cimported module.
......
......@@ -2264,7 +2264,7 @@ class FuncDefNode(StatNode, BlockNode):
error(arg.pos, "Argument type '%s' is incomplete" % arg.type)
entry = env.declare_arg(arg.name, arg.type, arg.pos)
if arg.annotation:
entry.annotation = arg.annotation.expr
entry.annotation = arg.annotation
return entry
def generate_arg_type_test(self, arg, code):
......
......@@ -192,7 +192,7 @@ class IterationTransform(Visitor.EnvTransform):
def _optimise_for_loop(self, node, iterable, reversed=False):
annotation_type = None
if (iterable.is_name or iterable.is_attribute) and iterable.entry and iterable.entry.annotation:
annotation = iterable.entry.annotation
annotation = iterable.entry.annotation.expr
if annotation.is_subscript:
annotation = annotation.base # container base type
# FIXME: generalise annotation evaluation => maybe provide a "qualified name" also for imported names?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment