-
Notifications
You must be signed in to change notification settings - Fork 4k
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
File types binding #60977
File types binding #60977
Changes from all commits
fe95366
84624a5
32f20d4
4d66ff2
eb4a758
e12cf05
42e8c6a
d90473a
b3758d5
ef64fe1
dff49d2
b29dbc4
f9f9e85
db8e18c
a8391bc
1e470dd
8ba0014
8ec3b14
c70e9a1
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 |
---|---|---|
|
@@ -1816,6 +1816,15 @@ Symbol resultSymbol( | |
Debug.Assert(!Symbol.Equals(first, second, TypeCompareKind.ConsiderEverything) || !Symbol.Equals(originalSymbols[best.Index], originalSymbols[secondBest.Index], TypeCompareKind.ConsiderEverything), | ||
"Why does the LookupResult contain the same symbol twice?"); | ||
|
||
if (best.IsFromFile && !secondBest.IsFromFile) | ||
{ | ||
// a lookup of a file type is "better" than a lookup of a non-file type; no need to further diagnose | ||
// PROTOTYPE(ft): some "single symbol" diagnostics are missed here for similar reasons | ||
// that make us miss diagnostics when reporting WRN_SameFullNameThisAggAgg. | ||
// | ||
return first; | ||
} | ||
|
||
CSDiagnosticInfo info; | ||
bool reportError; | ||
|
||
|
@@ -2133,6 +2142,7 @@ private static AssemblySymbol GetContainingAssembly(Symbol symbol) | |
private enum BestSymbolLocation | ||
{ | ||
None, | ||
FromFile, | ||
FromSourceModule, | ||
FromAddedModule, | ||
FromReferencedAssembly, | ||
|
@@ -2180,6 +2190,14 @@ public bool IsFromCompilation | |
} | ||
} | ||
|
||
public bool IsFromFile | ||
{ | ||
get | ||
{ | ||
return _location == BestSymbolLocation.FromFile; | ||
} | ||
} | ||
|
||
public bool IsNone | ||
{ | ||
get | ||
|
@@ -2281,6 +2299,11 @@ private BestSymbolInfo GetBestSymbolInfo(ArrayBuilder<Symbol> symbols, out BestS | |
|
||
private static BestSymbolLocation GetLocation(CSharpCompilation compilation, Symbol symbol) | ||
{ | ||
if (symbol is SourceMemberContainerTypeSymbol { IsFile: true }) | ||
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. 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 might, in some cases where the member access is not qualified. The only relevant case I can think of, though, involves // File1.cs
using static C.D;
M();
file class C
{
public class D
{
public static void M() { }
}
}
// File2.cs
class C
{
public class D
{
public static void M() { }
}
} I'll add the test. Let me know if any other scenarios come to mind that might hit this issue. 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 added this test and it "just worked". I suspect this is because we "broke the tie" when binding the |
||
{ | ||
return BestSymbolLocation.FromFile; | ||
} | ||
|
||
var containingAssembly = symbol.ContainingAssembly; | ||
if (containingAssembly == compilation.SourceAssembly) | ||
{ | ||
|
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.
Isn't this covered by the previous
else if
? Specifically, won'tthis.IsAccessible(symbol, ...)
handle this?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.
No, we're treating this as a "parallel" concept to accessibility. So IsAccessible, IsAtLeastAsVisibleAs, etc. don't consider file types.