diff options
author | Stephen Toub <stoub@microsoft.com> | 2017-02-07 19:23:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-07 19:23:51 +0300 |
commit | b49bcfbc0856482752d91ba645110cbd67e06eca (patch) | |
tree | 2cc22a0e503e78a709a96696bb133b6a06ed1017 | |
parent | 0d7496a06f4436841a9fbcd44ddf1d09503073d0 (diff) | |
parent | b0578cc9b1ceb571203e6cdd6f2c7ce3d4fda3da (diff) |
Merge pull request #15907 from JonHanna/sle_dont_short_circuit_lifted_binary
Don't short-circuit null-checks in lifted binary ops
-rw-r--r-- | src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Binary.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Binary.cs b/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Binary.cs index 3364b45292..7d4e502dd6 100644 --- a/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Binary.cs +++ b/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Binary.cs @@ -544,20 +544,25 @@ namespace System.Linq.Expressions.Compiler _ilg.Emit(OpCodes.Stloc, locLeft); // test for null - // use short circuiting + // don't use short circuiting if (leftIsNullable) { _ilg.Emit(OpCodes.Ldloca, locLeft); _ilg.EmitHasValue(leftType); - _ilg.Emit(OpCodes.Brfalse_S, labIfNull); } + if (rightIsNullable) { _ilg.Emit(OpCodes.Ldloca, locRight); _ilg.EmitHasValue(rightType); - _ilg.Emit(OpCodes.Brfalse_S, labIfNull); + if (leftIsNullable) + { + _ilg.Emit(OpCodes.And); + } } + _ilg.Emit(OpCodes.Brfalse_S, labIfNull); + // do op on values if (leftIsNullable) { |