Skip to content

Commit cd2e4ff

Browse files
committed
Revert "CLJCLR-175: Fix aset throwing an exception when arg is type Array by inference (say from aclone)."
This reverts commit 9d6243e.
1 parent 9d6243e commit cd2e4ff

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

Clojure/Clojure/Lib/RT.cs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ static Dictionary<Symbol, Type> CreateDefaultImportDictionary()
5252

5353
static IEnumerable<Type> GetAllTypesInNamespace(string nspace)
5454
{
55-
Func<Assembly, IEnumerable<Type>> getTypes = (Assembly a) =>
56-
{
55+
Func<Assembly, IEnumerable<Type>> getTypes = (Assembly a) => {
5756
try { return a.GetTypes(); } catch (Exception) { return new Type[0]; }
5857
};
5958
var q = AppDomain.CurrentDomain.GetAssemblies()
@@ -75,7 +74,7 @@ static IEnumerable<Type> GetAllTypesInNamespace(string nspace)
7574

7675
public static readonly object[] EmptyObjectArray = new Object[] { };
7776

78-
static readonly RTProperties _versionProperties = new();
77+
static readonly RTProperties _versionProperties = new RTProperties();
7978

8079
public static RTProperties GetVersionProperties() { return _versionProperties; }
8180

@@ -84,7 +83,7 @@ static IEnumerable<Type> GetAllTypesInNamespace(string nspace)
8483
// for folks using Cygwin and its ilk.
8584
public const string ClojureLoadPathString = "CLOJURE_LOAD_PATH";
8685

87-
static public readonly Object REQUIRE_LOCK = new();
86+
static public readonly Object REQUIRE_LOCK = new Object();
8887

8988
#endregion
9089

@@ -124,7 +123,7 @@ public static readonly Namespace ClojureNamespace
124123
public static readonly Keyword TagKey
125124
= Keyword.intern(null, "tag");
126125

127-
public static readonly Keyword ParamTagsKey
126+
public static readonly Keyword ParamTagsKey
128127
= Keyword.intern(null, "param-tags");
129128

130129
public static readonly Keyword ConstKey
@@ -337,7 +336,7 @@ public override object invoke(object arg1)
337336

338337
static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
339338
{
340-
AssemblyName asmName = new(args.Name);
339+
AssemblyName asmName = new AssemblyName(args.Name);
341340
var name = asmName.Name;
342341
var stream = GetEmbeddedResourceStream(name, out _);
343342
if (stream == null)
@@ -372,16 +371,16 @@ static RT()
372371

373372
// TODO: Check for existence of ClojureContext.Default before doing this?
374373

375-
ScriptRuntimeSetup setup = new();
376-
LanguageSetup lsetup = new(
374+
ScriptRuntimeSetup setup = new ScriptRuntimeSetup();
375+
LanguageSetup lsetup = new LanguageSetup(
377376
typeof(ClojureContext).AssemblyQualifiedName,
378377
ClojureContext.ClojureDisplayName,
379378
ClojureContext.ClojureNames.Split(new Char[] { ';' }),
380379
ClojureContext.ClojureFileExtensions.Split(new Char[] { ';' }));
381380

382381

383382
setup.LanguageSetups.Add(lsetup);
384-
ScriptRuntime env = new(setup);
383+
ScriptRuntime env = new ScriptRuntime(setup);
385384
env.GetEngine("clj");
386385

387386

@@ -2376,7 +2375,7 @@ public static object[] toArray(object coll)
23762375

23772376
private static object[] IEnumToArray(IEnumerable e)
23782377
{
2379-
List<object> list = new();
2378+
List<object> list = new List<object>();
23802379
foreach (object o in e)
23812380
list.Add(o);
23822381

@@ -2504,7 +2503,7 @@ public static bool suppressRead()
25042503

25052504
static public string printString(object x)
25062505
{
2507-
using (StringWriter sw = new())
2506+
using (StringWriter sw = new StringWriter())
25082507
{
25092508
print(x, sw);
25102509
return sw.ToString();
@@ -2520,7 +2519,7 @@ static public Object readString(String s)
25202519

25212520
static public Object readString(String s, Object opts)
25222521
{
2523-
using (PushbackTextReader r = new(new StringReader(s)))
2522+
using (PushbackTextReader r = new PushbackTextReader(new StringReader(s)))
25242523
return LispReader.read(r, opts);
25252524
}
25262525

@@ -2785,7 +2784,7 @@ public static Type classForName(string p)
27852784

27862785
AppDomain domain = AppDomain.CurrentDomain;
27872786
Assembly[] assys = domain.GetAssemblies();
2788-
List<Type> candidateTypes = new();
2787+
List<Type> candidateTypes = new List<Type>();
27892788

27902789
// fast path, will succeed for namespace qualified names (returned by Type.FullName)
27912790
// e.g. "UnityEngine.Transform"
@@ -2865,9 +2864,9 @@ public static int alength(Array a)
28652864
}
28662865

28672866

2868-
public static object aclone(Array a)
2867+
public static Array aclone(Array a)
28692868
{
2870-
return a.Clone();
2869+
return (Array)a.Clone();
28712870
}
28722871

28732872

@@ -3142,7 +3141,7 @@ public static long nanoTime()
31423141
return DateTime.Now.Ticks * 100;
31433142
}
31443143

3145-
private static readonly Stopwatch _stopwatch = new();
3144+
private static readonly Stopwatch _stopwatch = new Stopwatch();
31463145

31473146
public static object StartStopwatch()
31483147
{
@@ -3210,7 +3209,7 @@ public static void SortArray(Array a, IFn fn)
32103209

32113210

32123211

3213-
static readonly Random _random = new();
3212+
static readonly Random _random = new Random();
32143213

32153214

32163215
public static double random()
@@ -3364,7 +3363,7 @@ private static bool TryLoadFromEmbeddedResource(string relativePath, string asse
33643363

33653364
var embeddedCljName = relativePath.Replace("/", ".") + ".cljr";
33663365
var stream = GetEmbeddedResourceStream(embeddedCljName, out Assembly containingAssembly);
3367-
if (stream == null)
3366+
if ( stream == null )
33683367
{
33693368
embeddedCljName = relativePath.Replace("/", ".") + ".cljc";
33703369
stream = GetEmbeddedResourceStream(embeddedCljName, out containingAssembly);
@@ -3402,12 +3401,12 @@ public static void LoadCljScript(string cljname, bool failIfNotFound)
34023401
{
34033402
FileInfo cljInfo = FindFile(cljname);
34043403
if (cljInfo != null)
3405-
LoadScript(cljInfo, cljname);
3404+
LoadScript(cljInfo,cljname);
34063405
else if (failIfNotFound)
34073406
throw new FileNotFoundException(String.Format("Could not locate Clojure resource on {0}", ClojureLoadPathString));
34083407
}
34093408

3410-
public static void LoadScript(FileInfo cljInfo, string relativePath)
3409+
public static void LoadScript(FileInfo cljInfo, string relativePath)
34113410
{
34123411
using (TextReader rdr = cljInfo.OpenText())
34133412
LoadScript(cljInfo.FullName, cljInfo.Name, rdr, relativePath);
@@ -3420,7 +3419,7 @@ private static void LoadScript(string fullName, string name, TextReader rdr, str
34203419

34213420
private static void Compile(FileInfo cljInfo, string relativePath)
34223421
{
3423-
using (TextReader rdr = cljInfo.OpenText())
3422+
using ( TextReader rdr = cljInfo.OpenText() )
34243423
Compile(cljInfo.Directory.FullName, cljInfo.Name, rdr, relativePath);
34253424
}
34263425

@@ -3451,7 +3450,7 @@ static IEnumerable<string> GetFindFilePathsRaw()
34513450
yield return Path.GetDirectoryName(typeof(RT).Assembly.Location);
34523451

34533452
Assembly assy = Assembly.GetEntryAssembly();
3454-
if (assy != null)
3453+
if ( assy != null )
34553454
yield return Path.GetDirectoryName(assy.Location);
34563455

34573456
string rawpaths = (string)System.Environment.GetEnvironmentVariable(ClojureLoadPathString);
@@ -3471,7 +3470,7 @@ public static FileInfo FindFile(string fileName)
34713470
foreach (string path in GetFindFilePaths())
34723471
{
34733472
fi = FindFile(path, fileName);
3474-
if (fi is not null) return fi;
3473+
if (fi is not null ) return fi;
34753474
}
34763475

34773476
return FindRemappedFile(fileName);
@@ -3491,11 +3490,11 @@ public static FileInfo FindRemappedFile(string fileName)
34913490
if (!(x is PersistentVector mapping) || mapping.length() < 2) continue;
34923491
if (!(mapping[0] is string nsRoot)) continue;
34933492
nsRoot = nsRoot.Replace('.', '/');
3494-
if (fileName.StartsWith(nsRoot))
3493+
if(fileName.StartsWith(nsRoot))
34953494
{
34963495
var fsRoot = mapping[1] as string;
34973496
var probePath = ConvertPath(fsRoot) + ConvertPath(fileName.Substring(nsRoot.Length));
3498-
if (File.Exists(probePath))
3497+
if(File.Exists(probePath))
34993498
return new FileInfo(probePath);
35003499
}
35013500
}
@@ -3622,7 +3621,7 @@ public static string[] TrimTrailingEmptyStrings(string[] arr)
36223621
break;
36233622
i--;
36243623
}
3625-
Array.Resize(ref arr, i + 1);
3624+
Array.Resize(ref arr,i + 1);
36263625
return arr;
36273626
}
36283627

0 commit comments

Comments
 (0)