提交 a594bf70 编写于 作者: C CyrusNajmabadi

Merge remote-tracking branch 'upstream/master' into addImportTweaks

......@@ -19929,6 +19929,66 @@ static void M()
);
}
[Fact]
[WorkItem(14888, "https://github.com/dotnet/roslyn/issues/14888")]
public void Iterator_01()
{
var source = @"
using System;
using System.Collections.Generic;
public class C
{
static void Main(string[] args)
{
foreach (var x in entries())
{
Console.WriteLine(x);
}
}
static public IEnumerable<(int, int)> entries()
{
yield return (1, 2);
}
}
";
var comp = CompileAndVerify(source,
additionalRefs: s_valueTupleRefs,
parseOptions: TestOptions.Regular, expectedOutput: @"(1, 2)");
}
[Fact]
[WorkItem(14888, "https://github.com/dotnet/roslyn/issues/14888")]
public void Iterator_02()
{
var source = @"
using System;
using System.Collections.Generic;
public class C
{
public IEnumerable<(int, int)> entries()
{
yield return (1, 2);
}
}
";
var compilation = CreateCompilationWithMscorlib(source,
references: new[] { ValueTupleRef });
compilation.VerifyEmitDiagnostics(
// (7,24): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
// public IEnumerable<(int, int)> entries()
Diagnostic(ErrorCode.ERR_NoTypeDef, "(int, int)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(7, 24),
// (9,22): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
// yield return (1, 2);
Diagnostic(ErrorCode.ERR_NoTypeDef, "(1, 2)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(9, 22)
);
}
[Fact]
[WorkItem(14649, "https://github.com/dotnet/roslyn/issues/14649")]
public void ParseLongLambda()
......
......@@ -379,9 +379,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' When we bind generic type reference, we pass through here with symbols for
' the generic type definition, each type argument and for the final constructed
' symbol. To avoid reporting duplicate diagnostics in this scenario, report use
' site errors only on a definition. '
' site errors only on a definition.
If Not reportedAnError AndAlso Not suppressUseSiteError AndAlso
Not typeSymbol.IsArrayType() AndAlso typeSymbol.IsDefinition Then
Not typeSymbol.IsArrayType() AndAlso Not typeSymbol.IsTupleType AndAlso typeSymbol.IsDefinition Then
ReportUseSiteError(diagBag, typeSyntax, typeSymbol)
End If
......
......@@ -355,18 +355,12 @@ End Module
comp.AssertTheseDiagnostics(
<errors>
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim t as (Integer, Integer)
~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim t as (Integer, Integer)
~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim t1 as (A As Integer, B As Integer)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim t1 as (A As Integer, B As Integer)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37268: Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference?
Dim t1 as (A As Integer, B As Integer)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -4377,9 +4371,6 @@ BC37267: Predefined type 'ValueTuple(Of )' is not defined or imported.
BC37267: Predefined type 'ValueTuple(Of ,,,,,,,)' is not defined or imported.
Dim x As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) = ("Alice", 2, 3, 4, 5, 6, 7, 8)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,,,,,,,)' is not defined or imported.
Dim x As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) = ("Alice", 2, 3, 4, 5, 6, 7, 8)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of )' is not defined or imported.
Dim x As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) = ("Alice", 2, 3, 4, 5, 6, 7, 8)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -4392,9 +4383,6 @@ BC37267: Predefined type 'ValueTuple(Of )' is not defined or imported.
BC37267: Predefined type 'ValueTuple(Of ,,,,,,,)' is not defined or imported.
Dim y As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) = (1, 2, 3, 4, 5, 6, 7, 8)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,,,,,,,)' is not defined or imported.
Dim y As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) = (1, 2, 3, 4, 5, 6, 7, 8)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of )' is not defined or imported.
Dim y As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) = (1, 2, 3, 4, 5, 6, 7, 8)
~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -5065,9 +5053,6 @@ End Module
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim x As (Integer, String) = (1, "hello")
~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim x As (Integer, String) = (1, "hello")
~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim x As (Integer, String) = (1, "hello")
~~~~~~~~~~~~
......@@ -5476,9 +5461,6 @@ End Class
comp.AssertTheseDiagnostics(
<errors>
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Public Shared Function M(Of T1, T2)() As (first As T1, second As T2)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Public Shared Function M(Of T1, T2)() As (first As T1, second As T2)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -5563,9 +5545,6 @@ End Namespace
comp.AssertTheseDiagnostics(
<errors>
BC37267: Predefined type 'ValueTuple(Of ,,,,,,,)' is not defined or imported.
Function M(Of T1, T2, T3, T4, T5, T6, T7, T8, T9)() As (T1, T2, T3, T4, T5, T6, T7, T8, T9)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,,,,,,,)' is not defined or imported.
Function M(Of T1, T2, T3, T4, T5, T6, T7, T8, T9)() As (T1, T2, T3, T4, T5, T6, T7, T8, T9)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -16090,9 +16069,6 @@ End Class
comp.AssertTheseDiagnostics(
<errors>
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim t As (Integer, Integer) = Nothing
~~~~~~~~~~~~~~~~~~
BC37267: Predefined type 'ValueTuple(Of ,)' is not defined or imported.
Dim t As (Integer, Integer) = Nothing
~~~~~~~~~~~~~~~~~~
......@@ -17349,6 +17325,63 @@ BC30652: Reference required to assembly 'System.Runtime, Version=4.0.0.0, Cultur
</errors>)
End Sub
<Fact>
<WorkItem(14888, "https://github.com/dotnet/roslyn/issues/14888")>
Public Sub Iterator_01()
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C
Shared Sub Main()
For Each x in Test()
Console.WriteLine(x)
Next
End Sub
Shared Iterator Function Test() As IEnumerable(Of (integer, integer))
yield (1, 2)
End Function
End Class
</file>
</compilation>,
options:=TestOptions.ReleaseExe, additionalRefs:=s_valueTupleRefs)
CompileAndVerify(comp, expectedOutput:="(1, 2)")
End Sub
<Fact()>
<WorkItem(14888, "https://github.com/dotnet/roslyn/issues/14888")>
Public Sub Iterator_02()
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C
Iterator Function Test() As IEnumerable(Of (integer, integer))
yield (1, 2)
End Function
End Class
</file>
</compilation>, additionalRefs:={ValueTupleRef})
comp.AssertTheseEmitDiagnostics(
<errors>
BC30652: Reference required to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the type 'ValueType'. Add one to your project.
Iterator Function Test() As IEnumerable(Of (integer, integer))
~~~~~~~~~~~~~~~~~~
BC30652: Reference required to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the type 'ValueType'. Add one to your project.
yield (1, 2)
~~~~~~
</errors>)
End Sub
<Fact>
<WorkItem(269808, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=269808")>
Public Sub UserDefinedConversionsAndNameMismatch_01()
......
......@@ -40,7 +40,7 @@ try
switch ($branchName)
{
"dev15-rc" { }
"dev15-rc2" { }
"master" { }
default
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册