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

Merge future-stabilization into master #12127

Merged
merged 84 commits into from Jun 23, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
1662e3b
Generalize the version update script, add support for LKG
tmat Jun 11, 2016
8abe2b9
Merge pull request #11935 from tmat/update_deps
tmat Jun 12, 2016
5116e42
Update prerelease nuget version for Dev15 Preview 3
shyamnamboodiripad Jun 13, 2016
ada58c6
Update to corefx RTM
cston Jun 12, 2016
bd23fe4
Merge pull request #11945 from cston/u3-rtm
cston Jun 13, 2016
71f5cf5
Update to corefx RTM
cston Jun 13, 2016
169f8e8
Merge pull request #11955 from cston/u3-rtm-2
cston Jun 13, 2016
4e63530
Update PreReleaseOnlyPackages
cston Jun 13, 2016
4911b8c
Merge pull request #11957 from cston/u3-rtm-3
cston Jun 13, 2016
b54df73
Prevent stack overflow when creating symbol ids.
CyrusNajmabadi Jun 13, 2016
214aa34
Merge pull request #11963 from CyrusNajmabadi/symbolIdOverflow
CyrusNajmabadi Jun 13, 2016
251191e
fix crash due to result existing both in compiler and ide side.
heejaechang Jun 13, 2016
8b2e60b
Revert changes to generate release versions
cston Jun 13, 2016
9bdaba0
Merge pull request #11954 from shyamnamboodiripad/future-stabilization
shyamnamboodiripad Jun 13, 2016
21aead4
Add option to disable converting metadata to project references
mattwar Jun 13, 2016
a7c04df
disable workspace document events on project disconnect
mattwar Jun 10, 2016
ab599a0
Merge pull request #11974 from cston/pre-release
cston Jun 14, 2016
24de6a5
Merge pull request #11985 from mattwar/Issue11912Stab
mattwar Jun 14, 2016
0648b01
Relax compiler server spinwait test (#11864)
agocke Jun 14, 2016
559ab3b
Merge pull request #11972 from heejaechang/fixcrash10
heejaechang Jun 14, 2016
035bc15
Merge pull request #11982 from mattwar/Issue11913Stab
mattwar Jun 14, 2016
55836e7
Change version to 1.3.1
cston Jun 14, 2016
225b0a1
Update bindingRedirects for 1.3.1
cston Jun 14, 2016
32b8b32
Revert changes to PreReleaseOnlyPackages
cston Jun 14, 2016
b4f28a3
Merge pull request #12003 from cston/version
cston Jun 14, 2016
38df45c
Merge pull request #12009 from cston/publish
cston Jun 14, 2016
8ad20ad
Merge remote-tracking branch 'upstream/stabilization' into merge-stab…
jinujoseph Jun 15, 2016
644ab8d
MicrosoftDiaSymReaderNativeVersion version changed to rc2
jinujoseph Jun 15, 2016
4441acf
Fixing the dependencies
jinujoseph Jun 15, 2016
31fadd6
Merge pull request #12030 from vslsnap/merge-stabilization-into-futur…
jinujoseph Jun 15, 2016
42fd266
Fix Interactive Window versioning (don't version separately)...
KevinH-MS Jun 16, 2016
0ec704a
Merge pull request #12048 from KevinH-MS/FixInteractiveVersion
KevinH-MS Jun 16, 2016
816218d
Merge pull request #12054 from dotnet/stabilization
jinujoseph Jun 16, 2016
15bc390
add csharp 7 language version flag (#11660)
TyOverby Jun 2, 2016
0eae3a4
Move language features to the langver switch
jaredpar Jun 17, 2016
df88a0d
Merge pull request #12080 from jaredpar/patch
jaredpar Jun 19, 2016
6205883
Fixed up the code references
jaredpar Jun 19, 2016
1d939f2
Provide C# options for controlling new Dev15 features.
CyrusNajmabadi Jun 2, 2016
dea8f4e
Don't load Dev15 binaries unless a dev15 completion option is set.
CyrusNajmabadi Jun 2, 2016
43ca856
Add VB support for these options as well.
CyrusNajmabadi Jun 2, 2016
c11295f
Break non-language-specific options into its own Class.
CyrusNajmabadi Jun 2, 2016
34136d6
PR feedback.
CyrusNajmabadi Jun 2, 2016
05f4acd
Remove file.
CyrusNajmabadi Jun 3, 2016
da07713
Actually listen to completion options.
CyrusNajmabadi Jun 3, 2016
c9eb85c
Formatting.
CyrusNajmabadi Jun 3, 2016
e1415dd
Fix all of the unit test diagnostic messages
jaredpar Jun 20, 2016
29c11cd
Properly implement type inference for C# member access expressions.
CyrusNajmabadi Jun 20, 2016
045003e
Add VB side.
CyrusNajmabadi Jun 20, 2016
1e4027f
Share comment.
CyrusNajmabadi Jun 20, 2016
91cad67
More VB side.
CyrusNajmabadi Jun 20, 2016
033e770
Merge pull request #12099 from Pilchie/CompletionOptions
Pilchie Jun 20, 2016
19fedfc
Make sure CompletionItems have DisplayTexts of differing lengths befo…
Jun 20, 2016
41a1d64
Fix inference in awaits.
CyrusNajmabadi Jun 20, 2016
058ffc1
Don't invoke SignFiles if there's no files to sign
jasonmalinowski Jun 21, 2016
138ac57
Only compute entry points when compiling everything.
gafter Jun 21, 2016
b35bac4
Merge branch 'master' into typeInferenceWork
CyrusNajmabadi Jun 21, 2016
f29a6cb
Add better inference for task and enumerable scenarios.
CyrusNajmabadi Jun 21, 2016
6bdb5a5
VB side of type inference.
CyrusNajmabadi Jun 21, 2016
e11beed
Fix test.
CyrusNajmabadi Jun 21, 2016
3491dd2
Only consider identifiers that bind to lambda parameters.
CyrusNajmabadi Jun 21, 2016
bc2369d
Merge pull request #12119 from jasonmalinowski/fix-signed-build-warnings
jasonmalinowski Jun 21, 2016
16fde31
Redirect more of MSBuild
jasonmalinowski Jun 21, 2016
52595d7
Merge pull request #12120 from gafter/master-12113
gafter Jun 21, 2016
a5b8071
Add test.
CyrusNajmabadi Jun 21, 2016
96568b8
Merge pull request #12110 from CyrusNajmabadi/typeInferenceWork
CyrusNajmabadi Jun 21, 2016
76b3818
Update CoreFX to RTM and CorecLR to the latest vNext
tmat Jun 17, 2016
2ba614e
Delete types and tests moved to System.Reflection.Metadata
tmat May 8, 2016
c6a1c2c
Fix up namespaces
tmat May 8, 2016
ea2bca8
Merge pull request #12103 from jaredpar/move
jaredpar Jun 21, 2016
f8296d1
Use linked files for shared sources
jaredpar Jun 21, 2016
ef1f1a4
Adjust to API changes.
tmat May 14, 2016
eca2b74
Update update_dependencies.csx
tmat Jun 21, 2016
e8c3712
Linked more files
jaredpar Jun 21, 2016
4c34104
SRM version correction
tmat Jun 21, 2016
7abdbb5
Improve lambda type inference for erroneous method groups
gafter Jun 13, 2016
1d7a91e
Don't deploy VSIX during perf correctness run
jaredpar Jun 21, 2016
3e27633
Merge pull request #12133 from jasonmalinowski/fix-signed-build-warnings
jasonmalinowski Jun 21, 2016
9f74043
Merge branch 'master-errlambda05'
gafter Jun 22, 2016
eed3167
Merge pull request #12073 from tmat/CoreRTM
tmat Jun 22, 2016
aa1fb65
Merge pull request #12144 from jaredpar/dupe
jaredpar Jun 22, 2016
99b92a7
Merge pull request #12149 from jaredpar/sanity
jaredpar Jun 22, 2016
5d42f86
Merge pull request #12115 from rchande/fixPrefixCheck
Jun 22, 2016
6b525d0
Merge remote-tracking branch 'upstream/future-stabilization' into mer…
jinujoseph Jun 22, 2016
4107f24
Getting rid of RequiredFeatureLegacy
jinujoseph Jun 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
VB side of type inference.
  • Loading branch information
CyrusNajmabadi committed Jun 21, 2016
commit 6bdb5a53a5de4eac37ef4f68e07af36d4246df65
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax
End Function
End Class

Public Partial Class SingleLineLambdaExpressionSyntax
Partial Public Class SingleLineLambdaExpressionSyntax
''' <summary>
''' Single line subs only have a single statement. However, when binding it is convenient to have a statement list. For example,
''' dim statements are not valid in a single line lambda. However, it is nice to be able to provide semantic info about the local.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,6 @@ static void Foo(System.ConsoleModifiers arg)
}

[Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)]
[WorkItem(6765, "https://github.com/dotnet/roslyn/issues/6765")]
public async Task TestWhereCall()
{
var text =
Expand All @@ -1837,7 +1836,6 @@ void Foo()
}

[Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)]
[WorkItem(6765, "https://github.com/dotnet/roslyn/issues/6765")]
public async Task TestWhereCall2()
{
var text =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ Module M
Dim x As Boolean = Await [|F|].ContinueWith(Function(a) True).ContinueWith(Function(a) False)
End Sub
End Module"
Await TestAsync(text, "System.Object", testPosition:=False)
Await TestAsync(text, "Global.System.Threading.Tasks.Task(Of System.Object)", testPosition:=False)
End Function

<Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)>
Expand Down Expand Up @@ -736,5 +736,31 @@ End Module"
End Class"
Await TestAsync(text, "System.Object", testNode:=False, testPosition:=True)
End Function

<Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)>
Public Async Function TestWhereCall() As Task
Dim text =
"imports System.Collections.Generic
class C
sub Foo()
[|ints|].Where(function(i) i > 10)
end sub
end class"
Await TestAsync(text, "Global.System.Collections.Generic.IEnumerable(Of System.Int32)", testPosition:=False)
End Function

<Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)>
Public Async Function TestWhereCall2() As Task
Dim text =
"imports System.Collections.Generic
class C
sub Foo()
[|ints|].Where(function(i)
return i > 10
end function)
end sub
end class"
Await TestAsync(text, "Global.System.Collections.Generic.IEnumerable(Of System.Int32)", testPosition:=False)
End Function
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -1457,72 +1457,78 @@ private IEnumerable<ITypeSymbol> InferTypeInMemberAccessExpression(
Debug.Assert(expressionOpt != null);
if (expressionOpt == memberAccessExpression.Expression)
{
// If we're on the left side of a dot, it's possible in a few cases
// to figure out what type we should be. Specifically, if we have
//
// await foo.ConfigureAwait()
//
// then we can figure out what 'foo' should be based on teh await
// context.
var name = memberAccessExpression.Name.Identifier.Value;
if (name.Equals(nameof(Task<int>.ConfigureAwait)) &&
memberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression) &&
memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression))
{
return InferTypes((ExpressionSyntax)memberAccessExpression.Parent);
}
else if (name.Equals(nameof(Task<int>.ContinueWith)))
return InferTypeForExpressionOfMemberAccessExpression(memberAccessExpression);
}

// We're right after the dot in "Foo.Bar". The type for "Bar" should be
// whatever type we'd infer for "Foo.Bar" itself.
return InferTypes(memberAccessExpression);
}
}

private IEnumerable<ITypeSymbol> InferTypeForExpressionOfMemberAccessExpression(
MemberAccessExpressionSyntax memberAccessExpression)
{
// If we're on the left side of a dot, it's possible in a few cases
// to figure out what type we should be. Specifically, if we have
//
// await foo.ConfigureAwait()
//
// then we can figure out what 'foo' should be based on teh await
// context.
var name = memberAccessExpression.Name.Identifier.Value;
if (name.Equals(nameof(Task<int>.ConfigureAwait)) &&
memberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression) &&
memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression))
{
return InferTypes((ExpressionSyntax)memberAccessExpression.Parent);
}
else if (name.Equals(nameof(Task<int>.ContinueWith)))
{
// foo.ContinueWith(...)
// We want to infer Task<T>. For now, we'll just do Task<object>,
// in the future it would be nice to figure out the actual result
// type based on the argument to ContinueWith.
var taskOfT = this.Compilation.TaskOfTType();
if (taskOfT != null)
{
return SpecializedCollections.SingletonEnumerable(
taskOfT.Construct(this.Compilation.ObjectType));
}
}
else if (name.Equals(nameof(Enumerable.Select)) ||
name.Equals(nameof(Enumerable.Where)))
{
var ienumerableType = this.Compilation.IEnumerableOfTType();

// foo.Select
// We want to infer IEnumerable<T>. We can try to figure out what
// T if we get a delegate as the first argument to Select/Where.
if (ienumerableType != null && memberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression))
{
var invocation = (InvocationExpressionSyntax)memberAccessExpression.Parent;
if (invocation.ArgumentList.Arguments.Count > 0)
{
// foo.ContinueWith(...)
// We want to infer Task<T>. For now, we'll just do Task<object>,
// in the future it would be nice to figure out the actual result
// type based on the argument to ContinueWith.
var taskOfT = this.Compilation.TaskOfTType();
if (taskOfT != null)
var argumentExpression = invocation.ArgumentList.Arguments[0].Expression;
var argumentTypes = GetTypes(argumentExpression);
var delegateType = argumentTypes.FirstOrDefault().GetDelegateType(this.Compilation);
var typeArg = delegateType?.TypeArguments.Length > 0
? delegateType.TypeArguments[0]
: this.Compilation.ObjectType;

if (IsUnusableType(typeArg) && argumentExpression is LambdaExpressionSyntax)
{
return SpecializedCollections.SingletonEnumerable(
taskOfT.Construct(this.Compilation.ObjectType));
typeArg = InferTypeForFirstParameterOfLambda((LambdaExpressionSyntax)argumentExpression) ??
this.Compilation.ObjectType;
}
}
else if (name.Equals(nameof(Enumerable.Select)) ||
name.Equals(nameof(Enumerable.Where)))
{
var ienumerableType = this.Compilation.IEnumerableOfTType();

// foo.Select
// We want to infer IEnumerable<T>. We can try to figure out what
// T if we get a delegate as the first argument to Select/Where.
if (ienumerableType != null && memberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression))
{
var invocation = (InvocationExpressionSyntax)memberAccessExpression.Parent;
if (invocation.ArgumentList.Arguments.Count > 0)
{
var argumentExpression = invocation.ArgumentList.Arguments[0].Expression;
var argumentTypes = GetTypes(argumentExpression);
var delegateType = argumentTypes.FirstOrDefault().GetDelegateType(this.Compilation);
var typeArg = delegateType?.TypeArguments.Length > 0
? delegateType.TypeArguments[0]
: this.Compilation.ObjectType;

if (IsUnusableType(typeArg) && argumentExpression is LambdaExpressionSyntax)
{
typeArg = InferTypeForFirstParameterOfLambda((LambdaExpressionSyntax)argumentExpression) ??
this.Compilation.ObjectType;
}

return SpecializedCollections.SingletonEnumerable(
ienumerableType.Construct(typeArg));
}
}
return SpecializedCollections.SingletonEnumerable(
ienumerableType.Construct(typeArg));
}

return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
}

// We're right after the dot in "Foo.Bar". The type for "Bar" should be
// whatever type we'd infer for "Foo.Bar" itself.
return InferTypes(memberAccessExpression);
}

return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
}

private ITypeSymbol InferTypeForFirstParameterOfLambda(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,17 +828,107 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' then we can figure out what 'foo' should be based on teh await
' context.
If expressionOpt Is memberAccessExpression.Expression Then
If memberAccessExpression.Name.Identifier.Value.Equals(NameOf(Task(Of Integer).ConfigureAwait)) AndAlso
memberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression) AndAlso
memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression) Then
Return InferTypes(DirectCast(memberAccessExpression.Parent, ExpressionSyntax))
Return InferTypeForExpressionOfMemberAccessExpression(memberAccessExpression)
End If

Return InferTypes(memberAccessExpression)
End If
End Function

Private Function InferTypeForExpressionOfMemberAccessExpression(memberAccessExpression As MemberAccessExpressionSyntax) As IEnumerable(Of ITypeSymbol)
Dim name = memberAccessExpression.Name.Identifier.Value

If name.Equals(NameOf(Task(Of Integer).ConfigureAwait)) AndAlso
memberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression) AndAlso
memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression) Then
Return InferTypes(DirectCast(memberAccessExpression.Parent, ExpressionSyntax))
ElseIf name.Equals(NameOf(Task(Of Integer).ContinueWith)) Then
' foo.ContinueWith(...)
' We want to infer Task<T>. For now, we'll just do Task<object>,
' in the future it would be nice to figure out the actual result
' type based on the argument to ContinueWith.
Dim taskOfT = Me.Compilation.TaskOfTType()
If taskOfT IsNot Nothing Then
Return SpecializedCollections.SingletonEnumerable(
taskOfT.Construct(Me.Compilation.ObjectType))
End If
ElseIf name.Equals(NameOf(Enumerable.Select)) OrElse
name.Equals(NameOf(Enumerable.Where)) Then

Dim ienumerableType = Me.Compilation.IEnumerableOfTType()

' foo.Select
' We want to infer IEnumerable<T>. We can try to figure out what
' T if we get a delegate as the first argument to Select/Where.
If ienumerableType IsNot Nothing AndAlso memberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression) Then
Dim invocation = DirectCast(memberAccessExpression.Parent, InvocationExpressionSyntax)
If invocation.ArgumentList.Arguments.Count > 0 AndAlso
TypeOf invocation.ArgumentList.Arguments(0) Is SimpleArgumentSyntax Then
Dim argumentExpression = DirectCast(invocation.ArgumentList.Arguments(0), SimpleArgumentSyntax).Expression
Dim argumentTypes = GetTypes(argumentExpression)
Dim delegateType = argumentTypes.FirstOrDefault().GetDelegateType(Me.Compilation)
Dim typeArg = If(delegateType?.TypeArguments.Length > 0,
delegateType.TypeArguments(0),
Me.Compilation.ObjectType)

If delegateType Is Nothing OrElse IsUnusableType(typeArg) Then
If TypeOf argumentExpression Is LambdaExpressionSyntax Then
typeArg = If(InferTypeForFirstParameterOfLambda(DirectCast(argumentExpression, LambdaExpressionSyntax)),
Me.Compilation.ObjectType)
End If
End If

Return SpecializedCollections.SingletonEnumerable(
ienumerableType.Construct(typeArg))
End If
End If
End If

Return SpecializedCollections.EmptyEnumerable(Of ITypeSymbol)()
Return SpecializedCollections.EmptyEnumerable(Of ITypeSymbol)()
End Function

Private Function InferTypeForFirstParameterOfLambda(
lambda As LambdaExpressionSyntax) As ITypeSymbol
If lambda.SubOrFunctionHeader.ParameterList.Parameters.Count > 0 Then
Dim parameter = lambda.SubOrFunctionHeader.ParameterList.Parameters(0)
Dim parameterName = parameter.Identifier.Identifier.ValueText

If TypeOf lambda Is SingleLineLambdaExpressionSyntax Then
Dim singleLine = DirectCast(lambda, SingleLineLambdaExpressionSyntax)
Return InferTypeForFirstParameterOfLambda(parameterName, singleLine.Body)
ElseIf TypeOf lambda Is MultiLineLambdaExpressionSyntax Then
Dim multiLine = DirectCast(lambda, MultiLineLambdaExpressionSyntax)
For Each statement In multiLine.Statements
Dim type = InferTypeForFirstParameterOfLambda(parameterName, statement)
If type IsNot Nothing Then
Return type
End If
Next
End If
End If

Return InferTypes(memberAccessExpression)
Return Nothing
End Function

Private Function InferTypeForFirstParameterOfLambda(
parameterName As String, node As SyntaxNode) As ITypeSymbol
If node.IsKind(SyntaxKind.IdentifierName) Then
Dim identifier = DirectCast(node, IdentifierNameSyntax)
If CaseInsensitiveComparison.Equals(parameterName, identifier.Identifier.ValueText) Then
Return InferTypes(identifier).FirstOrDefault()
End If
Else
For Each child In node.ChildNodesAndTokens()
If child.IsNode Then
Dim type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode)
If type IsNot Nothing Then
Return type
End If
End If
Next
End If

Return Nothing
End Function

Private Function InferTypeInNamedFieldInitializer(initializer As NamedFieldInitializerSyntax, Optional previousToken As SyntaxToken = Nothing) As IEnumerable(Of ITypeSymbol)
Expand Down