Skip to content

Commit 9021214

Browse files
authored
Merge pull request #18495 from michaelnebel/csharp/refstrucinterfacetests
C# 13: [TEST ONLY] ref structs are allowed to implement interfaces.
2 parents 0452b4a + 8b6e552 commit 9021214

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
3+
public interface I1
4+
{
5+
object Prop { get; set; }
6+
void M1();
7+
}
8+
9+
public interface I2
10+
{
11+
object M2();
12+
}
13+
14+
public class C : I1
15+
{
16+
public object Prop { get; set; }
17+
public void M1() { }
18+
}
19+
20+
public struct S : I1
21+
{
22+
public object Prop { get; set; }
23+
public void M1() { }
24+
public object M2() { throw null; }
25+
}
26+
27+
public ref struct RS1 : I1
28+
{
29+
public object Prop { get; set; }
30+
public void M1() { }
31+
public object M2() { throw null; }
32+
}
33+
34+
public ref struct RS2 : I1, I2
35+
{
36+
public object Prop { get; set; }
37+
public void M1() { }
38+
public object M2() { throw null; }
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
| Implements.cs:16:19:16:22 | Prop | Implements.cs:14:14:14:14 | C | Implements.cs:5:12:5:15 | Prop | Implements.cs:3:18:3:19 | I1 |
2+
| Implements.cs:16:26:16:28 | get_Prop | Implements.cs:14:14:14:14 | C | Implements.cs:5:19:5:21 | get_Prop | Implements.cs:3:18:3:19 | I1 |
3+
| Implements.cs:16:31:16:33 | set_Prop | Implements.cs:14:14:14:14 | C | Implements.cs:5:24:5:26 | set_Prop | Implements.cs:3:18:3:19 | I1 |
4+
| Implements.cs:17:17:17:18 | M1 | Implements.cs:14:14:14:14 | C | Implements.cs:6:10:6:11 | M1 | Implements.cs:3:18:3:19 | I1 |
5+
| Implements.cs:22:19:22:22 | Prop | Implements.cs:20:15:20:15 | S | Implements.cs:5:12:5:15 | Prop | Implements.cs:3:18:3:19 | I1 |
6+
| Implements.cs:22:26:22:28 | get_Prop | Implements.cs:20:15:20:15 | S | Implements.cs:5:19:5:21 | get_Prop | Implements.cs:3:18:3:19 | I1 |
7+
| Implements.cs:22:31:22:33 | set_Prop | Implements.cs:20:15:20:15 | S | Implements.cs:5:24:5:26 | set_Prop | Implements.cs:3:18:3:19 | I1 |
8+
| Implements.cs:23:17:23:18 | M1 | Implements.cs:20:15:20:15 | S | Implements.cs:6:10:6:11 | M1 | Implements.cs:3:18:3:19 | I1 |
9+
| Implements.cs:29:19:29:22 | Prop | Implements.cs:27:19:27:21 | RS1 | Implements.cs:5:12:5:15 | Prop | Implements.cs:3:18:3:19 | I1 |
10+
| Implements.cs:29:26:29:28 | get_Prop | Implements.cs:27:19:27:21 | RS1 | Implements.cs:5:19:5:21 | get_Prop | Implements.cs:3:18:3:19 | I1 |
11+
| Implements.cs:29:31:29:33 | set_Prop | Implements.cs:27:19:27:21 | RS1 | Implements.cs:5:24:5:26 | set_Prop | Implements.cs:3:18:3:19 | I1 |
12+
| Implements.cs:30:17:30:18 | M1 | Implements.cs:27:19:27:21 | RS1 | Implements.cs:6:10:6:11 | M1 | Implements.cs:3:18:3:19 | I1 |
13+
| Implements.cs:36:19:36:22 | Prop | Implements.cs:34:19:34:21 | RS2 | Implements.cs:5:12:5:15 | Prop | Implements.cs:3:18:3:19 | I1 |
14+
| Implements.cs:36:26:36:28 | get_Prop | Implements.cs:34:19:34:21 | RS2 | Implements.cs:5:19:5:21 | get_Prop | Implements.cs:3:18:3:19 | I1 |
15+
| Implements.cs:36:31:36:33 | set_Prop | Implements.cs:34:19:34:21 | RS2 | Implements.cs:5:24:5:26 | set_Prop | Implements.cs:3:18:3:19 | I1 |
16+
| Implements.cs:37:17:37:18 | M1 | Implements.cs:34:19:34:21 | RS2 | Implements.cs:6:10:6:11 | M1 | Implements.cs:3:18:3:19 | I1 |
17+
| Implements.cs:38:19:38:20 | M2 | Implements.cs:34:19:34:21 | RS2 | Implements.cs:11:12:11:13 | M2 | Implements.cs:9:18:9:19 | I2 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import csharp
2+
3+
from Overridable o1, Overridable o2
4+
where
5+
o1.overridesOrImplements(o2) and
6+
o1.fromSource() and
7+
o2.fromSource()
8+
select o1, o1.getDeclaringType(), o2, o2.getDeclaringType()

0 commit comments

Comments
 (0)