From c9a10638495714bc160bc9860521a637b78e33c2 Mon Sep 17 00:00:00 2001 From: vladres Date: Thu, 28 Aug 2014 17:14:52 -0700 Subject: [PATCH] * Fix 879811: Do not suppress ambiguity errors if they are caused be the same nested type imported through several using static directives with different type arguments. * Fix typos in comments, corrupted characters due to incorrect source encoding, remove unnecessary casts, namespace qualifiers, type arguments and using directives. (changeset 1326357) --- .../Portable/Binder/Binder_Attributes.cs | 4 +- .../Portable/Binder/Binder_Expressions.cs | 18 ++-- .../CSharp/Portable/Binder/Binder_Lookup.cs | 2 +- .../CSharp/Portable/Binder/Binder_Symbols.cs | 33 +++++-- .../CSharp/Portable/Binder/Imports.cs | 2 +- .../Portable/Binder/InContainerBinder.cs | 1 - .../CSharp/Portable/Errors/CSDiagnostic.cs | 3 +- .../Errors/DiagnosticBagExtensions.cs | 4 - .../CSharp/Portable/Errors/ErrorCode.cs | 2 +- .../LocalRewriter_AssignmentOperator.cs | 2 - .../LocalRewriter/LocalRewriter_Call.cs | 2 +- .../LocalRewriter_ObjectCreationExpression.cs | 2 - ...ObjectOrCollectionInitializerExpression.cs | 2 - .../Portable/Symbols/NamedTypeSymbol.cs | 27 +++--- .../Source/SourceMemberMethodSymbol.cs | 18 ++-- .../AttributeTests_CallerInfoAttributes.cs | 2 +- .../CSharp/Test/Emit/Emit/EmitErrorTests.cs | 2 +- .../Semantic/Semantics/NameCollisionTests.cs | 95 ++++++++++++++++++- .../Symbol/Symbols/IndexedPropertyTests.cs | 3 - .../Symbol/Symbols/Source/PropertyTests.cs | 2 +- .../Binding/Binder_Expressions_Tests.vb | 2 +- 21 files changed, 156 insertions(+), 72 deletions(-) diff --git a/Src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs b/Src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs index 5e2e0bcc2c1..1914fe2923f 100644 --- a/Src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs +++ b/Src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; @@ -922,7 +922,7 @@ public ImmutableArray VisitArguments(ImmutableArray GetCandidatesPassingFinalValidation(CSharpS // ... // * If the type parameters of F were substituted in the step above, their constraints are satisfied. // * If F is a static method, the method group must have resulted from a simple-name, a member-access through a type, - // or a member-access whose receiver can�t be classified as a type or value until after overload resolution (see �7.6.4.1). + // or a member-access whose receiver can't be classified as a type or value until after overload resolution (see §7.6.4.1). // * If F is an instance method, the method group must have resulted from a simple-name, a member-access through a variable or value, - // or a member-access whose receiver can�t be classified as a type or value until after overload resolution (see �7.6.4.1). + // or a member-access whose receiver can't be classified as a type or value until after overload resolution (see §7.6.4.1). if (!MemberGroupFinalValidationAccessibilityChecks(methodGroup.ReceiverOpt, result.Member, syntax, candidateDiagnostics, invokedAsExtensionMethod: false) && (methodGroup.TypeArgumentsOpt.IsDefault || result.Member.CheckConstraints(this.Conversions, syntax, this.Compilation, candidateDiagnostics))) @@ -3452,8 +3452,8 @@ private void BindArrayInitializerExpressions(InitializerExpressionSyntax initial boundExpression = BadExpression( expression, LookupResultKind.Empty, - ImmutableArray.Create(boundExpression.ExpressionSymbol), - ImmutableArray.Create(boundExpression)); + ImmutableArray.Create(boundExpression.ExpressionSymbol), + ImmutableArray.Create(boundExpression)); } exprBuilder.Add(boundExpression); @@ -4470,7 +4470,7 @@ private BoundExpression BindClassCreationExpression(ObjectCreationExpressionSynt // SPEC: an expression or an object initializer or collection initializer. // SPEC: A member initializer that specifies an expression after the equals sign is processed in the same way as an assignment (7.17.1) to the field or property. - // SPEC VIOLATION: Native compiler also allows initialization of fieldlike events in object initializers, so we allow it as well. + // SPEC VIOLATION: Native compiler also allows initialization of field-like events in object initializers, so we allow it as well. boundMember = BindInstanceMemberAccess( node: memberName, @@ -6108,7 +6108,7 @@ private BoundExpression MakeMemberAccessValue(BoundExpression expr, DiagnosticBa private void BindMemberAccessReportError(BoundMethodGroup node, DiagnosticBag diagnostics) { var nameSyntax = node.NameSyntax; - var syntax = node.MemberAccessExpressionSyntax ?? (CSharpSyntaxNode)nameSyntax; + var syntax = node.MemberAccessExpressionSyntax ?? nameSyntax; this.BindMemberAccessReportError(syntax, nameSyntax, node.Name, node.ReceiverOpt, node.LookupError, diagnostics); } @@ -6193,7 +6193,7 @@ private bool IsWinRTAsyncInterface(TypeSymbol type) private BoundExpression BindMemberAccessBadResult(BoundMethodGroup node) { var nameSyntax = node.NameSyntax; - var syntax = node.MemberAccessExpressionSyntax ?? (CSharpSyntaxNode)nameSyntax; + var syntax = node.MemberAccessExpressionSyntax ?? nameSyntax; return this.BindMemberAccessBadResult(syntax, node.Name, node.ReceiverOpt, node.LookupError, StaticCast.From(node.Methods), node.ResultKind); } @@ -6240,7 +6240,7 @@ private BoundExpression BindMemberAccessBadResult(BoundMethodGroup node) return new BoundBadExpression( node, lookupKind, - (object)symbolOpt == null ? ImmutableArray.Empty : ImmutableArray.Create(symbolOpt), + (object)symbolOpt == null ? ImmutableArray.Empty : ImmutableArray.Create(symbolOpt), boundLeft == null ? ImmutableArray.Empty : ImmutableArray.Create(boundLeft), GetNonMethodMemberType(symbolOpt)); } diff --git a/Src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs b/Src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs index 9428031bf0b..ba066d9a488 100644 --- a/Src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs +++ b/Src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs @@ -702,7 +702,7 @@ internal virtual bool SupportsExtensionMethods currentType = currentType.GetNextBaseTypeNoUseSiteDiagnostics(basesBeingResolved, this.Compilation, ref visited); if ((object)currentType != null) { - ((TypeSymbol)currentType.OriginalDefinition).AddUseSiteDiagnostics(ref useSiteDiagnostics); + currentType.OriginalDefinition.AddUseSiteDiagnostics(ref useSiteDiagnostics); } } diff --git a/Src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs b/Src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs index ff969d45954..6c76126cae0 100644 --- a/Src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs +++ b/Src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs @@ -1269,18 +1269,31 @@ public int Compare(Symbol fst, Symbol snd) if (first.Kind == SymbolKind.NamedType && second.Kind == SymbolKind.NamedType) { - // ErrorCode.ERR_SameFullNameAggAgg: The type '{1}' exists in both '{0}' and '{2}' - info = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameAggAgg, originalSymbols, - new object[] { first.ContainingAssembly, first, second.ContainingAssembly }); + if (first.OriginalDefinition == second.OriginalDefinition) + { + // We imported different generic instantiations of the same generic type + // and have an ambiguous reference to a type nested in it + reportError = true; - // Do not report this error if the first is declared in source and the second is declared in added module, - // we already reported declaration error about this name collision. - // Do not report this error if both are declared in added modules, - // we will report assembly level declaration error about this name collision. - if (secondBest.IsFromAddedModule) + // '{0}' is an ambiguous reference between '{1}' and '{2}' + info = new CSDiagnosticInfo(ErrorCode.ERR_AmbigContext, originalSymbols, + new object[] { where, first, second }); + } + else { - Debug.Assert(best.IsFromCompilation); - reportError = false; + // ErrorCode.ERR_SameFullNameAggAgg: The type '{1}' exists in both '{0}' and '{2}' + info = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameAggAgg, originalSymbols, + new object[] { first.ContainingAssembly, first, second.ContainingAssembly }); + + // Do not report this error if the first is declared in source and the second is declared in added module, + // we already reported declaration error about this name collision. + // Do not report this error if both are declared in added modules, + // we will report assembly level declaration error about this name collision. + if (secondBest.IsFromAddedModule) + { + Debug.Assert(best.IsFromCompilation); + reportError = false; + } } } else if (first.Kind == SymbolKind.Namespace && second.Kind == SymbolKind.NamedType) diff --git a/Src/Compilers/CSharp/Portable/Binder/Imports.cs b/Src/Compilers/CSharp/Portable/Binder/Imports.cs index 852fca5dcce..2e77908c693 100644 --- a/Src/Compilers/CSharp/Portable/Binder/Imports.cs +++ b/Src/Compilers/CSharp/Portable/Binder/Imports.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Collections.Immutable; diff --git a/Src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs b/Src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs index 4137faa0560..27d6e72e35d 100644 --- a/Src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs +++ b/Src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading; diff --git a/Src/Compilers/CSharp/Portable/Errors/CSDiagnostic.cs b/Src/Compilers/CSharp/Portable/Errors/CSDiagnostic.cs index 1980c88d18a..f3a980826d8 100644 --- a/Src/Compilers/CSharp/Portable/Errors/CSDiagnostic.cs +++ b/Src/Compilers/CSharp/Portable/Errors/CSDiagnostic.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Runtime.Serialization; namespace Microsoft.CodeAnalysis.CSharp { diff --git a/Src/Compilers/CSharp/Portable/Errors/DiagnosticBagExtensions.cs b/Src/Compilers/CSharp/Portable/Errors/DiagnosticBagExtensions.cs index a3e658feba7..77400df6e00 100644 --- a/Src/Compilers/CSharp/Portable/Errors/DiagnosticBagExtensions.cs +++ b/Src/Compilers/CSharp/Portable/Errors/DiagnosticBagExtensions.cs @@ -2,10 +2,6 @@ using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis.CSharp.Symbols; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.CSharp { diff --git a/Src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/Src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index cca68544fd5..b0ba0b37803 100644 --- a/Src/Compilers/CSharp/Portable/Errors/ErrorCode.cs +++ b/Src/Compilers/CSharp/Portable/Errors/ErrorCode.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.CodeAnalysis.CSharp { diff --git a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_AssignmentOperator.cs b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_AssignmentOperator.cs index c121ba9da1c..52d5f1c3a3e 100644 --- a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_AssignmentOperator.cs +++ b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_AssignmentOperator.cs @@ -3,8 +3,6 @@ using System.Collections.Immutable; using System.Diagnostics; using Microsoft.CodeAnalysis.CSharp.Symbols; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp diff --git a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs index f8827dcaebd..be6776d4feb 100644 --- a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs +++ b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Immutable; using System.Diagnostics; diff --git a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs index df3522e870c..b63d4120a22 100644 --- a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs +++ b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs @@ -3,8 +3,6 @@ using System.Collections.Immutable; using System.Diagnostics; using Microsoft.CodeAnalysis.CSharp.Symbols; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp diff --git a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectOrCollectionInitializerExpression.cs b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectOrCollectionInitializerExpression.cs index 2efe0b5bd4e..09a017f39e5 100644 --- a/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectOrCollectionInitializerExpression.cs +++ b/Src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectOrCollectionInitializerExpression.cs @@ -4,8 +4,6 @@ using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; using System.Collections.Generic; diff --git a/Src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs b/Src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs index 20116889d5c..59495f90e39 100644 --- a/Src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs +++ b/Src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs @@ -67,7 +67,7 @@ internal ImmutableArray TypeArgumentsWithDefinitionUseSiteDiagnostic foreach (var typeArgument in result) { - ((TypeSymbol)typeArgument.OriginalDefinition).AddUseSiteDiagnostics(ref useSiteDiagnostics); + typeArgument.OriginalDefinition.AddUseSiteDiagnostics(ref useSiteDiagnostics); } return result; @@ -76,7 +76,7 @@ internal ImmutableArray TypeArgumentsWithDefinitionUseSiteDiagnostic internal TypeSymbol TypeArgumentWithDefinitionUseSiteDiagnostics(int index, ref HashSet useSiteDiagnostics) { var result = TypeArgumentsNoUseSiteDiagnostics[index]; - ((TypeSymbol)result.OriginalDefinition).AddUseSiteDiagnostics(ref useSiteDiagnostics); + result.OriginalDefinition.AddUseSiteDiagnostics(ref useSiteDiagnostics); return result; } @@ -134,7 +134,7 @@ internal bool KnownToHaveNoDeclaredBaseCycles internal void SetKnownToHaveNoDeclaredBaseCycles() { - if (!this.hasNoBaseCycles) this.hasNoBaseCycles = true; + this.hasNoBaseCycles = true; } /// @@ -569,7 +569,7 @@ public override int GetHashCode() // ignores custom modifiers. if (this.SpecialType == Microsoft.CodeAnalysis.SpecialType.System_Object) { - return (int)Microsoft.CodeAnalysis.SpecialType.System_Object; + return (int)SpecialType.System_Object; } // OriginalDefinition must be object-equivalent. @@ -587,7 +587,7 @@ internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiers = false, // if ignoring dynamic, then treat dynamic the same as the type 'object' if (ignoreDynamic && t2.TypeKind == TypeKind.DynamicType && - this.SpecialType == Microsoft.CodeAnalysis.SpecialType.System_Object) + this.SpecialType == SpecialType.System_Object) { return true; } @@ -601,8 +601,8 @@ internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiers = false, // CONSIDER: original definitions are not unique for missing metadata type // symbols. Therefore this code may not behave correctly if 'this' is List - // where List'1 is a missing metadata type symbol, and other is similarly List - // but for a reference-distinct List'1. + // where List`1 is a missing metadata type symbol, and other is similarly List + // but for a reference-distinct List`1. if (((object)this == (object)thisOriginalDefinition) || ((object)other == (object)otherOriginalDefinition) || (thisOriginalDefinition != otherOriginalDefinition)) @@ -660,7 +660,6 @@ private bool EqualsComplicatedCases(NamedTypeSymbol other, bool ignoreCustomModi /// /// The immediate type arguments to be replaced for type /// parameters in the type. - /// public NamedTypeSymbol Construct(params TypeSymbol[] typeArguments) { return Construct(typeArguments.AsImmutableOrNull(), false); @@ -671,7 +670,6 @@ public NamedTypeSymbol Construct(params TypeSymbol[] typeArguments) /// /// The immediate type arguments to be replaced for type /// parameters in the type. - /// public NamedTypeSymbol Construct(ImmutableArray typeArguments) { return Construct(typeArguments, false); @@ -681,7 +679,6 @@ public NamedTypeSymbol Construct(ImmutableArray typeArguments) /// Returns a constructed type given its type arguments. /// /// - /// public NamedTypeSymbol Construct(IEnumerable typeArguments) { return Construct(typeArguments.AsImmutableOrNull(), false); @@ -711,7 +708,7 @@ internal NamedTypeSymbol Construct(ImmutableArray arguments, bool un throw new ArgumentNullException("typeArguments"); } - if (arguments.Any(NamedTypeSymbol.TypeSymbolIsNullFunction)) + if (arguments.Any(TypeSymbolIsNullFunction)) { throw new ArgumentException(CSharpResources.TypeArgumentCannotBeNull, "typeArguments"); } @@ -721,7 +718,7 @@ internal NamedTypeSymbol Construct(ImmutableArray arguments, bool un throw new ArgumentException(CSharpResources.WrongNumberOfTypeArguments, "typeArguments"); } - Debug.Assert(!unbound || arguments.All(NamedTypeSymbol.TypeSymbolIsErrorType)); + Debug.Assert(!unbound || arguments.All(TypeSymbolIsErrorType)); if (ConstructedNamedTypeSymbol.TypeParametersMatchTypeArguments(this.TypeParameters, arguments)) { @@ -1036,15 +1033,15 @@ protected CharSet DefaultMarshallingCharSet /// /// Declaration security information associated with this type, or null if there is none. /// - internal abstract IEnumerable GetSecurityInformation(); + internal abstract IEnumerable GetSecurityInformation(); /// - /// Returns a sequence of preprocessor symbols specified in applied on this symbol, or null if there are none. + /// Returns a sequence of preprocessor symbols specified in applied on this symbol, or null if there are none. /// internal abstract ImmutableArray GetAppliedConditionalSymbols(); /// - /// If CoClassAttribute was applied to the type and the attribute argument is a valid named type argument, i.e. accessible class type, then it returns the type symbol for the argument. + /// If was applied to the type and the attribute argument is a valid named type argument, i.e. accessible class type, then it returns the type symbol for the argument. /// Otherwise, returns null. /// /// diff --git a/Src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs b/Src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs index 7e659389a19..873b96473b8 100644 --- a/Src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs +++ b/Src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs @@ -7,11 +7,7 @@ using System.Threading; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.CSharp.Emit; -using System; namespace Microsoft.CodeAnalysis.CSharp.Symbols { @@ -880,13 +876,13 @@ private void CheckModifiers(Location location, DiagnosticBag diagnostics) diagnostics.Add(ErrorCode.ERR_PartialMethodMustReturnVoid, location); } else if (IsPartial && !ContainingType.IsInterface && 0 != (DeclarationModifiers & - (CSharp.DeclarationModifiers.AccessibilityMask & ~CSharp.DeclarationModifiers.Private | - CSharp.DeclarationModifiers.Virtual | - CSharp.DeclarationModifiers.Abstract | - CSharp.DeclarationModifiers.Override | - CSharp.DeclarationModifiers.New | - CSharp.DeclarationModifiers.Sealed | - CSharp.DeclarationModifiers.Extern))) + (DeclarationModifiers.AccessibilityMask & ~DeclarationModifiers.Private | + DeclarationModifiers.Virtual | + DeclarationModifiers.Abstract | + DeclarationModifiers.Override | + DeclarationModifiers.New | + DeclarationModifiers.Sealed | + DeclarationModifiers.Extern))) { diagnostics.Add(ErrorCode.ERR_PartialMethodInvalidModifier, location); } diff --git a/Src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs b/Src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs index 5599f85aaa9..e055c3ca977 100644 --- a/Src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs +++ b/Src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Immutable; using System.Text; diff --git a/Src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs b/Src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs index c2df18db374..08eb9b94076 100644 --- a/Src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs +++ b/Src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs @@ -123,7 +123,7 @@ public class A var compilation1 = CreateCompilationWithMscorlib(source1); compilation1.VerifyDiagnostics( // (4,22): error CS0110: The evaluation of the constant value for 'A.x' involves a circular definition - Diagnostic(CSharp.ErrorCode.ERR_CircConstValue, "x").WithArguments("A.x")); + Diagnostic(ErrorCode.ERR_CircConstValue, "x").WithArguments("A.x")); string source2 = @" public class B diff --git a/Src/Compilers/CSharp/Test/Semantic/Semantics/NameCollisionTests.cs b/Src/Compilers/CSharp/Test/Semantic/Semantics/NameCollisionTests.cs index 38e8a1dedd8..a9ee44c38d9 100644 --- a/Src/Compilers/CSharp/Test/Semantic/Semantics/NameCollisionTests.cs +++ b/Src/Compilers/CSharp/Test/Semantic/Semantics/NameCollisionTests.cs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; @@ -1867,5 +1866,99 @@ static void Main() Diagnostic(ErrorCode.ERR_NonInvocableMemberCalled, "Assembly").WithArguments("System.Reflection.Assembly").WithLocation(9, 41) ); } + + [Fact] + [WorkItem(879811, "DevDiv")] + public void Bug879811_1() + { + const string source = @" +using Static; +using Static; + +public static class Static +{ + public class Nested + { + public void M() { } + } +} + +class D +{ + static void Main(string[] args) + { + var c = new Nested(); + c.M(); + } +}"; + CreateCompilationWithMscorlib(source).VerifyDiagnostics( + // (17,21): error CS0104: 'Nested' is an ambiguous reference between 'Static.Nested' and 'Static.Nested' + // var c = new Nested(); + Diagnostic(ErrorCode.ERR_AmbigContext, "Nested").WithArguments("Nested", "Static.Nested", "Static.Nested").WithLocation(17, 21)); + } + + [Fact] + [WorkItem(879811, "DevDiv")] + public void Bug879811_2() + { + const string source = @" +using Static; +using Static; + +public static class Static +{ + public class Nested + { + public void M() { } + } +} + +class D +{ + static void Main() + { + var c = new Nested(); + } +}"; + CreateCompilationWithMscorlib(source).VerifyDiagnostics( + // (3,7): warning CS0105: The using directive for 'Static' appeared previously in this namespace + // using Static; + Diagnostic(ErrorCode.WRN_DuplicateUsing, "Static").WithArguments("Static").WithLocation(3, 7), + // (3,1): hidden CS8019: Unnecessary using directive. + // using Static; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using Static;").WithLocation(3, 1)); + } + + [Fact] + [WorkItem(879811, "DevDiv")] + public void Bug879811_3() + { + const string source = @" +using Static; + +public static class Static +{ + public class Nested + { + public void M() { } + } +} + +namespace N +{ + using Static; + class D + { + static void Main() + { + Static.Nested c = new Nested(); + } + } +}"; + CreateCompilationWithMscorlib(source).VerifyDiagnostics( + // (2,1): hidden CS8019: Unnecessary using directive. + // using Static; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using Static;").WithLocation(2, 1)); + } } } diff --git a/Src/Compilers/CSharp/Test/Symbol/Symbols/IndexedPropertyTests.cs b/Src/Compilers/CSharp/Test/Symbol/Symbols/IndexedPropertyTests.cs index 2d0178b740c..90db46ae5a0 100644 --- a/Src/Compilers/CSharp/Test/Symbol/Symbols/IndexedPropertyTests.cs +++ b/Src/Compilers/CSharp/Test/Symbol/Symbols/IndexedPropertyTests.cs @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using Microsoft.CodeAnalysis.CSharp.Symbols; -using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities; using Xunit; diff --git a/Src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs b/Src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs index 3cbde2f56a3..33d6cd07a94 100644 --- a/Src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs +++ b/Src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Linq; diff --git a/Src/Compilers/VisualBasic/Test/Semantic/Binding/Binder_Expressions_Tests.vb b/Src/Compilers/VisualBasic/Test/Semantic/Binding/Binder_Expressions_Tests.vb index 41c5042621e..19d9643edd1 100644 --- a/Src/Compilers/VisualBasic/Test/Semantic/Binding/Binder_Expressions_Tests.vb +++ b/Src/Compilers/VisualBasic/Test/Semantic/Binding/Binder_Expressions_Tests.vb @@ -80,7 +80,7 @@ expectedOutput:="123") Public Sub Bug707924a() Dim source = My.Resources.Resource.T_1247520 - Dim result = Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.ParseText(source).ToString() + Dim result = VisualBasicSyntaxTree.ParseText(source).ToString() Assert.Equal(source, result) End Sub -- GitLab