diff --git a/Src/IronPython.Modules/_thread.cs b/Src/IronPython.Modules/_thread.cs
index 4bde8c6b5..e8df1f394 100644
--- a/Src/IronPython.Modules/_thread.cs
+++ b/Src/IronPython.Modules/_thread.cs
@@ -228,9 +228,9 @@ public void Start() {
try {
#pragma warning disable 618 // TODO: obsolete
if (_kwargs != null) {
- PythonOps.CallWithArgsTupleAndKeywordDictAndContext(_context, _func, ArrayUtils.EmptyObjects, ArrayUtils.EmptyStrings, _args, _kwargs);
+ PythonOps.CallWithArgsTupleAndKeywordDictAndContext(_context, _func, [], [], _args, _kwargs);
} else {
- PythonOps.CallWithArgsTuple(_func, ArrayUtils.EmptyObjects, _args);
+ PythonOps.CallWithArgsTuple(_func, [], _args);
}
#pragma warning restore 618
} catch (SystemExitException) {
diff --git a/Src/IronPython/Compiler/Ast/ClassDefinition.cs b/Src/IronPython/Compiler/Ast/ClassDefinition.cs
index 1b126d4fe..8c68fab0b 100644
--- a/Src/IronPython/Compiler/Ast/ClassDefinition.cs
+++ b/Src/IronPython/Compiler/Ast/ClassDefinition.cs
@@ -15,7 +15,6 @@
using IronPython.Runtime;
using Microsoft.Scripting;
-using Microsoft.Scripting.Actions;
using Microsoft.Scripting.Utils;
using AstUtils = Microsoft.Scripting.Ast.Utils;
@@ -403,7 +402,7 @@ public static string[] FindNames(FunctionDefinition function) {
if (parameters.Count == 0) {
// no point analyzing function with no parameters
- return ArrayUtils.EmptyStrings;
+ return [];
}
var finder = new SelfNameFinder(function, parameters[0]);
diff --git a/Src/IronPython/Compiler/Ast/FunctionDefinition.cs b/Src/IronPython/Compiler/Ast/FunctionDefinition.cs
index edc452a27..36e74b0bb 100644
--- a/Src/IronPython/Compiler/Ast/FunctionDefinition.cs
+++ b/Src/IronPython/Compiler/Ast/FunctionDefinition.cs
@@ -5,21 +5,20 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
-using System.Runtime.CompilerServices;
-
-using Microsoft.Scripting;
-using Microsoft.Scripting.Interpreter;
-using Microsoft.Scripting.Utils;
using IronPython.Runtime;
using IronPython.Runtime.Operations;
-using MSAst = System.Linq.Expressions;
+using Microsoft.Scripting;
+using Microsoft.Scripting.Interpreter;
+using Microsoft.Scripting.Utils;
-using LightLambdaExpression = Microsoft.Scripting.Ast.LightLambdaExpression;
using AstUtils = Microsoft.Scripting.Ast.Utils;
+using LightLambdaExpression = Microsoft.Scripting.Ast.LightLambdaExpression;
+using MSAst = System.Linq.Expressions;
namespace IronPython.Compiler.Ast {
using Ast = MSAst.Expression;
@@ -85,8 +84,7 @@ internal override MSAst.Expression LocalContext {
internal override int ArgCount {
get {
int argCount = 0;
- for (argCount = 0; argCount < _parameters.Length; argCount++)
- {
+ for (argCount = 0; argCount < _parameters.Length; argCount++) {
Parameter p = _parameters[argCount];
if (p.IsDictionary || p.IsList || p.IsKeywordOnly) break;
}
@@ -256,7 +254,7 @@ internal override void Bind(PythonNameBinder binder) {
NeedsLocalsDictionary = true;
}
}
-
+
internal override void FinishBind(PythonNameBinder binder) {
foreach (var param in _parameters) {
_variableMapping[param.PythonVariable] = param.FinishBind(forceClosureCell: ExposesLocalVariable(param.PythonVariable));
@@ -286,7 +284,7 @@ public override MSAst.Expression Reduce() {
new SourceSpan(GlobalParent.IndexToLocation(StartIndex), GlobalParent.IndexToLocation(HeaderIndex))
);
}
-
+
///
/// Returns an expression which creates the function object.
///
@@ -542,7 +540,7 @@ public override int Run(InterpretedFrame frame) {
defaults[i] = frame.Pop();
}
} else {
- defaults = ArrayUtils.EmptyObjects;
+ defaults = [];
}
object modName;
@@ -779,7 +777,7 @@ internal override IList GetVarNames() {
return res;
}
-
+
private void InitializeParameters(List init, bool needsWrapperMethod, MSAst.Expression[] parameters) {
for (int i = 0; i < _parameters.Length; i++) {
Parameter p = _parameters[i];
@@ -829,10 +827,10 @@ private static Type GetDelegateType(Parameter[] parameters, bool wrapper, out De
internal override void RewriteBody(MSAst.ExpressionVisitor visitor) {
_dlrBody = null; // clear the cached body if we've been reduced
-
+
MSAst.Expression funcCode = GlobalParent.Constant(GetOrMakeFunctionCode());
FuncCodeExpr = funcCode;
-
+
Body = new RewrittenBodyStatement(Body, visitor.Visit(Body));
}
diff --git a/Src/IronPython/Compiler/Ast/ScopeStatement.cs b/Src/IronPython/Compiler/Ast/ScopeStatement.cs
index 28d571804..55ddbee69 100644
--- a/Src/IronPython/Compiler/Ast/ScopeStatement.cs
+++ b/Src/IronPython/Compiler/Ast/ScopeStatement.cs
@@ -92,7 +92,7 @@ public abstract class ScopeStatement : Statement {
///
/// It is used to ensure that the first argument is accessible through a closure cell.
///
- internal bool ContainsSuperCall{ get; set; }
+ internal bool ContainsSuperCall { get; set; }
public virtual string Name => "";
@@ -116,7 +116,7 @@ public abstract class ScopeStatement : Statement {
internal bool NeedsLocalContext
=> NeedsLocalsDictionary || ContainsNestedFreeVariables || ContainsSuperCall;
- internal virtual string[] ParameterNames => ArrayUtils.EmptyStrings;
+ internal virtual string[] ParameterNames => [];
internal virtual int ArgCount => 0;
@@ -439,7 +439,7 @@ private PythonVariable CreateNonlocalVariable(string name) {
}
internal void EnsureNonlocalVariable(string name, NonlocalStatement node) {
- _nonlocalVars ??= new();
+ _nonlocalVars ??= new();
if (!_nonlocalVars.ContainsKey(name)) {
CreateNonlocalVariable(name);
_nonlocalVars[name] = node;
@@ -611,7 +611,7 @@ internal MSAst.Expression? FuncCodeExpr {
internal MSAst.MethodCallExpression CreateLocalContext(MSAst.Expression parentContext, bool newNamespace = true) {
var closureVariables = _closureVariables ?? Array.Empty();
-
+
int numFreeVars = FreeVariables?.Count ?? 0;
int firstArgIdx = -1;
if ((NeedsLocalsDictionary || ContainsSuperCall) && ArgCount > 0) {
diff --git a/Src/IronPython/Compiler/Parser.cs b/Src/IronPython/Compiler/Parser.cs
index ddbf3b02e..9161912bd 100644
--- a/Src/IronPython/Compiler/Parser.cs
+++ b/Src/IronPython/Compiler/Parser.cs
@@ -804,7 +804,7 @@ private ModuleName ParseRelativeModuleName() {
dotCount++;
}
- string[] names = ArrayUtils.EmptyStrings;
+ string[] names = [];
if (PeekToken() is NameToken) {
names = ReadNames();
}
diff --git a/Src/IronPython/Runtime/Binding/WarningInfo.cs b/Src/IronPython/Runtime/Binding/WarningInfo.cs
index 616ecd3af..b00e665c4 100644
--- a/Src/IronPython/Runtime/Binding/WarningInfo.cs
+++ b/Src/IronPython/Runtime/Binding/WarningInfo.cs
@@ -2,12 +2,12 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
+using System;
using System.Dynamic;
using System.Linq.Expressions;
using IronPython.Runtime.Operations;
using IronPython.Runtime.Types;
-using Microsoft.Scripting.Utils;
using AstUtils = Microsoft.Scripting.Ast.Utils;
@@ -29,7 +29,7 @@ public WarningInfo(PythonType/*!*/ type, string/*!*/ message, Expression conditi
codeContext,
AstUtils.Constant(_type),
AstUtils.Constant(_message),
- AstUtils.Constant(ArrayUtils.EmptyObjects)
+ AstUtils.Constant(Array.Empty