Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Fix #19: OperatorResolveResult.IsLiftedOperator is false for lifted b…
Browse files Browse the repository at this point in the history
…uilt-in operators.
  • Loading branch information
dgrunwald committed Mar 11, 2012
1 parent 3215504 commit a731b93
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,11 @@ public ResolveResult ResolveBinaryOperator(BinaryOperatorType op, ResolveResult
} else {
lhs = Convert(lhs, m.Parameters[0].Type, builtinOperatorOR.ArgumentConversions[0]);
rhs = Convert(rhs, m.Parameters[1].Type, builtinOperatorOR.ArgumentConversions[1]);
if (builtinOperatorOR.BestCandidate is OverloadResolution.ILiftedOperator) {
return new OperatorResolveResult(
resultType, BinaryOperatorExpression.GetLinqNodeType(op, this.CheckForOverflow),
null, true, new[] { lhs, rhs });
}
return BinaryOperatorResolveResult(resultType, lhs, op, rhs);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,5 +671,35 @@ class Test {
Assert.IsFalse(irr.IsError);
Assert.AreEqual(compilation.FindType(KnownTypeCode.Boolean), irr.Type);
}

[Test]
public void IsLiftedProperty()
{
string program = @"
class Test {
static void Inc() {
int? a = 0, b = 0;
int? c = $a + b$;
}
}";
var irr = Resolve<OperatorResolveResult>(program);
Assert.IsFalse(irr.IsError);
Assert.IsTrue(irr.IsLiftedOperator);
}

[Test]
public void IsLiftedProperty2()
{
string program = @"
class Test {
static void Inc() {
int? a = 0, b = 0;
$b += a$;
}
}";
var irr = Resolve<OperatorResolveResult>(program);
Assert.IsFalse(irr.IsError);
Assert.IsTrue(irr.IsLiftedOperator);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="nunit.framework, Version=2.6.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Private>False</Private>
<HintPath>..\..\Mono.Cecil\Test\libs\nunit-2.5.10\nunit.framework.dll</HintPath>
<Private>True</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
Expand Down

0 comments on commit a731b93

Please sign in to comment.