提交 4d819cea 编写于 作者: V VSadov

CR feedback and better visualization

上级 7ad395c8
......@@ -648,9 +648,18 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
if (arguments.Count < 2)
{
// this should be a parse error already.
return BadExpression(node);
var args = arguments.Count == 1 ?
new BoundExpression[] { BindValue(arguments[0].Expression, diagnostics, BindValueKind.RValue) } :
new BoundExpression[0];
return BadExpression(node, args);
}
bool hasErrors = false;
// set of names already used
HashSet<string> uniqueFieldNames = new HashSet<string>();
var boundArguments = ArrayBuilder<BoundExpression>.GetInstance(arguments.Count);
var elementTypes = ArrayBuilder<TypeSymbol>.GetInstance(arguments.Count);
ArrayBuilder<string> elementNames = null;
......@@ -658,8 +667,22 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
for (int i = 0, l = arguments.Count; i < l; i++)
{
var argumentSyntax = arguments[i];
var name = argumentSyntax.NameColon?.Name.Identifier.ValueText;
var name = argumentSyntax.NameColon?.Name?.Identifier.ValueText;
// validate name if we have one
if (name != null)
{
// PROTOTYPE: check for a case "ItemX" where X is not i
if (!uniqueFieldNames.Add(name))
{
hasErrors = true;
// PROTOTYPE: need specific duplicate name error for tuples
Error(diagnostics, ErrorCode.ERR_AnonymousTypeDuplicatePropertyName, argumentSyntax.NameColon.Name);
}
}
// add the name to the list
// names would typically all be there or none at all
// but in case we need to handle this in error cases
if (elementNames != null)
......@@ -679,15 +702,18 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
}
}
var boundArgument = BindExpression(argumentSyntax.Expression, diagnostics);
var boundArgument = BindValue(argumentSyntax.Expression, diagnostics, BindValueKind.RValue);
boundArguments.Add(boundArgument);
elementTypes.Add(boundArgument.Type);
// PROTOTYPE: need to report distinc errors for tuples
var elementType = GetAnonymousTypeFieldType(boundArgument, argumentSyntax, diagnostics, ref hasErrors);
elementTypes.Add(elementType);
}
var type = new TupleTypeSymbol(
elementTypes.ToImmutableAndFree(),
elementNames == null ?
ImmutableArray<string>.Empty :
default(ImmutableArray<string>) :
elementNames.ToImmutableAndFree(),
node,
this,
......@@ -696,7 +722,7 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
//PROTOTYPE: should be a wellknown member?
var ctor = type.UnderlyingTupleType?.InstanceConstructors.FirstOrDefault();
return new BoundTupleCreationExpression(node, ctor, boundArguments.ToImmutableAndFree(), type);
return new BoundTupleCreationExpression(node, ctor, boundArguments.ToImmutableAndFree(), type, hasErrors);
}
private BoundExpression BindRefValue(RefValueExpressionSyntax node, DiagnosticBag diagnostics)
......
......@@ -187,10 +187,6 @@ protected void LookupMembersInType(LookupResult result, TypeSymbol type, string
this.LookupMembersInClass(result, type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteDiagnostics);
break;
case TypeKind.Tuple:
useSiteDiagnostics = LookupMembersInTuple(result, type, name, arity, basesBeingResolved, options, originalBinder, diagnose, useSiteDiagnostics);
break;
case TypeKind.Submission:
this.LookupMembersInSubmissions(result, type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteDiagnostics);
break;
......@@ -212,12 +208,6 @@ protected void LookupMembersInType(LookupResult result, TypeSymbol type, string
// done in the caller?
}
private HashSet<DiagnosticInfo> LookupMembersInTuple(LookupResult result, TypeSymbol type, string name, int arity, ConsList<Symbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, HashSet<DiagnosticInfo> useSiteDiagnostics)
{
this.LookupMembersInClass(result, type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteDiagnostics);
return useSiteDiagnostics;
}
private void LookupMembersInErrorType(LookupResult result, ErrorTypeSymbol errorType, string name, int arity, ConsList<Symbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if (!errorType.CandidateSymbols.IsDefault && errorType.CandidateSymbols.Length == 1)
......@@ -728,7 +718,7 @@ internal virtual bool SupportsExtensionMethods
// PROTOTYPE consider taking this out of the loop. tuples are always at the end of hierarchy
// PROTOTYPE match this in other lookups
var tuple = currentType as TupleTypeSymbol;
if (tuple != null)
if ((object)tuple != null)
{
currentType = tuple.UnderlyingTupleType;
continue;
......@@ -1542,6 +1532,8 @@ private void AddMemberLookupSymbolsInfoInType(LookupSymbolsInfo result, TypeSymb
this.AddMemberLookupSymbolsInfoInClass(result, type, options, originalBinder, type);
break;
//PROTOTYPE: add special handling for tuple types - we need to collect both tuple members and from the underlying.
case TypeKind.Submission:
this.AddMemberLookupSymbolsInfoInSubmissions(result, type, options, originalBinder);
break;
......
......@@ -99,9 +99,6 @@ internal static class AccessCheck
case SymbolKind.NamedType:
return IsNamedTypeAccessible((NamedTypeSymbol)symbol, within, ref useSiteDiagnostics, basesBeingResolved);
case SymbolKind.TupleType:
return IsNamedTypeAccessible(((TupleTypeSymbol)symbol).UnderlyingTupleType, within, ref useSiteDiagnostics, basesBeingResolved);
case SymbolKind.ErrorType:
// Always assume that error types are accessible.
return true;
......@@ -224,11 +221,6 @@ private static bool IsNamedTypeAccessible(NamedTypeSymbol type, Symbol within, r
failedThroughTypeCheck = false;
// for tuples consider the underlying type as a true container for visibility puroposes.
containingType =
(containingType as TupleTypeSymbol)?.UnderlyingTupleType ??
containingType;
// easy case - members of containing type are accessible.
if ((object)containingType == (object)within)
{
......
......@@ -1145,6 +1145,7 @@
<Node Name="BoundTupleCreationExpression" Base="BoundExpression">
<!-- Non-null type is required for this node kind -->
<Field Name="Type" Type="TypeSymbol" Override="true" Null="disallow"/>
<!-- The constructor of the underlying tuple type -->
<Field Name="Constructor" Type="MethodSymbol" Null="disallow"/>
<Field Name="Arguments" Type="ImmutableArray&lt;BoundExpression&gt;"/>
</Node>
......
......@@ -768,6 +768,10 @@ protected virtual Cci.IModuleReference TranslateModule(ModuleSymbol module, Diag
{
namedTypeSymbol = AnonymousTypeManager.TranslateAnonymousTypeSymbol(namedTypeSymbol);
}
else if (namedTypeSymbol.IsTupleType)
{
namedTypeSymbol = ((TupleTypeSymbol)namedTypeSymbol).UnderlyingTupleType;
}
// Substitute error types with a special singleton object.
// Unreported bad types can come through NoPia embedding, for example.
......@@ -914,9 +918,6 @@ internal static Cci.IGenericParameterReference Translate(TypeParameterSymbol par
case SymbolKind.TypeParameter:
return Translate((TypeParameterSymbol)typeSymbol);
case SymbolKind.TupleType:
return Translate(((TupleTypeSymbol)typeSymbol).UnderlyingTupleType, syntaxNodeOpt, diagnostics);
}
throw ExceptionUtilities.UnexpectedValue(typeSymbol.Kind);
......@@ -1090,6 +1091,10 @@ internal override Cci.IMethodReference Translate(MethodSymbol symbol, Diagnostic
{
methodSymbol = AnonymousTypeManager.TranslateAnonymousTypeMethodSymbol(methodSymbol);
}
else if (container.IsTupleType)
{
container = ((TupleTypeSymbol)container).UnderlyingTupleType;
}
if (!methodSymbol.IsDefinition)
{
......
......@@ -165,7 +165,9 @@ public override void VisitNamedType(INamedTypeSymbol symbol)
}
}
if (this.IsMinimizing)
// PROTOTYPE : we need to settle on final tuple symbol visualization.
// it feels like tuples would not need any qualification
if (this.IsMinimizing || symbol.IsTupleType)
{
MinimallyQualify(symbol);
return;
......@@ -238,6 +240,11 @@ private void AddNameAndTypeArgumentsOrParameters(INamedTypeSymbol symbol)
AddAnonymousTypeName(symbol);
return;
}
else if (symbol.IsTupleType)
{
AddTupleTypeName(symbol);
return;
}
string symbolName = null;
......@@ -378,11 +385,32 @@ private void AddAnonymousTypeName(INamedTypeSymbol symbol)
}
}
private void AddTupleTypeName(INamedTypeSymbol symbol)
{
// TODO: revise to generate user-friendly name
var members = string.Join(", ", symbol.GetMembers().OfType<IFieldSymbol>().Select(CreateTupleTypeMember));
if (members.Length == 0)
{
builder.Add(new SymbolDisplayPart(SymbolDisplayPartKind.ClassName, symbol, "<empty tuple type>"));
}
else
{
var name = $"<tuple: {members}>";
builder.Add(new SymbolDisplayPart(SymbolDisplayPartKind.ClassName, symbol, name));
}
}
private string CreateAnonymousTypeMember(IPropertySymbol property)
{
return property.Type.ToDisplayString(format) + " " + property.Name;
}
private string CreateTupleTypeMember(IFieldSymbol field)
{
return field.Type.ToDisplayString(format) + " " + field.Name;
}
private bool CanShowDelegateSignature(INamedTypeSymbol symbol)
{
return
......@@ -479,6 +507,11 @@ private void AddTypeKind(INamedTypeSymbol symbol)
builder.Add(new SymbolDisplayPart(SymbolDisplayPartKind.AnonymousTypeIndicator, null, "AnonymousType"));
AddSpace();
}
else if (symbol.IsTupleType)
{
builder.Add(new SymbolDisplayPart(SymbolDisplayPartKind.AnonymousTypeIndicator, null, "Tuple"));
AddSpace();
}
else
{
var kindKeyword = GetKindKeyword(symbol.TypeKind);
......
......@@ -118,7 +118,7 @@ private void MinimallyQualify(INamedTypeSymbol symbol)
// TODO(cyrusn): This code needs to see if type is an attribute and if it can be shown
// in simplified form here.
if (!symbol.IsAnonymousType)
if (!(symbol.IsAnonymousType || symbol.IsTupleType))
{
if (!NameBoundSuccessfullyToSameSymbol(symbol))
{
......
......@@ -639,7 +639,7 @@ public override int GetHashCode()
/// </summary>
internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiersAndArraySizesAndLowerBounds = false, bool ignoreDynamic = false)
{
if ((object)t2 == this) return true;
if ((object)t2 == this) return true;
if ((object)t2 == null) return false;
if (ignoreDynamic)
......@@ -655,18 +655,13 @@ internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiersAndArrayS
//PROTOTYPE: rename ignoreDynamic or introduce another "ignoreTuple" flag
// if ignoring dynamic, compare underlying tuple types
var tupleType = t2 as TupleTypeSymbol;
if (tupleType != null)
if (t2.IsTupleType)
{
t2 = tupleType.UnderlyingTupleType;
t2 = ((TupleTypeSymbol)t2).UnderlyingTupleType;
if ((object)t2 == this) return true;
}
tupleType = this as TupleTypeSymbol;
if (tupleType != null)
{
return tupleType.UnderlyingTupleType.Equals(t2, ignoreCustomModifiersAndArraySizesAndLowerBounds, ignoreDynamic);
}
Debug.Assert(!this.IsTupleType);
}
NamedTypeSymbol other = t2 as NamedTypeSymbol;
......
......@@ -65,11 +65,11 @@ internal sealed class TupleTypeSymbol : NamedTypeSymbol, ITupleTypeSymbol
var underlyingField2 = (FieldSymbol) Binder.GetWellKnownTypeMember(binder.Compilation, WellKnownMember.System_Runtime_CompilerServices_ValueTuple_T1_T2__Item2, diagnostics, syntax: syntax);
fields = ImmutableArray.Create(
new TupleFieldSymbol(elementNames.IsEmpty ? "Item1" : elementNames[0],
new TupleFieldSymbol(elementNames.IsDefault ? "Item1" : elementNames[0],
this,
elementTypes[0],
underlyingField1?.AsMember(underlyingType)),
new TupleFieldSymbol(elementNames.IsEmpty ? "Item2" : elementNames[1],
new TupleFieldSymbol(elementNames.IsDefault ? "Item2" : elementNames[1],
this,
elementTypes[1],
underlyingField2?.AsMember(underlyingType))
......@@ -136,6 +136,14 @@ internal sealed override bool IsManagedType
}
}
public override bool IsTupleType
{
get
{
return true;
}
}
internal sealed override ObsoleteAttributeData ObsoleteAttributeData
{
get { return _underlyingType.ObsoleteAttributeData; }
......@@ -148,7 +156,7 @@ public override ImmutableArray<Symbol> GetMembers()
public override ImmutableArray<Symbol> GetMembers(string name)
{
//TODO: PERF do we need to have a dictionary here?
//PROTOTYPE: PERF do we need to have a dictionary here?
// tuples will be typically small 2 or 3 elements only
return ImmutableArray<Symbol>.CastUp(_fields).WhereAsArray(field => field.Name == name);
}
......@@ -172,7 +180,7 @@ public override SymbolKind Kind
{
get
{
return SymbolKind.TupleType;
return _underlyingType.Kind;
}
}
......@@ -180,7 +188,7 @@ public override TypeKind TypeKind
{
get
{
return TypeKind.Tuple;
return _underlyingType.TypeKind;
}
}
......@@ -188,7 +196,7 @@ public override Symbol ContainingSymbol
{
get
{
return null;
return _underlyingType.ContainingSymbol;
}
}
......@@ -229,6 +237,10 @@ internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiers, bool ig
{
//PROTOTYPE: rename ignoreDynamic or introduce another "ignoreTuple" flag
// if ignoring dynamic, compare underlying tuple types
if (t2.IsTupleType)
{
t2 = (t2 as TupleTypeSymbol).UnderlyingTupleType;
}
return _underlyingType.Equals(t2, ignoreCustomModifiers, ignoreDynamic);
}
......@@ -280,7 +292,7 @@ public override Accessibility DeclaredAccessibility
{
get
{
return Accessibility.NotApplicable;
return _underlyingType.DeclaredAccessibility;
}
}
......@@ -312,7 +324,7 @@ public override int Arity
{
get
{
return _underlyingType.Arity;
return 0;
}
}
......@@ -320,7 +332,7 @@ public override ImmutableArray<TypeParameterSymbol> TypeParameters
{
get
{
return _underlyingType.TypeParameters;
return ImmutableArray<TypeParameterSymbol>.Empty;
}
}
......@@ -328,7 +340,7 @@ internal override ImmutableArray<ImmutableArray<CustomModifier>> TypeArgumentsCu
{
get
{
return _underlyingType.TypeArgumentsCustomModifiers;
return ImmutableArray<ImmutableArray<CustomModifier>>.Empty;
}
}
......@@ -336,7 +348,7 @@ internal override bool HasTypeArgumentsCustomModifiers
{
get
{
return _underlyingType.HasTypeArgumentsCustomModifiers;
return false;
}
}
......@@ -344,7 +356,7 @@ internal override ImmutableArray<TypeSymbol> TypeArgumentsNoUseSiteDiagnostics
{
get
{
return _underlyingType.TypeArgumentsNoUseSiteDiagnostics;
return ImmutableArray<TypeSymbol>.Empty;
}
}
......@@ -352,7 +364,7 @@ public override NamedTypeSymbol ConstructedFrom
{
get
{
return _underlyingType.ConstructedFrom;
return this;
}
}
......@@ -376,7 +388,7 @@ internal override bool MangleName
{
get
{
return _underlyingType.MangleName;
return false;
}
}
......@@ -392,7 +404,7 @@ internal override bool HasSpecialName
{
get
{
return _underlyingType.HasSpecialName;
return false;
}
}
......@@ -400,7 +412,7 @@ internal override bool IsComImport
{
get
{
return _underlyingType.IsComImport;
return false;
}
}
......@@ -408,7 +420,7 @@ internal override bool IsWindowsRuntimeImport
{
get
{
return _underlyingType.IsWindowsRuntimeImport;
return false;
}
}
......@@ -416,7 +428,7 @@ internal override bool ShouldAddWinRTMembers
{
get
{
return _underlyingType.ShouldAddWinRTMembers;
return false;
}
}
......@@ -456,7 +468,7 @@ internal override bool IsInterface
{
get
{
return _underlyingType.IsInterface;
return false;
}
}
......@@ -488,59 +500,49 @@ internal override bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticIn
#region ISymbol Members
public override void Accept(SymbolVisitor visitor)
{
visitor.VisitTupleType(this);
}
public override TResult Accept<TResult>(SymbolVisitor<TResult> visitor)
{
return visitor.VisitTupleType(this);
}
internal override AttributeUsageInfo GetAttributeUsageInfo()
{
throw new NotImplementedException();
return AttributeUsageInfo.Null;
}
internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers()
{
throw new NotImplementedException();
return this.GetMembers();
}
internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name)
{
throw new NotImplementedException();
return this.GetMembers(name);
}
internal override NamedTypeSymbol GetDeclaredBaseType(ConsList<Symbol> basesBeingResolved)
{
throw new NotImplementedException();
return _underlyingType.GetDeclaredBaseType(basesBeingResolved);
}
internal override ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList<Symbol> basesBeingResolved)
{
throw new NotImplementedException();
return _underlyingType.GetDeclaredInterfaces(basesBeingResolved);
}
internal override IEnumerable<SecurityAttribute> GetSecurityInformation()
{
throw new NotImplementedException();
throw ExceptionUtilities.Unreachable;
}
internal override ImmutableArray<string> GetAppliedConditionalSymbols()
{
throw new NotImplementedException();
return ImmutableArray<string>.Empty;
}
internal override IEnumerable<FieldSymbol> GetFieldsToEmit()
{
throw new NotImplementedException();
throw ExceptionUtilities.Unreachable;
}
internal override ImmutableArray<NamedTypeSymbol> GetInterfacesToEmit()
{
throw new NotImplementedException();
throw ExceptionUtilities.Unreachable;
}
#endregion
......
......@@ -553,6 +553,17 @@ public virtual bool IsAnonymousType
}
}
/// <summary>
/// Is this a symbol for a Tuple
/// </summary>
public virtual bool IsTupleType
{
get
{
return false;
}
}
/// <summary>
/// Is this type a managed type (false for everything but enum, pointer, and
/// some struct types).
......
......@@ -509,7 +509,6 @@ public static TypeSymbol VisitType<T>(this TypeSymbol type, Func<TypeSymbol, T,
case TypeKind.Interface:
case TypeKind.Enum:
case TypeKind.Delegate:
case TypeKind.Tuple:
foreach (var typeArg in ((NamedTypeSymbol)current).TypeArgumentsNoUseSiteDiagnostics)
{
var result = typeArg.VisitType(predicate, arg);
......
......@@ -12,8 +12,6 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen
{
public class CodeGenTupleTests : CSharpTestBase
{
private static readonly string trivial2uple =
@"
......@@ -95,17 +93,17 @@ static void Main()
// Code size 54 (0x36)
.maxstack 5
.locals init (System.Runtime.CompilerServices.ValueTuple<int, string> V_0, //x
System.Runtime.CompilerServices.ValueTuple<int, > V_1)
System.Runtime.CompilerServices.ValueTuple<int, <tuple: int Item1, int Item2>> V_1)
IL_0000: ldloca.s V_0
IL_0002: ldc.i4.1
IL_0003: ldc.i4.2
IL_0004: ldc.i4.3
IL_0005: ldc.i4.4
IL_0006: newobj ""System.Runtime.CompilerServices.ValueTuple<int, int>..ctor(int, int)""
IL_000b: newobj ""System.Runtime.CompilerServices.ValueTuple<int, >..ctor(int, )""
IL_000b: newobj ""System.Runtime.CompilerServices.ValueTuple<int, <tuple: int Item1, int Item2>>..ctor(int, <tuple: int Item1, int Item2>)""
IL_0010: stloc.1
IL_0011: ldloca.s V_1
IL_0013: constrained. ""System.Runtime.CompilerServices.ValueTuple<int, >""
IL_0013: constrained. ""System.Runtime.CompilerServices.ValueTuple<int, <tuple: int Item1, int Item2>>""
IL_0019: callvirt ""string object.ToString()""
IL_001e: call ""System.Runtime.CompilerServices.ValueTuple<int, string>..ctor(int, string)""
IL_0023: ldloca.s V_0
......@@ -277,30 +275,30 @@ static void Main()
{
// Code size 87 (0x57)
.maxstack 4
.locals init (System.Runtime.CompilerServices.ValueTuple<int, > V_0) //x
.locals init (System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>> V_0) //x
IL_0000: ldloca.s V_0
IL_0002: ldc.i4.1
IL_0003: ldc.i4.2
IL_0004: ldc.i4.3
IL_0005: newobj ""System.Runtime.CompilerServices.ValueTuple<int, int>..ctor(int, int)""
IL_000a: call ""System.Runtime.CompilerServices.ValueTuple<int, >..ctor(int, )""
IL_000a: call ""System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>>..ctor(int, <tuple: int c, int d>)""
IL_000f: ldloca.s V_0
IL_0011: ldflda "" System.Runtime.CompilerServices.ValueTuple<int, >.Item2""
IL_0011: ldflda ""<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>>.Item2""
IL_0016: ldflda ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item1""
IL_001b: call ""string int.ToString()""
IL_0020: call ""void System.Console.WriteLine(string)""
IL_0025: ldloca.s V_0
IL_0027: ldflda "" System.Runtime.CompilerServices.ValueTuple<int, >.Item2""
IL_0027: ldflda ""<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>>.Item2""
IL_002c: ldc.i4.s 39
IL_002e: stfld ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item2""
IL_0033: ldloc.0
IL_0034: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int, >.Item1""
IL_0034: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>>.Item1""
IL_0039: ldloc.0
IL_003a: ldfld "" System.Runtime.CompilerServices.ValueTuple<int, >.Item2""
IL_003a: ldfld ""<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>>.Item2""
IL_003f: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item1""
IL_0044: add
IL_0045: ldloc.0
IL_0046: ldfld "" System.Runtime.CompilerServices.ValueTuple<int, >.Item2""
IL_0046: ldfld ""<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>>.Item2""
IL_004b: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item2""
IL_0050: add
IL_0051: call ""void System.Console.WriteLine(int)""
......
......@@ -64,6 +64,11 @@ public interface ITypeSymbol : INamespaceOrTypeSymbol
/// </summary>
bool IsAnonymousType { get; }
/// <summary>
/// Is this a symbol for a tuple .
/// </summary>
bool IsTupleType { get; }
/// <summary>
/// The original definition of this symbol. If this symbol is constructed from another
/// symbol by type substitution then <see cref="OriginalDefinition"/> gets the original symbol as it was defined in
......
......@@ -101,10 +101,5 @@ public enum SymbolKind
/// Symbol is a preprocessing/conditional compilation constant.
/// </summary>
Preprocessing = 18,
/// <summary>
/// Symbol is a tuple type.
/// </summary>
TupleType = 19,
}
}
......@@ -23,11 +23,6 @@ public virtual void VisitArrayType(IArrayTypeSymbol symbol)
DefaultVisit(symbol);
}
public virtual void VisitTupleType(ITupleTypeSymbol symbol)
{
DefaultVisit(symbol);
}
public virtual void VisitAssembly(IAssemblySymbol symbol)
{
DefaultVisit(symbol);
......
......@@ -26,11 +26,6 @@ public virtual TResult VisitArrayType(IArrayTypeSymbol symbol)
return DefaultVisit(symbol);
}
public virtual TResult VisitTupleType(ITupleTypeSymbol symbol)
{
return DefaultVisit(symbol);
}
public virtual TResult VisitAssembly(IAssemblySymbol symbol)
{
return DefaultVisit(symbol);
......
......@@ -79,10 +79,5 @@ public enum TypeKind : byte
/// Type is an interactive submission.
/// </summary>
Submission = 12,
/// <summary>
/// Type is a tuple.
/// </summary>
Tuple = 13,
}
}
......@@ -452,6 +452,13 @@ Done:
End Get
End Property
Private ReadOnly Property ITypeSymbol_IsTupleSymbol As Boolean Implements ITypeSymbol.IsTupleType
Get
' PROTOTYPE: VB does not yet support tuples.
Return False
End Get
End Property
Private ReadOnly Property ITypeSymbol_TypeKind As TypeKind Implements ITypeSymbol.TypeKind
Get
Return Me.TypeKind.ToCommon()
......
......@@ -243,6 +243,14 @@ public bool IsAnonymousType
}
}
public bool IsTupleType
{
get
{
return _symbol.IsTupleType;
}
}
ITypeSymbol ITypeSymbol.OriginalDefinition
{
get
......
......@@ -74,6 +74,14 @@ public bool IsAnonymousType
}
}
public bool IsTupleType
{
get
{
return false;
}
}
public new ITypeSymbol OriginalDefinition
{
get
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册