Skip to content

Commit b7b57f5

Browse files
author
Maksim Volkau
committed
cleanup #491 and add tests to net472
1 parent 1d97c06 commit b7b57f5

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,11 +2514,10 @@ private static bool TryEmitNew(Expression expr, IReadOnlyList<PE> paramExprs, IL
25142514
else
25152515
return false;
25162516

2517-
closure.LastEmitIsAddress = newType.IsValueType && (parent & ParentFlags.InstanceAccess) != 0 && !parent.IgnoresResult();
2517+
closure.LastEmitIsAddress =
2518+
(parent & ParentFlags.InstanceAccess) != 0 & (parent & ParentFlags.IgnoreResult) == 0 && newType.IsValueType;
25182519
if (closure.LastEmitIsAddress)
2519-
{
25202520
EmitStoreAndLoadLocalVariableAddress(il, newType);
2521-
}
25222521

25232522
if (parent.IgnoresResult())
25242523
il.Demit(OpCodes.Pop);

test/FastExpressionCompiler.TestsRunner.Net472/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ void Run(Func<int> run, string name = null)
133133
Run(new LightExpression.UnitTests.ConvertOperatorsTests().Run);
134134
Run(new DefaultTests().Run);
135135
Run(new LightExpression.UnitTests.DefaultTests().Run);
136+
Run(new ConstructorCallTests().Run);
137+
Run(new LightExpression.UnitTests.ConstructorCallTests().Run);
136138
Run(new EqualityOperatorsTests().Run);
137139
Run(new LightExpression.UnitTests.EqualityOperatorsTests().Run);
138140
Run(new GotoTests().Run);

test/FastExpressionCompiler.UnitTests/ConstructorCallTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public void Constructor_conversions_and_boxing()
6161
).CompileFast(true);
6262
Asserts.AreEqual(42, ((TestStruct)fBox()).A);
6363

64-
var fInterface = Lambda<Func<ITestInterfacce>>(
65-
Convert(New(TestStruct.Ctor, Constant(43), Constant("a")), typeof(ITestInterfacce))
64+
var fInterface = Lambda<Func<ITestInterface>>(
65+
Convert(New(TestStruct.Ctor, Constant(43), Constant("a")), typeof(ITestInterface))
6666
).CompileFast(true);
6767
Asserts.AreEqual(43, fInterface().PropertyA);
6868

@@ -377,9 +377,9 @@ public void Constructor_nested_in_block_member_access()
377377
Asserts.AreEqual(42, fastCompiled());
378378
}
379379

380-
public interface ITestInterfacce { int PropertyA { get; } }
380+
public interface ITestInterface { int PropertyA { get; } }
381381

382-
public struct TestStruct : ITestInterfacce
382+
public struct TestStruct : ITestInterface
383383
{
384384
public static readonly ConstructorInfo Ctor = typeof(TestStruct).GetConstructors()[0];
385385
public int A;
@@ -406,7 +406,7 @@ public TestStruct(int a, string b)
406406
public static implicit operator int(TestStruct s) => s.A;
407407
}
408408

409-
public class TestClass : ITestInterfacce
409+
public class TestClass : ITestInterface
410410
{
411411
public static readonly ConstructorInfo Ctor = typeof(TestClass).GetConstructors()[0];
412412
public int A;

0 commit comments

Comments
 (0)