@@ -391,14 +391,26 @@ def p_ref_type(p):
391
391
'''ref_type : IDENTIFIER'''
392
392
ref_type = thrift_stack [- 1 ]
393
393
394
- for index , name in enumerate (p [1 ].split ('.' )):
395
- ref_type = getattr (ref_type , name , None )
396
- if ref_type is None :
397
- if index != len (p [1 ].split ('.' )) - 1 :
398
- raise ThriftParserError ('No type found: %r, at line %d' %
399
- (p [1 ], p .lineno (1 )))
400
- p [0 ] = incomplete_type .set_info ((p [1 ], p .lineno (1 )))
401
- return
394
+ for attr in dir (ref_type ):
395
+ if attr in {'__doc__' , '__loader__' , '__name__' , '__package__' ,
396
+ '__spec__' , '__thrift_file__' , '__thrift_meta__' }:
397
+ continue
398
+ if p [1 ].startswith (attr + '.' ):
399
+ name = p [1 ][len (attr )+ 1 :]
400
+ included_ref_type = getattr (ref_type , attr )
401
+ resolved_ref_type = getattr (included_ref_type , name , None )
402
+ if resolved_ref_type is not None :
403
+ ref_type = resolved_ref_type
404
+ break
405
+ else :
406
+ for index , name in enumerate (p [1 ].split ('.' )):
407
+ ref_type = getattr (ref_type , name , None )
408
+ if ref_type is None :
409
+ if index != len (p [1 ].split ('.' )) - 1 :
410
+ raise ThriftParserError ('No type found: %r, at line %d' %
411
+ (p [1 ], p .lineno (1 )))
412
+ p [0 ] = incomplete_type .set_info ((p [1 ], p .lineno (1 )))
413
+ return
402
414
403
415
if hasattr (ref_type , '_ttype' ):
404
416
p [0 ] = getattr (ref_type , '_ttype' ), ref_type
0 commit comments