Welcome to mirror list, hosted at ThFree Co, Russian Federation.

VarianceBasic.il « Dependencies « StaticInterfaceMethods « Inheritance.Interfaces « Mono.Linker.Tests.Cases « test - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ee391b352c4674a37e3a68813945aa60b8e3def (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

.assembly extern System.Runtime
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A)
}

.assembly 'library' { }

.class interface public abstract auto ansi InterfaceScenario1`1<- T>
{
  .method public newslot virtual abstract static int32 Method() cil managed noinlining
  {
  } // end of method Method
} // end of class InterfaceScenario1`1

.class interface public abstract auto ansi InterfaceScenario2`1<- T>
{
  .method public newslot virtual abstract static int32 Method() cil managed noinlining
  {
  }
  .method public newslot virtual abstract static int32 Method2() cil managed noinlining
  {
  } // end of method Method
} // end of class InterfaceScenario2`1

.class public auto ansi BaseScenario1
       extends [System.Runtime]System.Object
       implements class InterfaceScenario1`1<object>
{
  .method public static int32 Method() cil managed noinlining
  {
    .override method int32 class InterfaceScenario1`1<object>::Method()
    ldc.i4 1
    ret
  } // end of method Method
} // end of class BaseScenario1

.class public auto ansi DerivedScenario1
       extends BaseScenario1
{
} // end of class DerivedScenario1


.class public auto ansi BaseScenario2
       extends [System.Runtime]System.Object
       implements class InterfaceScenario2`1<string>, class InterfaceScenario2`1<object>
{
  // NOTE: The order of the methods in this .il file is important as it controls the MethodImpl record creation order
  .method public static int32 Method() cil managed noinlining
  {
    .override method int32 class InterfaceScenario2`1<string>::Method()
    ldc.i4 2
    ret
  } // end of method Method
  .method public static int32 Method_Obj() cil managed noinlining
  {
    .override method int32 class InterfaceScenario2`1<object>::Method()
    ldc.i4 3
    ret
  } // end of method Method
  .method public static int32 Method2_Obj() cil managed noinlining
  {
    .override method int32 class InterfaceScenario2`1<object>::Method2()
    ldc.i4 4
    ret
  } // end of method Method
  .method public static int32 Method2() cil managed noinlining
  {
    .override method int32 class InterfaceScenario2`1<string>::Method2()
    ldc.i4 5
    ret
  } // end of method Method
} // end of class BaseScenario2

.class public auto ansi DerivedScenario2
       extends BaseScenario2
{
    .method public static int32 Method() cil managed noinlining
  {
    .override method int32 class InterfaceScenario2`1<object>::Method()
    ldc.i4 6
    ret
  } // end of method Method

  .method public static int32 Method2() cil managed noinlining
  {
    .override method int32 class InterfaceScenario2`1<object>::Method2()
    ldc.i4 7
    ret
  } // end of method Method
} // end of class DerivedScenario2

.class public auto ansi TestEntrypoint
       extends [System.Runtime]System.Object
{
  .method public static string Test_Scenario<T, (class InterfaceScenario1`1<!!0>) ImplType>() cil managed noinlining
  {
    // Variant dispatch to method on base type
    .locals init (int32 V_1)
    constrained. !!1
    call int32 class InterfaceScenario1`1<!!0>::Method()
    stloc.0
    ldloca.s   V_1
    call       instance string [System.Runtime]System.Int32::ToString()
    ret
  } // end of method Test_Scenario1

  .method public static string Test_Scenario2_1<T, (class InterfaceScenario2`1<!!0>) ImplType>() cil managed noinlining
  {
    // Variant dispatch to method on base type
    .locals init (int32 V_1)
    constrained. !!1
    call int32 class InterfaceScenario2`1<!!0>::Method()
    stloc.0
    ldloca.s   V_1
    call       instance string [System.Runtime]System.Int32::ToString()
    ret
  } // end of method Test_Scenario1

  .method public static string Test_Scenario2_2<T, (class InterfaceScenario2`1<!!0>) ImplType>() cil managed noinlining
  {
    // Variant dispatch to method on base type
    .locals init (int32 V_1)
    constrained. !!1
    call int32 class InterfaceScenario2`1<!!0>::Method2()
    stloc.0
    ldloca.s   V_1
    call       instance string [System.Runtime]System.Int32::ToString()
    ret
  } // end of method Test_Scenario1
  .method public static int32 Test() cil managed noinlining
  {
    .locals init (class [System.Runtime]System.Exception V_0)

    .try {
        ldstr "VariantDispatchToBaseTypeMethodVariantly"
        ldstr "1"
        call string TestEntrypoint::Test_Scenario<string, class BaseScenario1>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        ldstr "VariantDispatchToBaseTypeMethodFromDerivedTypeVariantly"
        ldstr "1"
        call string TestEntrypoint::Test_Scenario<string, class DerivedScenario1>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        leave.s VariantDispatchToBaseTypeMethodDone
    } catch [System.Runtime]System.Exception {
        stloc.0
        ldstr "VariantDispatchToBaseTypeMethod"
        ldstr "No Exception"
        ldloc.0
        callvirt   instance class [System.Runtime]System.Type [System.Runtime]System.Exception::GetType()
        callvirt   instance string [System.Runtime]System.Reflection.MemberInfo::get_Name()
        call void TestEntrypoint::CheckForFailure(string,string,string)
        leave.s VariantDispatchToBaseTypeMethodDone
    }
VariantDispatchToBaseTypeMethodDone: nop

    .try {
        // Variant dispatch when applied at a single layer in the type hierarchy does not take priority
        // over non-variant dispatch. This test verifies that the ordering of MethodImpl's has no effect
        // and that the correct function is called
        ldstr "NonVariantDispatchToMethodTakesPriorityOverVariantMatch"
        ldstr "2"
        call string TestEntrypoint::Test_Scenario2_1<string, class BaseScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        ldstr "NonVariantDispatchToMethodTakesPriorityOverVariantMatch"
        ldstr "3"
        call string TestEntrypoint::Test_Scenario2_1<object, class BaseScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        ldstr "NonVariantDispatchToMethodTakesPriorityOverVariantMatch"
        ldstr "4"
        call string TestEntrypoint::Test_Scenario2_2<object, class BaseScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        ldstr "NonVariantDispatchToMethodTakesPriorityOverVariantMatch"
        ldstr "5"
        call string TestEntrypoint::Test_Scenario2_2<string, class BaseScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        leave.s NonVariantDispatchToMethodTakesPriorityOverVariantMatchDone
    } catch [System.Runtime]System.Exception {
        stloc.0
        ldstr "NonVariantDispatchToMethodTakesPriorityOverVariantMatch"
        ldstr "No Exception"
        ldloc.0
        callvirt   instance class [System.Runtime]System.Type [System.Runtime]System.Exception::GetType()
        callvirt   instance string [System.Runtime]System.Reflection.MemberInfo::get_Name()
        call void TestEntrypoint::CheckForFailure(string,string,string)
        leave.s NonVariantDispatchToMethodTakesPriorityOverVariantMatchDone
    }
NonVariantDispatchToMethodTakesPriorityOverVariantMatchDone: nop
    .try {
        // Variant dispatch when applied at a two layer in the type hierarchy results in calls
        // where the variant match on the derived type will override the exact match on the base type
        ldstr "VariantDispatchToMethodOnDerivedTypeOverridesExactMatchOnBaseType"
        ldstr "6"
        call string TestEntrypoint::Test_Scenario2_1<string, class DerivedScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        ldstr "VariantDispatchToMethodOnDerivedTypeOverridesExactMatchOnBaseType"
        ldstr "6"
        call string TestEntrypoint::Test_Scenario2_1<object, class DerivedScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        ldstr "VariantDispatchToMethodOnDerivedTypeOverridesExactMatchOnBaseType"
        ldstr "7"
        call string TestEntrypoint::Test_Scenario2_2<string, class DerivedScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        ldstr "VariantDispatchToMethodOnDerivedTypeOverridesExactMatchOnBaseType"
        ldstr "7"
        call string TestEntrypoint::Test_Scenario2_2<object, class DerivedScenario2>()
        call void TestEntrypoint::CheckForFailure(string,string,string)

        leave.s VariantDispatchToMethodOnDerivedTypeOverridesExactMatchOnBaseTypeDone
    } catch [System.Runtime]System.Exception {
        stloc.0
        ldstr "VariantDispatchToBaseTypeMethodFromDerivedTypeVariantly"
        ldstr "No Exception"
        ldloc.0
        callvirt   instance class [System.Runtime]System.Type [System.Runtime]System.Exception::GetType()
        callvirt   instance string [System.Runtime]System.Reflection.MemberInfo::get_Name()
        call void TestEntrypoint::CheckForFailure(string,string,string)
        leave.s VariantDispatchToMethodOnDerivedTypeOverridesExactMatchOnBaseTypeDone
    }
VariantDispatchToMethodOnDerivedTypeOverridesExactMatchOnBaseTypeDone: nop

    call int32 TestEntrypoint::ReportResults()
    ret
  } // end of method Test
  .method public hidebysig static void  CheckForFailure(string a,
                                                        string b,
                                                        string c) cil managed
  {
    // Code size       2 (0x2)
    .maxstack  8
    IL_0000:  nop
    IL_0001:  ret
  } // end of method TestEntrypoint::CheckForFailure

} // end of class TestEntrypoint