@@ -15,24 +15,24 @@ public sealed partial class EcmaMethod : MethodDesc, EcmaModule.IEntityHandleObj
1515 {
1616 private static class MethodFlags
1717 {
18- public const int BasicMetadataCache = 0x00001 ;
19- public const int Virtual = 0x00002 ;
20- public const int NewSlot = 0x00004 ;
21- public const int Abstract = 0x00008 ;
22- public const int Final = 0x00010 ;
23- public const int NoInlining = 0x00020 ;
24- public const int AggressiveInlining = 0x00040 ;
25- public const int RuntimeImplemented = 0x00080 ;
26- public const int InternalCall = 0x00100 ;
27- public const int Synchronized = 0x00200 ;
18+ public const int BasicMetadataCache = 0x00001 ;
19+ public const int Virtual = 0x00002 ;
20+ public const int NewSlot = 0x00004 ;
21+ public const int Abstract = 0x00008 ;
22+ public const int Final = 0x00010 ;
23+ public const int NoInlining = 0x00020 ;
24+ public const int AggressiveInlining = 0x00040 ;
25+ public const int RuntimeImplemented = 0x00080 ;
26+ public const int InternalCall = 0x00100 ;
27+ public const int Synchronized = 0x00200 ;
2828 public const int AggressiveOptimization = 0x00400 ;
29- public const int NoOptimization = 0x00800 ;
30- public const int RequireSecObject = 0x01000 ;
29+ public const int NoOptimization = 0x00800 ;
30+ public const int RequireSecObject = 0x01000 ;
3131
3232 public const int AttributeMetadataCache = 0x02000 ;
33- public const int Intrinsic = 0x04000 ;
34- public const int UnmanagedCallersOnly = 0x08000 ;
35- public const int Async = 0x10000 ;
33+ public const int Intrinsic = 0x04000 ;
34+ public const int UnmanagedCallersOnly = 0x08000 ;
35+ public const int Async = 0x10000 ;
3636 } ;
3737
3838 private EcmaType _type ;
@@ -85,43 +85,8 @@ private MethodSignature InitializeSignature()
8585 EcmaSignatureParser parser = new EcmaSignatureParser ( Module , signatureReader , NotFoundBehavior . Throw ) ;
8686 var signature = parser . ParseMethodSignature ( ) ;
8787
88- bool returnsTask = signature . ReturnsTaskOrValueTask ( ) ;
89- if ( ! returnsTask && ! IsAsync )
90- {
91- _asyncMethodData = new AsyncMethodData
92- {
93- Kind = AsyncMethodKind . NotAsync ,
94- Signature = signature
95- } ;
96- }
97- else if ( returnsTask && IsAsync )
98- {
99- _asyncMethodData = new AsyncMethodData
100- {
101- Kind = AsyncMethodKind . AsyncVariantImpl ,
102- Signature = signature . CreateAsyncSignature ( )
103- } ;
104- }
105- else if ( returnsTask && ! IsAsync )
106- {
107- _asyncMethodData = new AsyncMethodData
108- {
109- Kind = AsyncMethodKind . TaskReturning ,
110- Signature = signature
111- } ;
112- }
113- else
114- {
115- Debug . Assert ( IsAsync && ! returnsTask ) ;
116- _asyncMethodData = new AsyncMethodData
117- {
118- Kind = AsyncMethodKind . AsyncExplicitImpl ,
119- Signature = signature
120- } ;
121- }
122-
12388 _metadataSignature = signature ;
124- return ( _metadataSignature = signature ) ;
89+ return _metadataSignature ;
12590 }
12691
12792 public override MethodSignature Signature
@@ -139,19 +104,6 @@ public override MethodSignature Signature
139104 }
140105 }
141106
142- /// <summary>
143- /// The method signature as defined in metadata, without any adjustments for async methods.
144- /// </summary>
145- public MethodSignature MetadataSignature
146- {
147- get
148- {
149- if ( _metadataSignature == null )
150- return InitializeSignature ( ) ;
151- return _metadataSignature ;
152- }
153- }
154-
155107 public EcmaModule Module
156108 {
157109 get
@@ -441,7 +393,28 @@ public override AsyncMethodData AsyncMethodData
441393 get
442394 {
443395 if ( _asyncMethodData . Equals ( default ( AsyncMethodData ) ) )
396+ {
444397 InitializeSignature ( ) ;
398+ bool returnsTask = _metadataSignature . ReturnsTaskOrValueTask ( ) ;
399+ if ( ! returnsTask && ! IsAsync )
400+ {
401+ _asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind . NotAsync , Signature = _metadataSignature } ;
402+ }
403+ else if ( returnsTask && IsAsync )
404+ {
405+ var asyncSignature = _metadataSignature . CreateAsyncSignature ( ) ;
406+ _asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind . AsyncVariantImpl , Signature = asyncSignature } ;
407+ }
408+ else if ( returnsTask && ! IsAsync )
409+ {
410+ _asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind . TaskReturning , Signature = _metadataSignature } ;
411+ }
412+ else
413+ {
414+ Debug . Assert ( IsAsync && ! returnsTask ) ;
415+ _asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind . AsyncExplicitImpl , Signature = _metadataSignature } ;
416+ }
417+ }
445418
446419 Debug . Assert ( ! _asyncMethodData . Equals ( default ( AsyncMethodData ) ) ) ;
447420 return _asyncMethodData ;
0 commit comments