Added: C# Language Design Notes for Aug 14, 2017 #825
Replies: 5 comments
-
That sounds a lot similar to #727. Is that how the "special mechanism" could look like? |
Beta Was this translation helpful? Give feedback.
-
👍 |
Beta Was this translation helpful? Give feedback.
-
Something that occurs to me now that you're talking about generics: What are all the places that public class Foo<TBar>
where TBar : Bar
{
public TBar Bar { get; }
} The Does this now produce a warning because of the class declaration? If yes, then how would I resolve that? //Option 1:
public class Foo<TBar?>
//-----------
//Option 2:
where TBar? : Bar
//-----------
//Option 3:
where TBar : Bar?
//-----------
//Possibly some combination? I think that it sounds like option 3 by itself is how it could go, which is also what I like the most. (For the record: I like option 1 the least, since that may pre-empt my following question.) Secondly: If nullability is explicitly stated by a constraint like option 3, does it still need to be stated at use-sites? I'm hoping "No", since the type argument doesn't change the fact that the base class property type is annotated with //Should not require the `?`
var foo = new Foo<DerivedBar>();
var bar = foo.Bar; //type: 'DerivedBar?'
//Neither here
public class DerivedFoo : Foo<DerivedBar>
{
} |
Beta Was this translation helpful? Give feedback.
-
Perhaps |
Beta Was this translation helpful? Give feedback.
-
Regarding the class constraint. Does this mean we will be able to use
This raises an important issue with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
C# Language Design Notes for Aug 14, 2017
We looked at the interaction between generics and nullable reference types
Please discuss!
Beta Was this translation helpful? Give feedback.
All reactions