Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OHI tests for ref readonly #17547

Merged
merged 7 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@
<data name="IDS_SK_EXTERNALIAS" xml:space="preserve">
<value>extern alias</value>
</data>
<data name="IDS_SK_CONSTRUCTOR" xml:space="preserve">
<value>constructor</value>
</data>
<data name="IDS_FOREACHLOCAL" xml:space="preserve">
<value>foreach iteration variable</value>
</data>
Expand Down Expand Up @@ -1817,8 +1820,8 @@ If such a class is used as a base class and if the deriving class defines a dest
<data name="ERR_OutAttrOnRefParam" xml:space="preserve">
<value>Cannot specify only Out attribute on a ref parameter. Use both In and Out attributes, or neither.</value>
</data>
<data name="ERR_OverloadRefOut" xml:space="preserve">
<value>'{0}' cannot define overloaded methods that differ only on ref and out</value>
<data name="ERR_OverloadRefKind" xml:space="preserve">
<value>'{0}' cannot define an overloaded {1} that differs only on parameter modifiers '{2}' and '{3}'</value>
</data>
<data name="ERR_LiteralDoubleCast" xml:space="preserve">
<value>Literal of type double cannot be implicitly converted to type '{1}'; use an '{0}' suffix to create a literal of this type</value>
Expand Down Expand Up @@ -3731,9 +3734,6 @@ You should consider suppressing the warning only if you're sure that you don't w
<data name="WRN_IsDynamicIsConfusing_Title" xml:space="preserve">
<value>Using 'is' to test compatibility with 'dynamic' is essentially identical to testing compatibility with 'Object'</value>
</data>
<data name="ERR_OverloadRefOutCtor" xml:space="preserve">
<value>Cannot define overloaded constructor '{0}' because it differs from another constructor only on ref and out</value>
</data>
<data name="ERR_YieldNotAllowedInScript" xml:space="preserve">
<value>Cannot use 'yield' in top-level script code</value>
</data>
Expand Down Expand Up @@ -4730,7 +4730,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>Properties which return by reference cannot have set accessors</value>
</data>
<data name="ERR_CantChangeRefReturnOnOverride" xml:space="preserve">
<value>'{0}' must {2}return by reference to match overridden member '{1}'</value>
<value>'{0}' must match by reference return of overridden member '{1}'</value>
</data>
<data name="ERR_MustNotHaveRefReturn" xml:space="preserve">
<value>By-reference returns may only be used in methods that return by reference</value>
Expand All @@ -4742,7 +4742,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>The return expression must be of type '{0}' because this method returns by reference</value>
</data>
<data name="ERR_CloseUnimplementedInterfaceMemberWrongRefReturn" xml:space="preserve">
<value>'{0}' does not implement interface member '{1}'. '{2}' cannot implement '{1}' because it does not return by {3}</value>
<value>'{0}' does not implement interface member '{1}'. '{2}' cannot implement '{1}' because it does not have matching return by reference.</value>
</data>
<data name="ERR_BadIteratorReturnRef" xml:space="preserve">
<value>The body of '{0}' cannot be an iterator block because '{0}' returns by reference</value>
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ internal enum ErrorCode
WRN_EqualityOpWithoutEquals = 660,
WRN_EqualityOpWithoutGetHashCode = 661,
ERR_OutAttrOnRefParam = 662,
ERR_OverloadRefOut = 663,
ERR_OverloadRefKind = 663,
ERR_LiteralDoubleCast = 664,
WRN_IncorrectBooleanAssg = 665,
ERR_ProtectedInStruct = 666,
Expand Down Expand Up @@ -584,7 +584,7 @@ internal enum ErrorCode
ERR_ExpressionTreeContainsBadCoalesce = 845,
ERR_ArrayInitializerExpected = 846,
ERR_ArrayInitializerIncorrectLength = 847,
ERR_OverloadRefOutCtor = 851,
// ERR_OverloadRefOutCtor = 851, Replaced By ERR_OverloadRefKind
ERR_ExpressionTreeContainsNamedArgument = 853,
ERR_ExpressionTreeContainsOptionalArgument = 854,
ERR_ExpressionTreeContainsIndexedProperty = 855,
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/CSharp/Portable/Errors/MessageID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal enum MessageID
{
None = 0,
MessageBase = 1200,

IDS_SK_METHOD = MessageBase + 2000,
IDS_SK_TYPE = MessageBase + 2001,
IDS_SK_NAMESPACE = MessageBase + 2002,
Expand All @@ -23,6 +24,8 @@ internal enum MessageID
IDS_SK_ALIAS = MessageBase + 2010,
//IDS_SK_EXTERNALIAS = MessageBase + 2011,
IDS_SK_LABEL = MessageBase + 2012,
IDS_SK_CONSTRUCTOR = MessageBase + 2013,

IDS_NULL = MessageBase + 10001,
//IDS_RELATEDERROR = MessageBase + 10002,
//IDS_RELATEDWARNING = MessageBase + 10003,
Expand Down Expand Up @@ -129,7 +132,6 @@ internal enum MessageID
IDS_ThrowExpression = MessageBase + 12717,

IDS_FeatureReadonlyReferences = MessageBase + 12718,

}

// Message IDs may refer to strings that need to be localized.
Expand Down
51 changes: 26 additions & 25 deletions src/Compilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerExplicitlyImplementedInterfaces: false,
considerReturnType: true,
considerTypeConstraints: false,
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCallingConvention: true,
considerCustomModifiers: false);

Expand All @@ -64,7 +64,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false, // constraints are checked by caller instead
considerCallingConvention: true,
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: false);

/// <summary>
Expand All @@ -78,7 +78,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: false,
considerTypeConstraints: false,
considerCallingConvention: false,
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: false); //shouldn't actually matter for source members

/// <summary>
Expand All @@ -95,7 +95,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: false,
considerTypeConstraints: false,
considerCallingConvention: false,
considerRefOutDifference: false,
considerRefKindDifferences: false,
considerCustomModifiers: false); //shouldn't actually matter for source members

/// <summary>
Expand All @@ -107,7 +107,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: false,
considerTypeConstraints: false,
considerCallingConvention: false, //ignore static-ness
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: false);

/// <summary>
Expand All @@ -120,7 +120,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false,
considerCallingConvention: false, //ignore static-ness
considerRefOutDifference: false,
considerRefKindDifferences: false,
considerCustomModifiers: false,
ignoreDynamic: true,
ignoreTupleNames: false);
Expand All @@ -135,7 +135,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false,
considerCallingConvention: false, //ignore static-ness
considerRefOutDifference: false,
considerRefKindDifferences: false,
considerCustomModifiers: false,
ignoreDynamic: true,
ignoreTupleNames: true);
Expand All @@ -151,7 +151,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false,
considerCallingConvention: false, //ignore static-ness
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: false);

/// <summary>
Expand All @@ -165,7 +165,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false,
considerCallingConvention: false, //ignore static-ness
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: true);

/// <summary>
Expand All @@ -178,7 +178,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: false,
considerTypeConstraints: false,
considerCallingConvention: false, //ignore static-ness
considerRefOutDifference: false,
considerRefKindDifferences: false,
considerCustomModifiers: false);

/// <summary>
Expand All @@ -193,7 +193,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false,
considerCallingConvention: true,
considerRefOutDifference: false,
considerRefKindDifferences: false,
considerCustomModifiers: true);

/// <summary>
Expand All @@ -207,7 +207,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false,
considerCallingConvention: true,
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: true);

/// <summary>
Expand All @@ -220,7 +220,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false, // constraints are checked by caller instead
considerCallingConvention: true,
considerRefOutDifference: false,
considerRefKindDifferences: false,
considerCustomModifiers: true);

// NOTE: Not used anywhere. Do we still need to keep it?
Expand All @@ -234,7 +234,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: true,
considerCallingConvention: true,
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: false); //intended for source types

/// <summary>
Expand All @@ -246,7 +246,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: true,
considerTypeConstraints: false,
considerCallingConvention: true,
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: true); //if it was a true explicit impl, we expect it to remain so after retargeting

/// <summary>
Expand All @@ -259,7 +259,7 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
considerReturnType: false,
considerTypeConstraints: false,
considerCallingConvention: false, //ignore static-ness
considerRefOutDifference: true,
considerRefKindDifferences: true,
considerCustomModifiers: false);

// Compare the "unqualified" part of the member name (no explicit part)
Expand All @@ -277,8 +277,8 @@ internal class MemberSignatureComparer : IEqualityComparer<Symbol>
// Compare the full calling conventions. Still compares varargs if false.
private readonly bool _considerCallingConvention;

// True to consider RefKind.Ref and RefKind.Out different, false to consider them the same.
private readonly bool _considerRefOutDifference;
// True to consider RefKind differences, false to consider them the same.
private readonly bool _considerRefKindDifferences;

// Consider custom modifiers on/in parameters and return types (if return is considered).
private readonly bool _considerCustomModifiers;
Expand All @@ -295,7 +295,7 @@ private MemberSignatureComparer(
bool considerReturnType,
bool considerTypeConstraints,
bool considerCallingConvention,
bool considerRefOutDifference,
bool considerRefKindDifferences,
bool considerCustomModifiers,
bool ignoreDynamic = true,
bool ignoreTupleNames = true)
Expand All @@ -307,7 +307,7 @@ private MemberSignatureComparer(
_considerReturnType = considerReturnType;
_considerTypeConstraints = considerTypeConstraints;
_considerCallingConvention = considerCallingConvention;
_considerRefOutDifference = considerRefOutDifference;
_considerRefKindDifferences = considerRefKindDifferences;
_considerCustomModifiers = considerCustomModifiers;
_ignoreDynamic = ignoreDynamic;
_ignoreTupleNames = ignoreTupleNames;
Expand Down Expand Up @@ -355,13 +355,14 @@ public bool Equals(Symbol member1, Symbol member2)
var typeMap1 = GetTypeMap(member1);
var typeMap2 = GetTypeMap(member2);

if (_considerReturnType && !HaveSameReturnTypes(member1, typeMap1, member2, typeMap2, _considerCustomModifiers, _ignoreDynamic, _ignoreTupleNames))
if (_considerReturnType && !HaveSameReturnTypes(member1, typeMap1, member2, typeMap2,
_considerCustomModifiers, _ignoreDynamic, _ignoreTupleNames))
{
return false;
}

if (member1.GetParameterCount() > 0 && !HaveSameParameterTypes(member1.GetParameters(), typeMap1, member2.GetParameters(), typeMap2,
_considerRefOutDifference, _considerCustomModifiers, _ignoreDynamic, _ignoreTupleNames))
_considerRefKindDifferences, _considerCustomModifiers, _ignoreDynamic, _ignoreTupleNames))
{
return false;
}
Expand Down Expand Up @@ -482,7 +483,7 @@ private static bool HaveSameReturnTypes(Symbol member1, TypeMap typeMap1, Symbol
member2.GetTypeOrReturnType(out refKind2, out unsubstitutedReturnType2, out returnTypeCustomModifiers2, out refCustomModifiers2);

// short-circuit type map building in the easiest cases
if ((refKind1 != RefKind.None) != (refKind2 != RefKind.None))
if (refKind1 != refKind2)
{
return false;
}
Expand Down Expand Up @@ -627,7 +628,7 @@ private static void SubstituteConstraintTypes(ImmutableArray<TypeSymbol> types,
}

private static bool HaveSameParameterTypes(ImmutableArray<ParameterSymbol> params1, TypeMap typeMap1, ImmutableArray<ParameterSymbol> params2, TypeMap typeMap2,
bool considerRefOutDifference, bool considerCustomModifiers, bool ignoreDynamic, bool ignoreTupleNames)
bool considerRefKindDifferences, bool considerCustomModifiers, bool ignoreDynamic, bool ignoreTupleNames)
{
Debug.Assert(params1.Length == params2.Length);

Expand Down Expand Up @@ -659,7 +660,7 @@ private static bool HaveSameParameterTypes(ImmutableArray<ParameterSymbol> param
var refKind2 = param2.RefKind;

// Metadata signatures don't distinguish ref/out, but C# does - even when comparing metadata method signatures.
if (considerRefOutDifference)
if (considerRefKindDifferences)
{
if (refKind1 != refKind2)
{
Expand Down
Loading