@@ -454,13 +454,13 @@ private bool TryImportModule(string modName, bool forceAbsolute, out ModuleRefer
454454 return false ;
455455 }
456456
457- internal List < AnalysisValue > LookupBaseMethods ( string name , IEnumerable < IAnalysisSet > bases , Node node , AnalysisUnit unit ) {
457+ internal List < AnalysisValue > LookupBaseMethods ( string name , IEnumerable < IAnalysisSet > mro , Node node , AnalysisUnit unit ) {
458458 var result = new List < AnalysisValue > ( ) ;
459- foreach ( var b in bases ) {
460- foreach ( var curType in b ) {
461- var klass = curType as BuiltinClassInfo ;
462- if ( klass != null ) {
463- var value = klass . GetMember ( node , unit , name ) ;
459+ foreach ( var @class in mro . Skip ( 1 ) ) {
460+ foreach ( var curType in @class ) {
461+ bool isClass = curType is ClassInfo || curType is BuiltinClassInfo ;
462+ if ( isClass ) {
463+ var value = curType . GetMember ( node , unit , name ) ;
464464 if ( value != null ) {
465465 result . AddRange ( value ) ;
466466 }
@@ -470,7 +470,6 @@ internal List<AnalysisValue> LookupBaseMethods(string name, IEnumerable<IAnalysi
470470 return result ;
471471 }
472472
473-
474473 public override bool Walk ( FunctionDefinition node ) {
475474 InterpreterScope funcScope ;
476475 if ( _unit . InterpreterScope . TryGetNodeScope ( node , out funcScope ) ) {
@@ -572,9 +571,28 @@ public override bool Walk(ImportStatement node) {
572571
573572 public override bool Walk ( ReturnStatement node ) {
574573 var fnScope = CurrentFunction ;
575- if ( node . Expression != null && fnScope != null ) {
576- var lookupRes = _eval . Evaluate ( node . Expression ) ;
577- fnScope . AddReturnTypes ( node , _unit , lookupRes ) ;
574+ if ( fnScope == null || node . Expression == null ) {
575+ return true ;
576+ }
577+
578+ var lookupRes = _eval . Evaluate ( node . Expression ) ;
579+ fnScope . AddReturnTypes ( node , _unit , lookupRes ) ;
580+
581+ var function = fnScope . Function ;
582+ var analysisUnit = ( FunctionAnalysisUnit ) function . AnalysisUnit ;
583+
584+ if ( Scope . OuterScope is ClassScope curClass ) {
585+ var bases = LookupBaseMethods (
586+ analysisUnit . Ast . Name ,
587+ curClass . Class . Mro ,
588+ analysisUnit . Ast ,
589+ analysisUnit
590+ ) ;
591+
592+ foreach ( FunctionInfo baseFunction in bases . OfType < FunctionInfo > ( ) ) {
593+ var baseAnalysisUnit = ( FunctionAnalysisUnit ) baseFunction . AnalysisUnit ;
594+ baseAnalysisUnit . ReturnValue . AddTypes ( _unit , lookupRes ) ;
595+ }
578596 }
579597 return true ;
580598 }
0 commit comments