This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix direction of variance check in delegate assignment (#4945)
* Fix direction of variance check in delegate assignment * Add tests
- Loading branch information
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
.assembly extern System.Runtime | ||
{ | ||
} | ||
|
||
.assembly DelegateTests | ||
{ | ||
} | ||
|
||
.class private auto ansi beforefieldinit C | ||
extends [System.Runtime]System.Object | ||
{ | ||
// assignment from Func<int, string> to Func<int, object> is valid | ||
.method private hidebysig instance class [System.Runtime]System.Func`2<int32,object> | ||
DelegateAssignmentReturn_Valid(class [System.Runtime]System.Func`2<int32,string> input) cil managed | ||
{ | ||
ldarg.1 | ||
ret | ||
} | ||
|
||
// assignment from Func<object, int> to Func<string, int> is valid | ||
.method private hidebysig instance class [System.Runtime]System.Func`2<string,int32> | ||
DelegateAssignmentParameter_Valid(class [System.Runtime]System.Func`2<object,int32> input) cil managed | ||
{ | ||
ldarg.1 | ||
ret | ||
} | ||
|
||
// assignment from Func<string, int> to Func<object, int> is invalid | ||
.method private hidebysig instance class [System.Runtime]System.Func`2<object,int32> | ||
DelegateAssignmentParameter_Invalid_StackUnexpected(class [System.Runtime]System.Func`2<string,int32> input) cil managed | ||
{ | ||
ldarg.1 | ||
ret | ||
} | ||
|
||
// assignment from Func<int, object> to Func<int, string> is invalid | ||
.method private hidebysig instance class [System.Runtime]System.Func`2<int32,string> | ||
DelegateAssignment_Invalid_StackUnexpected(class [System.Runtime]System.Func`2<int32,object> input) cil managed | ||
{ | ||
ldarg.1 | ||
ret | ||
} | ||
|
||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
ldarg.0 | ||
call instance void [System.Runtime]System.Object::.ctor() | ||
ret | ||
} | ||
} |