Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Symbols/Source/LambdaSymbol.cs (C#)

Code before:
            get { return this.ReturnTypeWithAnnotations.HasType && this.ReturnType.IsVoidType(); }
        }

        public override RefKind RefKind
        {
            get { return _refKind; }
        }

        public override ImmutableArray<CustomModifier> RefCustomModifiers
        {
            get { return _refCustomModifiers; }
        }

        public override TypeWithAnnotations ReturnTypeWithAnnotations
        {
            get { return _returnType; }
        }

        // In error recovery and type inference scenarios we do not know the return type
        // until after the body is bound, but the symbol is created before the body
        // is bound.  Fill in the return type post hoc in these scenarios; the
        // IDE might inspect the symbol and want to know the return type.
        internal void SetInferredReturnType(RefKind refKind, TypeWithAnnotations inferredReturnType)
        {
            Debug.Assert(inferredReturnType.HasType);
            Debug.Assert(_returnType.Type.IsErrorType());
            Debug.Assert(refKind != RefKind.RefReadOnly);

            var runtimeAsyncEnabledDuringInference = IsAsync && _binder.Compilation.IsRuntimeAsyncEnabledIn(this);
            _refKind = refKind;
            _refCustomModifiers = [];
            _returnType = inferredReturnType;
            _runtimeAsyncEnabledChangedDuringInference = IsAsync && runtimeAsyncEnabledDuringInference != _binder.Compilation.IsRuntimeAsyncEnabledIn(this);
        }

        /// <summary>
        /// True if <see cref="SetInferredReturnType(RefKind, TypeWithAnnotations)"/> changed whether <see cref="CSharpCompilation.IsRuntimeAsyncEnabledIn(Symbol?)"/> returns true for this method.
        /// In such cases, the lambda body needs to be re-bound to ensure correct handling of await expressions.
        /// </summary>
        public bool RuntimeAsyncEnabledChangedDuringInference => _runtimeAsyncEnabledChangedDuringInference;

        internal override bool IsExplicitInterfaceImplementation
        {
            get { return false; }
        }

        public override ImmutableArray<MethodSymbol> ExplicitInterfaceImplementations
        {
            get { return ImmutableArray<MethodSymbol>.Empty; }
        }


Review comment (bug):
>Debug.Assert(_returnType.Type.IsErrorType()); [](http://example.com/codeflow?start=12&length=45)

Let's strengthen this assert to expect ```LambdaSymbol.ReturnTypeIsBeingInferred``` #Closed

Code after:
            get { return this.ReturnTypeWithAnnotations.HasType && this.ReturnType.IsVoidType(); }
        }

        public override RefKind RefKind
        {
            get { return _refKind; }
        }

        public override ImmutableArray<CustomModifier> RefCustomModifiers
        {
            get { return _refCustomModifiers; }
        }

        public override TypeWithAnnotations ReturnTypeWithAnnotations
        {
            get { return _returnType; }
        }

        // In error recovery and type inference scenarios we do not know the return type
        // until after the body is bound, but the symbol is created before the body
        // is bound.  Fill in the return type post hoc in these scenarios; the
        // IDE might inspect the symbol and want to know the return type.
        internal void SetInferredReturnType(RefKind refKind, TypeWithAnnotations inferredReturnType)
        {
            Debug.Assert(inferredReturnType.HasType);
            Debug.Assert((object)_returnType.Type == ReturnTypeIsBeingInferred);
            Debug.Assert(refKind != RefKind.RefReadOnly);

            var runtimeAsyncEnabledDuringInference = IsAsync && _binder.Compilation.IsRuntimeAsyncEnabledIn(this);
            _refKind = refKind;
            _refCustomModifiers = [];
            _returnType = inferredReturnType;
            _runtimeAsyncEnabledChangedDuringInference = IsAsync && runtimeAsyncEnabledDuringInference != _binder.Compilation.IsRuntimeAsyncEnabledIn(this);
        }

        /// <summary>
        /// True if <see cref="SetInferredReturnType(RefKind, TypeWithAnnotations)"/> changed whether <see cref="CSharpCompilation.IsRuntimeAsyncEnabledIn(Symbol?)"/> returns true for this method.
        /// In such cases, the lambda body needs to be re-bound to ensure correct handling of await expressions.
        /// </summary>
        public bool RuntimeAsyncEnabledChangedDuringInference => _runtimeAsyncEnabledChangedDuringInference;

        internal override bool IsExplicitInterfaceImplementation
        {
            get { return false; }
        }

        public override ImmutableArray<MethodSymbol> ExplicitInterfaceImplementations
        {
            get { return ImmutableArray<MethodSymbol>.Empty; }
        }