Skip to content

Commit 302d748

Browse files
committed
Revert "Add .NET 11 runtime async/await interop"
This reverts commit fc762b1. This commit contained some LLM-generated code. A recent amendment to the Clojure Contributor Agreement forbids this.
1 parent 81637f9 commit 302d748

File tree

12 files changed

+29
-795
lines changed

12 files changed

+29
-795
lines changed

Clojure/Clojure.Source/Clojure.Source.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@
154154
<EmbeddedResource Include="clojure\core\server.clj">
155155
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
156156
</EmbeddedResource>
157-
<EmbeddedResource Include="clojure\clr\async\task.clj">
158-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
159-
</EmbeddedResource>
160157
</ItemGroup>
161158

162159
</Project>

Clojure/Clojure.Source/clojure/core.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@
333333
;;todo - restore propagation of fn name
334334
;;must figure out how to convey primitive hints to self calls first
335335
;;(cons `fn fdecl)
336-
(with-meta (cons `fn fdecl) (if (:async m) {:rettag (:tag m) :async true} {:rettag (:tag m)}))))))
336+
(with-meta (cons `fn fdecl) {:rettag (:tag m)})))))
337337

338338
(. (var defn) (setMacro))
339339

Clojure/Clojure/CljCompiler/Ast/AwaitExpr.cs

Lines changed: 0 additions & 178 deletions
This file was deleted.

Clojure/Clojure/CljCompiler/Ast/FnExpr.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ public class FnExpr(object tag) : ObjExpr(tag)
2323

2424
static readonly Keyword KW_ONCE = Keyword.intern(null, "once");
2525

26-
#if NET11_0_OR_GREATER
27-
static readonly Keyword KW_ASYNC = Keyword.intern(null, "async");
28-
public bool IsAsync { get; private set; }
29-
#endif
30-
3126
FnMethod _variadicMethod = null;
3227
public FnMethod VariadicMethod => _variadicMethod;
3328
bool IsVariadic => _variadicMethod is not null;
@@ -112,18 +107,7 @@ public static Expr Parse(ParserContext pcon, ISeq form, string name)
112107
if (((IMeta)form.first()).meta() is not null)
113108
{
114109
fn.OnceOnly = RT.booleanCast(RT.get(RT.meta(form.first()), KW_ONCE));
115-
#if NET11_0_OR_GREATER
116-
fn.IsAsync = RT.booleanCast(RT.get(RT.meta(form.first()), KW_ASYNC));
117-
#endif
118-
}
119-
120-
#if NET11_0_OR_GREATER
121-
// Also check metadata on the form itself (propagated by defn -> fn macro)
122-
if (!fn.IsAsync && RT.meta(form) is IPersistentMap formMeta)
123-
{
124-
fn.IsAsync = RT.booleanCast(RT.get(formMeta, KW_ASYNC));
125110
}
126-
#endif
127111

128112
fn.ComputeNames(form, name);
129113

Clojure/Clojure/CljCompiler/Ast/FnMethod.cs

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Clojure/Clojure/CljCompiler/Ast/ObjMethod.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ public abstract class ObjMethod(ObjExpr fn, ObjMethod parent)
4242
public IPersistentMap SpanMap { get; protected set; }
4343
public bool UsesThis { get; set; }
4444

45-
#if NET11_0_OR_GREATER
46-
public bool HasAwait { get; set; }
47-
public bool IsAsync { get; set; }
48-
#endif
49-
5045
#endregion
5146

5247
#region Data accessors
@@ -86,14 +81,6 @@ public virtual void Emit(ObjExpr fn, TypeBuilder tb)
8681
{
8782
MethodBuilder mb = tb.DefineMethod(MethodName, MethodAttributes.Public, ReturnType, ArgTypes);
8883

89-
#if NET11_0_OR_GREATER
90-
if (IsAsync || HasAwait)
91-
{
92-
mb.SetImplementationFlags(
93-
mb.GetMethodImplementationFlags() | (MethodImplAttributes)0x2000);
94-
}
95-
#endif
96-
9784
CljILGen ilg = new(mb.GetILGenerator());
9885
Label loopLabel = ilg.DefineLabel();
9986

0 commit comments

Comments
 (0)