Erase nullability from base and interfaces for types from unannotated assemblies#28028
Erase nullability from base and interfaces for types from unannotated assemblies#28028cston merged 11 commits intodotnet:features/NullableReferenceTypesfrom
Conversation
| if (a.QuestionToken.IsKind(SyntaxKind.QuestionToken)) | ||
| { | ||
| type = TypeSymbolWithAnnotations.CreateNullableReferenceType(array); | ||
| type = TypeSymbolWithAnnotations.Create(array, isNullableIfReferenceType: true); |
There was a problem hiding this comment.
Inlined the one instance of CreateNullableReferenceType().
| return new NonLazyType(typeSymbol, isNullable, customModifiers); | ||
| } | ||
|
|
||
| public TypeSymbolWithAnnotations AsNullableReferenceOrValueType(CSharpCompilation compilation, SyntaxReference nullableTypeSyntax) |
There was a problem hiding this comment.
nullableTypeSyntax was not needed.
|
@dotnet/roslyn-compiler please review. |
|
Please tag with Area-Compiler so it shows up in review queue. Thanks #Resolved |
|
@dotnet/roslyn-compiler please review. |
| { | ||
| static void F(object? x, B b) | ||
| { | ||
| var y = b.F; |
There was a problem hiding this comment.
; [](start = 19, length = 1)
Maybe add a VerifyTypes comment on b.F? Expecting object~ #Closed
| (new[] { x!, x! })[0].ToString(); | ||
| (new[] { y, y! })[0].ToString(); | ||
| (new[] { y!, y })[0].ToString(); | ||
| } |
There was a problem hiding this comment.
} [](start = 4, length = 1)
If it's not tested elsewhere, I'd also include permutations mixing x and y. Also, mixing z and w below. #Closed
| D<A> d; | ||
| d = Create(x).F; | ||
| x = y; | ||
| d = Create(x).F; // warning |
There was a problem hiding this comment.
x [](start = 19, length = 1)
Consider Create(y).F directly (rather than assigning x = y first). #Closed
| F(y, x)/*T:A?*/.ToString(); // 4 | ||
| F(y, y)/*T:A!*/.ToString(); | ||
| F(y, z)/*T:A!*/.ToString(); | ||
| F(z, x)/*T:A*/.ToString(); // 5 |
There was a problem hiding this comment.
// 5 [](start = 35, length = 4)
There is no warning for 5. I think this comment can be removed. Never mind. There should be a warning (one the ordering issue is fixed) #Closed
| private ImmutableArray<NamedTypeSymbol> _lazyInterfaces = default(ImmutableArray<NamedTypeSymbol>); | ||
| private NamedTypeSymbol _lazyDeclaredBaseType = ErrorTypeSymbol.UnknownResultType; | ||
| private NamedTypeSymbol _lazyDeclaredBaseType1 = ErrorTypeSymbol.UnknownResultType; | ||
| private NamedTypeSymbol _lazyDeclaredBaseType2 = ErrorTypeSymbol.UnknownResultType; |
There was a problem hiding this comment.
_lazyDeclaredBaseType2 [](start = 32, length = 22)
A comment would be useful (why do we need two?). Or maybe rename by adding "WithNullability" #Closed
| } | ||
|
|
||
| // PROTOTYPE(NullableReferenceTypes): Combine with other GetDeclaredBaseType overload and make abstract. | ||
| internal virtual NamedTypeSymbol GetDeclaredBaseType(ConsList<Symbol> basesBeingResolved, bool ignoreNullability) |
There was a problem hiding this comment.
GetDeclaredBaseType [](start = 41, length = 19)
Where is this method called from? It seems that only the overload in PENamedTypeSymbol is called from PENamedTypeSymbol itself. #Closed
There was a problem hiding this comment.
| if (ignoreNullability) | ||
| { | ||
| Interlocked.CompareExchange(ref _lazyDeclaredBaseType, MakeDeclaredBaseType(), ErrorTypeSymbol.UnknownResultType); | ||
| return _lazyDeclaredBaseType1; |
There was a problem hiding this comment.
Let's use a descriptive name, rather than "1" and "2". #Resolved
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (iteration 5).
| return GetDeclaredBaseType(basesBeingResolved, ignoreNullability: false); | ||
| } | ||
|
|
||
| private NamedTypeSymbol GetDeclaredBaseType(ConsList<Symbol> basesBeingResolved, bool ignoreNullability) |
There was a problem hiding this comment.
basesBeingResolved [](start = 69, length = 18)
Why do we even have this parameter if it's never used?
There was a problem hiding this comment.
| i1.F(x); | ||
| i1.F(y); | ||
| i2.F(x); | ||
| i2.F(y); // warn |
There was a problem hiding this comment.
This one is interesting. Perhaps more of a nullable design question, but is there going to be a way for a user to specify that I2.F takes a T?? Seems like a user would want to be able to override this behavior.
There was a problem hiding this comment.
An implicit implementation of I.F could be defined as F(T?) since the interface method is null-oblivious, but interface I2 could not redefine I.F.
In reply to: 198655729 [](ancestors = 198655729)
333fred
left a comment
There was a problem hiding this comment.
LGTM (commit 7) with a more general question on implementation strategy.
|
I know that rebasing causes other problems, but merging also makes the review difficult. Now a number of changes showing up in CodeFlow are not new changes... :-( |
Erase nullability from base and interfaces for types from unannotated assemblies.
Fixes #27967.