Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove remaining prototype comments #19392

Merged
merged 7 commits into from
May 11, 2017

Conversation

TyOverby
Copy link
Contributor

No description provided.

@TyOverby
Copy link
Contributor Author

CC: @VSadov @AlekseyTs @cston

ref lazyVariableSlotAllocator,
lambdaDebugInfoBuilder,
closureDebugInfoBuilder,
out stateMachineTypeOpt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we call LocalRewriter.Rewrite() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the same method that LowerBodyOrInitializer calls. It looks like LowerBodyOrInitializer handles extra cases (await, local functions, iterators) that are not needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that LowerBodyOrInitializer is the main entrypoint to lowering a method body, so even though all of its functionality isn't used.

Debug.Assert((object)stateMachineTypeOpt == null);
Debug.Assert(dynamicAnalysisSpans.IsEmpty);
Debug.Assert(lambdaDebugInfoBuilder.IsEmpty());
Debug.Assert(closureDebugInfoBuilder.IsEmpty());
Copy link
Member

@cston cston May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArrayBuilder instances and diagsForCurrentMethod are not freed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

BoundStatement body = synthesizedEntryPoint.CreateBody();

var dynamicAnalysisSpans = ImmutableArray<SourceSpan>.Empty;
var diagsForCurrentMethod = DiagnosticBag.GetInstance();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance of errors in lowering? If so, please test that case. Otherwise assert diagsForCurrentMethod is empty.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just pass diagnostics to LowerBodyOrInitializer instead, to ensure we don't drop diagnostics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

@@ -19,7 +19,6 @@ internal abstract class SynthesizedEntryPointSymbol : MethodSymbol
internal const string FactoryName = "<Factory>";

private readonly NamedTypeSymbol _containingType;
// PROTOTYPE(async-main): remove this and move it out into inheriting classes?
private TypeSymbol _returnType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move _returnType to the derived classes, and make ReturnType abstract?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was one of the solutions that I was thinking about. I just implemented it and like how it looks.

sourceCompilation.VerifyEmitDiagnostics(
// (30,12): warning CS0436: The type 'Task' in '' conflicts with the imported type 'Task' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using the type defined in ''.
// static Task Main() {
Diagnostic(ErrorCode.WRN_SameFullNameThisAggAgg, "Task").WithArguments("", "System.Threading.Tasks.Task", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Threading.Tasks.Task").WithLocation(30, 12),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this error prevent ReturnsAwaitableToVoidOrInt from treating the return type as the well-known type Task? In short, does the extension method test the expected code path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the compiler considers this Task to be the "real" task.

@cston
Copy link
Member

cston commented May 10, 2017

LGTM

@TyOverby
Copy link
Contributor Author

TyOverby commented May 10, 2017

Ping: @AlekseyTs, @VSadov

}
}";
var sourceCompilation = CreateStandardCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1));
sourceCompilation.VerifyEmitDiagnostics(
Copy link
Contributor

@AlekseyTs AlekseyTs May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceCompilation.VerifyEmitDiagnostics( [](start = 12, length = 40)

sourceCompilation.VerifyEmitDiagnostics( [](start = 12, length = 40)

Success cases should be executed and runtime behavior should be verified. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

System.Console.WriteLine(""Task<int>"");
return 0;
}").WithArguments("async main", "7.1").WithLocation(6, 5),
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "Task<int>").WithArguments("async main", "7.1").WithLocation(6, 18),
Copy link
Contributor

@AlekseyTs AlekseyTs May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "Task").WithArguments("async main", "7.1").WithLocation(6, 18), [](start = 16, length = 124)

It looks like all tests for this error use async method, we should have a test for anon-async scenario as well. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've doubled the number of tests testing ERR_FeatureNotAvailable and each new one doesn't use async.

@AlekseyTs
Copy link
Contributor

AlekseyTs commented May 10, 2017

Done with review pass. #Closed

@TyOverby TyOverby force-pushed the async-main-cleanup-2 branch from 39de672 to a38527d Compare May 10, 2017 22:26
var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7));
compilation.VerifyDiagnostics(
// (6,18): error CS8107: Feature 'async main' is not available in C# 7. Please use language version 7.1 or greater.
// async static Task Main(string[] args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No async in the actual test code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, the diagnostics (including comments) were copied from another test.

compilation.VerifyDiagnostics(
// (6,18): error CS8107: Feature 'async main' is not available in C# 7. Please use language version 7.1 or greater.
// async static Task<int> Main(string[] args)
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "Task<int>").WithArguments("async main", "7.1").WithLocation(6, 12),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No async in the test code. I think this test will fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is correct; it's complaining about Task being returned.

@VSadov
Copy link
Member

VSadov commented May 10, 2017

:shipit:

Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TyOverby
Copy link
Contributor Author

@AlekseyTs I've added obsolete tests, and reworked invocations to GetAwaitableExpressionInfo.

@AlekseyTs
Copy link
Contributor

AlekseyTs commented May 10, 2017

            var success = binder.GetAwaitableExpressionInfo(userMainInvocation, out _, out _, out _, out _getAwaiterGetResultCall, _userMainReturnTypeSyntax, diagnosticBag);

It looks like the parameter is no longer used. Consider removing. This is about diagnosticBag parameter of the containing method. #Closed


Refers to: src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs:365 in a54e0ce. [](commit_id = a54e0ce, deletion_comment = True)

// (31,20): warning CS0436: The type 'Task' in '' conflicts with the imported type 'Task' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using the type defined in ''.
// return new Task();
Diagnostic(ErrorCode.WRN_SameFullNameThisAggAgg, "Task").WithArguments("", "System.Threading.Tasks.Task", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Threading.Tasks.Task").WithLocation(31, 20));
CompileAndVerify(sourceCompilation);
Copy link
Contributor

@AlekseyTs AlekseyTs May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompileAndVerify(sourceCompilation); [](start = 12, length = 36)

It is hard to tell what the program is doing, especially that GetAwaiter returns null. Let's print something from GetAwaiter and GetResult and assert the output to verify that they are called. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
}

static class Program {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static class Program [](start = 0, length = 21)

Consider also testing scenario when the Program is obsolete and the Main is obsolete (two separate scenarios). I would expect the obsolete diagnostics to disappear for the first scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to do this tomorrow morning, but if more important things come up, I don't think that

[Obsolete]
public static async Task<T> Main(){}

is a 7.1 blocker.

Copy link
Contributor

@AlekseyTs AlekseyTs May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. #Closed

var verifier = sourceCompilation.VerifyEmitDiagnostics(
// (30,12): warning CS0436: The type 'Task' in '' conflicts with the imported type 'Task' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using the type defined in ''.
// static Task Main() {
Diagnostic(ErrorCode.WRN_SameFullNameThisAggAgg, "Task").WithArguments("", "System.Threading.Tasks.Task", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Threading.Tasks.Task"),
Copy link
Contributor

@AlekseyTs AlekseyTs May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) [](start = 230, length = 1)

Locations are dropped. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@AlekseyTs
Copy link
Contributor

AlekseyTs commented May 10, 2017

Done with review pass. #Closed

@TyOverby
Copy link
Contributor Author

TyOverby commented May 10, 2017

           var success = binder.GetAwaitableExpressionInfo(userMainInvocation, out _, out _, out _, out _getAwaiterGetResultCall, _userMainReturnTypeSyntax, diagnosticBag);

It looks like the parameter is no longer used. Consider removing.
Refers to: src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs:365 in a54e0ce. [](commit_id = a54e0ce, deletion_comment = True)

Which parameter?

EDIT: oh, DiagnosticBag?
EDIT: Done.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, additional tests with Obsolete can be added later

@TyOverby TyOverby merged commit b0249ee into dotnet:features/async-main May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants