Skip to content

Commit

Permalink
Inlined binder.GetSpecialType to remove binder parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Nov 13, 2018
1 parent 410272e commit 3965ca0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,22 @@ internal override TypeSymbol GetIteratorElementType(YieldStatementSyntax node, D

private TypeSymbol GetIteratorElementTypeFromReturnType(RefKind refKind, TypeSymbol returnType, CSharpSyntaxNode errorLocationNode, DiagnosticBag diagnostics)
{
return GetIteratorElementTypeFromReturnType(Compilation, binder: this, refKind, returnType, errorLocationNode, diagnostics).TypeSymbol;
return GetIteratorElementTypeFromReturnType(Compilation, refKind, returnType, errorLocationNode, diagnostics).TypeSymbol;
}

internal static TypeSymbolWithAnnotations GetIteratorElementTypeFromReturnType(CSharpCompilation compilation, Binder binder, RefKind refKind, TypeSymbol returnType, CSharpSyntaxNode errorLocationNode, DiagnosticBag diagnostics)
internal static TypeSymbolWithAnnotations GetIteratorElementTypeFromReturnType(CSharpCompilation compilation, RefKind refKind, TypeSymbol returnType, CSharpSyntaxNode errorLocationNode, DiagnosticBag diagnostics)
{
if (refKind == RefKind.None && returnType.Kind == SymbolKind.NamedType)
{
switch (returnType.OriginalDefinition.SpecialType)
{
case SpecialType.System_Collections_IEnumerable:
case SpecialType.System_Collections_IEnumerator:
var objectType = diagnostics is null ? compilation.GetSpecialType(SpecialType.System_Object) : binder.GetSpecialType(SpecialType.System_Object, diagnostics, errorLocationNode);
var objectType = compilation.GetSpecialType(SpecialType.System_Object);
if (diagnostics != null)
{
ReportUseSiteDiagnostics(objectType, diagnostics, errorLocationNode);
}
return TypeSymbolWithAnnotations.Create(objectType);

case SpecialType.System_Collections_Generic_IEnumerable_T:
Expand Down
3 changes: 1 addition & 2 deletions src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4600,8 +4600,7 @@ public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement no
return null;
}
var method = (MethodSymbol)_member;
Debug.Assert(method.IsIterator);
TypeSymbolWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(compilation, binder: null, RefKind.None, method.ReturnType.TypeSymbol, errorLocationNode: null, diagnostics: null);
TypeSymbolWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(compilation, RefKind.None, method.ReturnType.TypeSymbol, errorLocationNode: null, diagnostics: null);
VisitOptionalImplicitConversion(expr, elementType, useLegacyWarnings: false, AssignmentKind.Return);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class C
}

private CSharpCompilation CreateCompilationWithAsyncIterator(string source, CSharpCompilationOptions options = null)
=> CreateCompilationWithAsyncIterator(source, options: options);
=> CreateCompilationWithTasksExtensions(new[] { source, AsyncStreamsTypes }, options: options);

[Fact]
[WorkItem(30566, "https://github.com/dotnet/roslyn/issues/30566")]
Expand Down

0 comments on commit 3965ca0

Please sign in to comment.