Skip to content

Commit 648c838

Browse files
committed
Added test case for issue #1148 containing delegates with interface as TResult
1 parent 1338963 commit 648c838

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Tests/CSharp/ExpressionTests/ExpressionTests.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,74 @@ private void TestMethod()
14401440
}");
14411441
}
14421442

1443+
[Fact]
1444+
public async Task Issue1148_AddressOfSignatureCompatibilityAsync()
1445+
{
1446+
await TestConversionVisualBasicToCSharpAsync(@"
1447+
Imports System
1448+
1449+
Public Class Issue1148
1450+
Public Shared FuncClass As Func(Of TestObjClass) = AddressOf FunctionReturningClass
1451+
Public Shared FuncBaseClass As Func(Of TestBaseObjClass) = AddressOf FunctionReturningClass
1452+
Public Shared FuncInterface As Func(Of ITestObj) = AddressOf FunctionReturningClass
1453+
Public Shared FuncInterfaceParam As Func(Of ITestObj, ITestObj) = AddressOf CastObj
1454+
1455+
Public Shared Function FunctionReturningClass() As TestObjClass
1456+
Return New TestObjClass()
1457+
End Function
1458+
1459+
Public Shared Function CastObj(obj As ITestObj) As TestObjClass
1460+
Return CType(obj, TestObjClass)
1461+
End Function
1462+
1463+
End Class
1464+
1465+
Public Class TestObjClass
1466+
Inherits TestBaseObjClass
1467+
Implements ITestObj
1468+
End Class
1469+
1470+
Public Class TestBaseObjClass
1471+
End Class
1472+
1473+
Public Interface ITestObj
1474+
End Interface
1475+
", @"
1476+
using System;
1477+
1478+
public partial class Issue1148
1479+
{
1480+
public static Func<TestObjClass> FuncClass = FunctionReturningClass;
1481+
public static Func<TestBaseObjClass> FuncBaseClass = FunctionReturningClass;
1482+
public static Func<ITestObj> FuncInterface = FunctionReturningClass;
1483+
public static Func<ITestObj, ITestObj> FuncInterfaceParam = CastObj;
1484+
1485+
public static TestObjClass FunctionReturningClass()
1486+
{
1487+
return new TestObjClass();
1488+
}
1489+
1490+
public static TestObjClass CastObj(ITestObj obj)
1491+
{
1492+
return (TestObjClass)obj;
1493+
}
1494+
1495+
}
1496+
1497+
public partial class TestObjClass : TestBaseObjClass, ITestObj
1498+
{
1499+
}
1500+
1501+
public partial class TestBaseObjClass
1502+
{
1503+
}
1504+
1505+
public partial interface ITestObj
1506+
{
1507+
}
1508+
");
1509+
}
1510+
14431511
[Fact]
14441512
public async Task LambdaImmediatelyExecutedAsync()
14451513
{

0 commit comments

Comments
 (0)