@@ -114,10 +114,6 @@ internal static FnMethod Parse(FnExpr fn, ISeq form, object retTag)
114114 SpanMap = ( IPersistentMap ) Compiler . SourceSpanVar . deref ( )
115115 } ;
116116
117- #if NET11_0_OR_GREATER
118- method . IsAsync = fn . IsAsync ;
119- #endif
120-
121117 Var . pushThreadBindings ( RT . mapUniqueKeys (
122118 Compiler . MethodVar , method ,
123119 Compiler . LocalEnvVar , Compiler . LocalEnvVar . deref ( ) ,
@@ -152,10 +148,6 @@ internal static FnMethod Parse(FnExpr fn, ISeq form, object retTag)
152148 //if (method._prim != null)
153149 // method._prim = method._prim.Replace('.', '/');
154150
155- #if NET11_0_OR_GREATER
156- if ( method . IsAsync && method . _prim != null )
157- throw new ParseException ( "^:async cannot be combined with primitive type hints" ) ;
158- #endif
159151
160152 // register 'this' as local 0
161153 Compiler . RegisterLocalThis ( Symbol . intern ( fn . ThisName ?? "fn__" + RT . nextID ( ) ) , null , null ) ;
@@ -341,24 +333,10 @@ private void DoEmitStatic(ObjExpr fn, TypeBuilder tb)
341333
342334 string methodName = "invokeStatic" ;
343335
344- #if NET11_0_OR_GREATER
345- Type returnType = ( IsAsync || HasAwait )
346- ? typeof ( System . Threading . Tasks . Task < object > )
347- : ReturnType ;
348- #else
349336 Type returnType = ReturnType ;
350- #endif
351337
352338 MethodBuilder baseMB = tb . DefineMethod ( methodName , attribs , returnType , _argTypes ) ;
353339
354- #if NET11_0_OR_GREATER
355- if ( IsAsync || HasAwait )
356- {
357- baseMB . SetImplementationFlags (
358- baseMB . GetMethodImplementationFlags ( ) | ( MethodImplAttributes ) 0x2000 ) ;
359- }
360- #endif
361-
362340 CljILGen baseIlg = new ( baseMB . GetILGenerator ( ) ) ;
363341
364342 try
@@ -483,14 +461,6 @@ private void DoEmitPrim(ObjExpr fn, TypeBuilder tb)
483461
484462 private void DoEmit ( ObjExpr fn , TypeBuilder tb )
485463 {
486- #if NET11_0_OR_GREATER
487- if ( IsAsync || HasAwait )
488- {
489- DoEmitAsync ( fn , tb ) ;
490- return ;
491- }
492- #endif
493-
494464 MethodAttributes attribs = MethodAttributes . ReuseSlot | MethodAttributes . Public | MethodAttributes . Virtual ;
495465 MethodBuilder mb = tb . DefineMethod ( MethodName , attribs , ReturnType , ArgTypes ) ;
496466 SetCustomAttributes ( mb ) ;
@@ -518,61 +488,6 @@ private void DoEmit(ObjExpr fn, TypeBuilder tb)
518488 tb . DefineMethodOverride ( mb , ExplicitMethodInfo ) ;
519489 }
520490
521- #if NET11_0_OR_GREATER
522- private void DoEmitAsync ( ObjExpr fn , TypeBuilder tb )
523- {
524- // Generate the async implementation method: invokeAsync() -> Task<object>
525- // This method gets the 0x2000 async flag and contains the real body with await* calls.
526- Type asyncReturnType = typeof ( System . Threading . Tasks . Task < object > ) ;
527- MethodBuilder asyncMB = tb . DefineMethod (
528- MethodName + "Async" ,
529- MethodAttributes . Private ,
530- asyncReturnType ,
531- ArgTypes ) ;
532-
533- asyncMB . SetImplementationFlags (
534- asyncMB . GetMethodImplementationFlags ( ) | ( MethodImplAttributes ) 0x2000 ) ;
535-
536- CljILGen asyncIlg = new ( asyncMB . GetILGenerator ( ) ) ;
537-
538- try
539- {
540- Label loopLabel = asyncIlg . DefineLabel ( ) ;
541- Var . pushThreadBindings ( RT . map ( Compiler . LoopLabelVar , loopLabel , Compiler . MethodVar , this ) ) ;
542-
543- GenContext . EmitDebugInfo ( asyncIlg , SpanMap ) ;
544-
545- asyncIlg . MarkLabel ( loopLabel ) ;
546- Body . Emit ( RHC . Return , fn , asyncIlg ) ;
547- if ( Body . HasNormalExit ( ) )
548- asyncIlg . Emit ( OpCodes . Ret ) ;
549- }
550- finally
551- {
552- Var . popThreadBindings ( ) ;
553- }
554-
555- // Generate the IFn.invoke() override: invoke() -> object
556- // This wrapper calls invokeAsync() and returns the Task<object> as object.
557- MethodAttributes attribs = MethodAttributes . ReuseSlot | MethodAttributes . Public | MethodAttributes . Virtual ;
558- MethodBuilder invokeMB = tb . DefineMethod ( MethodName , attribs , typeof ( object ) , ArgTypes ) ;
559- SetCustomAttributes ( invokeMB ) ;
560-
561- CljILGen invokeIlg = new ( invokeMB . GetILGenerator ( ) ) ;
562-
563- // Load 'this' and all arguments, then call invokeAsync
564- invokeIlg . Emit ( OpCodes . Ldarg_0 ) ;
565- for ( int i = 0 ; i < ArgTypes . Length ; i ++ )
566- invokeIlg . EmitLoadArg ( i + 1 ) ;
567- invokeIlg . Emit ( OpCodes . Call , asyncMB ) ;
568- // Task<object> is already an object reference, no boxing needed
569- invokeIlg . Emit ( OpCodes . Ret ) ;
570-
571- if ( IsExplicit )
572- tb . DefineMethodOverride ( invokeMB , ExplicitMethodInfo ) ;
573- }
574- #endif
575-
576491 #endregion
577492 }
578493}
0 commit comments