diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs index 4d80368d2989f..7213be0d26a4f 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs @@ -19,7 +19,6 @@ internal abstract class SynthesizedEntryPointSymbol : MethodSymbol internal const string FactoryName = ""; private readonly NamedTypeSymbol _containingType; - private TypeSymbol _returnType; internal static SynthesizedEntryPointSymbol Create(SynthesizedInteractiveInitializerMethod initializerMethod, DiagnosticBag diagnostics) { @@ -56,12 +55,11 @@ internal static SynthesizedEntryPointSymbol Create(SynthesizedInteractiveInitial } } - private SynthesizedEntryPointSymbol(NamedTypeSymbol containingType, TypeSymbol returnType = null) + private SynthesizedEntryPointSymbol(NamedTypeSymbol containingType) { Debug.Assert((object)containingType != null); _containingType = containingType; - _returnType = returnType; } internal override bool GenerateDebugInfo @@ -129,11 +127,6 @@ internal override RefKind RefKind get { return RefKind.None; } } - public override TypeSymbol ReturnType - { - get { return _returnType; } - } - public override ImmutableArray ReturnTypeCustomModifiers { get { return ImmutableArray.Empty; } @@ -161,7 +154,7 @@ public override int Arity public override bool ReturnsVoid { - get { return _returnType.SpecialType == SpecialType.System_Void; } + get { return ReturnType.SpecialType == SpecialType.System_Void; } } public override MethodKind MethodKind @@ -371,8 +364,6 @@ internal AsyncForwardEntryPoint(CSharpCompilation compilation, DiagnosticBag dia var success = binder.GetAwaitableExpressionInfo(userMainInvocation, out _, out _, out _, out _getAwaiterGetResultCall, _userMainReturnTypeSyntax, diagnosticBag); - _returnType = _getAwaiterGetResultCall.Type; - Debug.Assert( ReturnType.SpecialType == SpecialType.System_Void || ReturnType.SpecialType == SpecialType.System_Int32); @@ -382,6 +373,8 @@ internal AsyncForwardEntryPoint(CSharpCompilation compilation, DiagnosticBag dia public override ImmutableArray Parameters => _parameters; + public override TypeSymbol ReturnType => _getAwaiterGetResultCall.Type; + internal override BoundBlock CreateBody() { var syntax = _userMainReturnTypeSyntax; @@ -430,21 +423,25 @@ private sealed class ScriptEntryPoint : SynthesizedEntryPointSymbol { private readonly MethodSymbol _getAwaiterMethod; private readonly MethodSymbol _getResultMethod; + private readonly TypeSymbol _returnType; internal ScriptEntryPoint(NamedTypeSymbol containingType, TypeSymbol returnType, MethodSymbol getAwaiterMethod, MethodSymbol getResultMethod) : - base(containingType, returnType) + base(containingType) { Debug.Assert(containingType.IsScriptClass); Debug.Assert(returnType.SpecialType == SpecialType.System_Void); _getAwaiterMethod = getAwaiterMethod; _getResultMethod = getResultMethod; + _returnType = returnType; } public override string Name => MainName; public override ImmutableArray Parameters => ImmutableArray.Empty; + public override TypeSymbol ReturnType => _returnType; + // private static void
() // { // var script = new Script(); @@ -514,13 +511,15 @@ internal override BoundBlock CreateBody() private sealed class SubmissionEntryPoint : SynthesizedEntryPointSymbol { private readonly ImmutableArray _parameters; + private readonly TypeSymbol _returnType; internal SubmissionEntryPoint(NamedTypeSymbol containingType, TypeSymbol returnType, TypeSymbol submissionArrayType) : - base(containingType, returnType) + base(containingType) { Debug.Assert(containingType.IsSubmissionClass); Debug.Assert(returnType.SpecialType != SpecialType.System_Void); _parameters = ImmutableArray.Create(SynthesizedParameterSymbol.Create(this, submissionArrayType, 0, RefKind.None, "submissionArray")); + _returnType = returnType; } public override string Name @@ -533,6 +532,8 @@ public override ImmutableArray Parameters get { return _parameters; } } + public override TypeSymbol ReturnType => _returnType; + // private static T (object[] submissionArray) // { // var submission = new Submission#N(submissionArray);