From fb5e81db27b075faf2f11446654b13fa77f40ec0 Mon Sep 17 00:00:00 2001 From: Llewellyn Pritchard Date: Tue, 8 Dec 2015 07:46:02 +0200 Subject: [PATCH] Add test cases for expressions too --- .../Semantics/OverloadResolutionTests.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs index e5a1c2c89f8..4d4c92710eb 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs @@ -606,25 +606,37 @@ public void TestRefOutAnonymousDelegate() { string source = @" using System; +using System.Linq.Expressions; class p { static void Foo(ref Func a) { } static void Bar(out Func a) { a = null; } + static void Foo2(ref Expression> a) { } + static void Bar2(out Expression> a) { a = null; } + static void Main() { Foo(x => x); Bar(x => x); + Foo2(x => x); + Bar2(x => x); } }"; - CreateCompilationWithMscorlib(source).VerifyDiagnostics( - // (10,21): error CS1503: Argument 1: cannot convert from 'lambda expression' to 'ref Func' + CreateCompilationWithMscorlibAndSystemCore(source).VerifyDiagnostics( + // (14,21): error CS1503: Argument 1: cannot convert from 'lambda expression' to 'ref Func' // Foo(x => x); - Diagnostic(ErrorCode.ERR_BadArgType, "x => x").WithArguments("1", "lambda expression", "ref System.Func").WithLocation(10, 21), - // (11,21): error CS1503: Argument 1: cannot convert from 'lambda expression' to 'out Func' + Diagnostic(ErrorCode.ERR_BadArgType, "x => x").WithArguments("1", "lambda expression", "ref System.Func").WithLocation(14, 21), + // (15,21): error CS1503: Argument 1: cannot convert from 'lambda expression' to 'out Func' // Bar(x => x); - Diagnostic(ErrorCode.ERR_BadArgType, "x => x").WithArguments("1", "lambda expression", "out System.Func").WithLocation(11, 21)); + Diagnostic(ErrorCode.ERR_BadArgType, "x => x").WithArguments("1", "lambda expression", "out System.Func").WithLocation(15, 21), + // (16,22): error CS1503: Argument 1: cannot convert from 'lambda expression' to 'ref Expression>' + // Foo2(x => x); + Diagnostic(ErrorCode.ERR_BadArgType, "x => x").WithArguments("1", "lambda expression", "ref System.Linq.Expressions.Expression>").WithLocation(16, 22), + // (17,22): error CS1503: Argument 1: cannot convert from 'lambda expression' to 'out Expression>' + // Bar2(x => x); + Diagnostic(ErrorCode.ERR_BadArgType, "x => x").WithArguments("1", "lambda expression", "out System.Linq.Expressions.Expression>").WithLocation(17, 22)); } -- GitLab