-
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
Specially handle some scenarios for type parameters with 'allows ref struct' constraint #73025
Specially handle some scenarios for type parameters with 'allows ref struct' constraint #73025
Conversation
@@ -527,9 +527,14 @@ public static bool IsPossibleArrayGenericInterface(this TypeSymbol type) | |||
return false; | |||
} | |||
|
|||
internal static bool IsErrorTypeOrRefLikeType(this TypeSymbol type) | |||
internal static bool IsErrorTypeOrIsRefLikeTypeOrAllowByRefLike(this TypeSymbol type) |
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.
internal static bool IsErrorTypeOrIsRefLikeTypeOrAllowByRefLike(this TypeSymbol type) | |
internal static bool IsErrorTypeOrIsRefLikeTypeOrAllowsByRefLike(this TypeSymbol type) | |
``` #Resolved |
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.
I prefer to do this rename in the next PR.
var src2 = @" | ||
public class Helper | ||
{ | ||
public static void Test1<T>(scoped T x) |
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.
Consider testing scoped ref T
parameter as well. #Pending
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.
Consider testing
scoped ref T
parameter as well.
Why do you think this is interesting? Any ref
parameter can be declared scoped, no type restrictions for that.
} | ||
|
||
[Fact] | ||
public void ScopedTypeParameter_02() |
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.
Nit: looks like this is testing locals, not parameters. #Resolved
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.
Nit: looks like this is testing locals, not parameters.
The name of the test says "TypeParameter" and that is what the test is testing.
|
||
public class Helper | ||
{ | ||
static void Test1<T>([UnscopedRef] params scoped T x) |
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.
Consider testing similar scenario without params
#Resolved
} | ||
|
||
[Fact] | ||
public void AutoProperty() |
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.
Consider testing similar scenario with synthesized record properties #Resolved
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.
Consider testing similar scenario with synthesized record properties
RestrictedTypesInRecords
will be added in the next PR
var src = @" | ||
abstract class Base | ||
{ | ||
protected abstract T Test1<T>(scoped T x) |
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.
Should we test similar scenario with params T
which is implicitly scoped? #Resolved
@@ -333,7 +333,7 @@ private enum IsParamsValues : byte | |||
Debug.Assert(refKind != RefKind.None); | |||
scope = ScopedKind.ScopedRef; |
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.
Can we have T: allows ref struct
parameter symbol which is also byref, in metadata? #Resolved
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.
Can we have
T: allows ref struct
parameter symbol which is also byref, in metadata?
We can have one in source as well. There is nothing wrong with that.
{ | ||
// ref struct R2<T> where T : allows ref struct | ||
// { | ||
// public ref T F; |
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.
Consider adding a test like this for a parameter as well. #Resolved
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.
Consider adding a test like this for a parameter as well.
Parameters like that are supported and there is already a bunch of tests covering them.
@jjonescz Thank you for the test suggestions. However, I am going through specific code paths (marked with PROTOTYPE comments, quate possibly some are marked in the first commit of this PR), adjusting the code paths (if necessary) and adding targeted tests for those specific code paths. I will capture you suggestions as PROTOTYPE comments in the next PR, but I will not be adding the tests at the moment. |
@cston, @dotnet/roslyn-compiler For the second review |
// public static S P4 {get; set;} | ||
Diagnostic(ErrorCode.ERR_FieldAutoPropCantBeByRefLike, "S").WithArguments("S").WithLocation(13, 19) | ||
); | ||
} |
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.
// protected abstract override void Test2(S y, out S z); | ||
Diagnostic(ErrorCode.ERR_ScopedMismatchInParameterOfOverrideOrImplementation, "Test2").WithArguments("y").WithLocation(14, 38) | ||
); | ||
} |
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.
e3b4e37
into
dotnet:features/RefStructInterfaces
No description provided.