-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Don't wrap fields in ValueTuple definitions #44231
Changes from all commits
72dc304
881e92d
21f72af
348daea
4154f07
758a8be
f4b0b9e
df14519
f491231
6400146
2054720
fc85a89
74cfed2
c422d49
c57a02b
c18e709
49199b8
5575125
52dba4d
92cf81d
e40f8c3
ae512eb
612364d
a3706e7
6b52689
9eeeecb
d260464
59933df
465438c
77e86db
ac45f85
1b2eb98
2484dc0
f02ee32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,6 +409,7 @@ Cci.ITypeReference Cci.ITypeDefinition.GetBaseClass(EmitContext context) | |
foreach (var f in AdaptedNamedTypeSymbol.GetFieldsToEmit()) | ||
{ | ||
Debug.Assert((object)(f.TupleUnderlyingField ?? f) == f); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we should keep the assert. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, I think we should make it even stronger and make sure we don't run into a In reply to: 426203595 [](ancestors = 426203595) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like the thread is actually addressed and no other response provided. In reply to: 426264743 [](ancestors = 426264743,426203595) |
||
Debug.Assert(!(f is TupleErrorFieldSymbol)); | ||
if (isStruct || f.GetCciAdapter().ShouldInclude(context)) | ||
{ | ||
yield return f.GetCciAdapter(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,12 +276,14 @@ private void ValidateReferencedAssembly(AssemblySymbol assembly, AssemblyReferen | |
AddSymbolLocation(result, member); | ||
break; | ||
case SymbolKind.Field: | ||
// NOTE: Dev11 does not add synthesized backing fields for properties, | ||
// but adds backing fields for events, Roslyn adds both | ||
if (member is TupleErrorFieldSymbol) | ||
{ | ||
var field = (FieldSymbol)member; | ||
AddSymbolLocation(result, field.TupleUnderlyingField ?? field); | ||
break; | ||
} | ||
|
||
// NOTE: Dev11 does not add synthesized backing fields for properties, | ||
// but adds backing fields for events, Roslyn adds both | ||
AddSymbolLocation(result, member); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It feels like we should skip |
||
break; | ||
|
||
case SymbolKind.Event: | ||
|
@@ -291,7 +293,7 @@ private void ValidateReferencedAssembly(AssemblySymbol assembly, AssemblyReferen | |
FieldSymbol field = ((EventSymbol)member).AssociatedField; | ||
if ((object)field != null) | ||
{ | ||
AddSymbolLocation(result, field.TupleUnderlyingField ?? field); | ||
AddSymbolLocation(result, field); | ||
} | ||
} | ||
break; | ||
|
@@ -1028,7 +1030,9 @@ internal Cci.IFieldReference Translate( | |
bool needDeclaration = false) | ||
{ | ||
Debug.Assert(fieldSymbol.IsDefinitionOrDistinct()); | ||
Debug.Assert(!fieldSymbol.IsVirtualTupleField && (object)(fieldSymbol.TupleUnderlyingField ?? fieldSymbol) == fieldSymbol, "tuple fields should be rewritten to underlying by now"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we should keep this condition, it is still bad to violate it. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, I think we should make the assert even stronger and make sure we don't run into a In reply to: 426203778 [](ancestors = 426203778) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like the thread is actually addressed completely and no other response provided. In reply to: 426264817 [](ancestors = 426264817,426203778) |
||
Debug.Assert(!fieldSymbol.IsVirtualTupleField && | ||
(object)(fieldSymbol.TupleUnderlyingField ?? fieldSymbol) == fieldSymbol && | ||
fieldSymbol is not TupleErrorFieldSymbol, "tuple fields should be rewritten to underlying by now"); | ||
|
||
if (!fieldSymbol.IsDefinition) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1350,14 +1350,18 @@ internal override IEnumerable<FieldSymbol> GetFieldsToEmit() | |
switch (m.Kind) | ||
{ | ||
case SymbolKind.Field: | ||
var field = (FieldSymbol)m; | ||
yield return field.TupleUnderlyingField ?? field; | ||
if (m is TupleErrorFieldSymbol) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When do we try to emit with error fields? #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is recognized as a 2-tuple, and thus has In reply to: 425348604 [](ancestors = 425348604) |
||
{ | ||
break; | ||
} | ||
|
||
yield return (FieldSymbol)m; | ||
break; | ||
case SymbolKind.Event: | ||
FieldSymbol? associatedField = ((EventSymbol)m).AssociatedField; | ||
if ((object?)associatedField != null) | ||
{ | ||
yield return associatedField.TupleUnderlyingField ?? associatedField; | ||
yield return associatedField; | ||
} | ||
break; | ||
} | ||
|
@@ -1499,13 +1503,6 @@ internal void AssertMemberExposure(Symbol member, bool forDiagnostics = false) | |
return; | ||
} | ||
|
||
if (member is FieldSymbol && this.IsTupleType) | ||
{ | ||
Debug.Assert(forDiagnostics); | ||
return; // There are dangling tuple elements, probably related to https://github.com/dotnet/roslyn/issues/43597 | ||
// and will be addressed by a pending PR https://github.com/dotnet/roslyn/pull/44231. | ||
} | ||
|
||
Debug.Assert(false, "Premature symbol exposure."); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there is an extra empty line above #Closed