diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs index 65ae6c2fb3..05d2872c8a 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs @@ -751,6 +751,9 @@ namespace Mono.CSharp { public virtual void Error_OperatorCannotBeApplied (ResolveContext rc, Location loc, string oper, TypeSpec t) { + if (t == InternalType.ErrorType) + return; + rc.Report.Error (23, loc, "The `{0}' operator cannot be applied to operand of type `{1}'", oper, t.GetSignatureForError ()); } @@ -4728,7 +4731,7 @@ namespace Mono.CSharp { } else if (IsDelegateInvoke) { ec.Report.Error (1594, loc, "Delegate `{0}' has some invalid arguments", DelegateType.GetSignatureForError ()); - } else { + } else if (a.Type != InternalType.ErrorType) { ec.Report.SymbolRelatedToPreviousError (method); ec.Report.Error (1502, loc, "The best overloaded method match for `{0}' has some invalid arguments", method.GetSignatureForError ()); @@ -4745,7 +4748,7 @@ namespace Mono.CSharp { else ec.Report.Error (1620, loc, "Argument `#{0}' is missing `{1}' modifier", index, Parameter.GetModifierSignature (mod)); - } else if (a.Expr != ErrorExpression.Instance) { + } else if (a.Type != InternalType.ErrorType) { string p1 = a.GetSignatureForError (); string p2 = TypeManager.CSharpName (paramType); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs index da92cae7fa..4ad2473d69 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs @@ -8422,8 +8422,11 @@ namespace Mono.CSharp return new IndexerExpr (indexers, type, this); } - ec.Report.Error (21, loc, "Cannot apply indexing with [] to an expression of type `{0}'", - type.GetSignatureForError ()); + if (type != InternalType.ErrorType) { + ec.Report.Error (21, loc, "Cannot apply indexing with [] to an expression of type `{0}'", + type.GetSignatureForError ()); + } + return null; } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs index b2a7b4b5dc..3fb1c75631 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs @@ -4579,6 +4579,24 @@ class MainClass Assert.IsNotNull (provider.Find ("Math"), "'Math' not found."); } + [Ignore("Mcs bug")] + [Test()] + public void TestConditionalExpression () + { + CompletionDataList provider = CreateProvider ( +@"using System; + +class MainClass +{ + public static void Main (string[] args) + { + int a; + $a = true ? System.$ + } +} +"); + Assert.IsNotNull (provider.Find ("Math"), "'Math' not found."); + } /// /// Bug 3655 - Autocompletion does not work for the assembly attribute [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MyExternalAssembly")]