-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Remove remaining prototype comments #19392
Conversation
469c98f
to
f11dd17
Compare
CC: @VSadov @AlekseyTs @cston |
ref lazyVariableSlotAllocator, | ||
lambdaDebugInfoBuilder, | ||
closureDebugInfoBuilder, | ||
out stateMachineTypeOpt); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cston are you talking about this method?
http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Lowering/LocalRewriter/LocalRewriter.cs,64
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
LGTM |
Ping: @AlekseyTs, @VSadov |
} | ||
}"; | ||
var sourceCompilation = CreateStandardCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); | ||
sourceCompilation.VerifyEmitDiagnostics( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Done with review pass. #Closed |
39de672
to
a38527d
Compare
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@AlekseyTs I've added obsolete tests, and reworked invocations to |
It looks like the parameter is no longer used. Consider removing. This is about 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
} | ||
|
||
static class Program { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Done with review pass. #Closed |
Which parameter? EDIT: oh, DiagnosticBag? |
There was a problem hiding this 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
No description provided.