@@ -278,7 +278,7 @@ private TypeMention getTypeAnnotation(AstNode n) {
278278 )
279279 or
280280 exists ( Function f |
281- result = f . getRetType ( ) . getTypeRepr ( ) and
281+ result = getReturnTypeMention ( f ) and
282282 n = f .getFunctionBody ( )
283283 )
284284}
@@ -436,8 +436,7 @@ module CertainTypeInference {
436436 result = inferTupleRootType ( n ) and
437437 path .isEmpty ( )
438438 or
439- result = inferAsyncBlockExprRootType ( n ) and
440- path .isEmpty ( )
439+ result = inferBlockExprType ( n , path )
441440 or
442441 result = inferArrayExprType ( n ) and
443442 path .isEmpty ( )
@@ -1854,7 +1853,7 @@ private module MethodCallMatchingInput implements MatchingWithEnvironmentInputSi
18541853 }
18551854
18561855 private Type resolveRetType ( TypePath path ) {
1857- result = this . getRetType ( ) . getTypeRepr ( ) . ( TypeMention ) .resolveTypeAt ( path )
1856+ result = getReturnTypeMention ( this ) .resolveTypeAt ( path )
18581857 }
18591858
18601859 pragma [ nomagic]
@@ -2799,10 +2798,21 @@ private AssociatedTypeTypeParameter getFutureOutputTypeParameter() {
27992798}
28002799
28012800pragma [ nomagic]
2802- private TraitType inferAsyncBlockExprRootType ( AsyncBlockExpr abe ) {
2801+ private Type inferBlockExprType ( BlockExpr be , TypePath path ) {
28032802 // `typeEquality` handles the non-root case
2804- exists ( abe ) and
2805- result = getFutureTraitType ( )
2803+ if be instanceof AsyncBlockExpr
2804+ then (
2805+ path .isEmpty ( ) and
2806+ result = getFutureTraitType ( )
2807+ or
2808+ not be .getStmtList ( ) .hasTailExpr ( ) and
2809+ path = TypePath:: singleton ( getFutureOutputTypeParameter ( ) ) and
2810+ result instanceof UnitType
2811+ ) else (
2812+ not be .getStmtList ( ) .hasTailExpr ( ) and
2813+ path .isEmpty ( ) and
2814+ result instanceof UnitType
2815+ )
28062816}
28072817
28082818final private class AwaitTarget extends Expr {
0 commit comments