You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the following test in 'CustomModifierCopyTests'. It appears that lowering is dropping the custom modifier which was present in the type of [] in initial binding.
It's not obvious to me whether this difference represents a real problem or not. Perhaps when the array type is created in the method implementation, and custom modifiers are missing which were present on the return type, then bad things could happen.
/// <summary>/// Test copying custom modifiers in/on property types./// </summary>[Fact]publicvoidTestPropertyOverrideCombinations_CollectionExpressionConversion(){vartext=@"class Derived : PropertyCustomModifierCombinations{ public override int[] Property11 { get => []; set { } } public override int[] Property10 { get => []; set { } } public override int[] Property01 { get => []; set { } } public override int[] Property00 { get => []; set { } }}";varilAssemblyReference=TestReferences.SymbolsTests.CustomModifiers.Modifiers.dll;varcomp=CreateCompilation(text,newMetadataReference[]{ilAssemblyReference});varglobal=comp.GlobalNamespace;comp.VerifyEmitDiagnostics();var@class=global.GetMember<NamedTypeSymbol>("Derived");for(inti=0;i<0x4;i++){PropertySymbolproperty=@class.GetMember<PropertySymbol>("Property"+Convert.ToString(i,2).PadLeft(2,'0'));boolinType=(i&0x2)!=0;boolonType=(i&0x1)!=0;CheckPropertyCustomModifiers(property,inType,onType);CheckMethodCustomModifiers(property.GetMethod,inReturnType:inType,onReturnType:onType,inParameterType:false,onParameterType:false);CheckMethodCustomModifiers(property.SetMethod,inReturnType:false,onReturnType:false,inParameterType:inType,onParameterType:onType);}}
Failure message:
System.InvalidOperationException : Assertion failed
Stack Trace:
ThrowingTraceListener.Fail(String message, String detailMessage) line 26
TraceInternal.Fail(String message)
Debug.Assert(Boolean condition)
LocalRewriter.VisitExpressionImpl(BoundExpression node) line 280
LocalRewriter.Visit(BoundNode node) line 214
BoundTreeRewriter.VisitReturnStatement(BoundReturnStatement node) line 11274
LocalRewriter.VisitReturnStatement(BoundReturnStatement node) line 15
BoundReturnStatement.Accept(BoundTreeVisitor visitor) line 3551
LocalRewriter.VisitStatement(BoundStatement node) line 241
LocalRewriter.VisitPossibleUsingDeclaration(BoundStatement node, ImmutableArray`1 statements, Int32 statementIndex, Boolean& replacedLocalDeclarations) line 123
LocalRewriter.VisitStatementSubList(ArrayBuilder`1 builder, ImmutableArray`1 statements, Int32 startIndex) line 81
LocalRewriter.VisitBlock(BoundBlock node) line 33
BoundBlock.Accept(BoundTreeVisitor visitor) line 3293
LocalRewriter.VisitStatement(BoundStatement node) line 241
LocalRewriter.Rewrite(CSharpCompilation compilation, MethodSymbol method, Int32 methodOrdinal, NamedTypeSymbol containingType, BoundStatement statement, TypeCompilationState compilationState, SynthesizedSubmissionFields previousSubmissionFields, Boolean allowOmissionOfConditionalCalls, MethodInstrumentation instrumentation, DebugDocumentProvider debugDocumentProvider, BindingDiagnosticBag diagnostics, ImmutableArray`1& codeCoverageSpans, Boolean& sawLambdas, Boolean& sawLocalFunctions, Boolean& sawAwaitInExceptionHandler) line 146
MethodCompiler.LowerBodyOrInitializer(MethodSymbol method, Int32 methodOrdinal, BoundStatement body, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState, MethodInstrumentation instrumentation, DebugDocumentProvider debugDocumentProvider, ImmutableArray`1& codeCoverageSpans, BindingDiagnosticBag diagnostics, VariableSlotAllocator& lazyVariableSlotAllocator, ArrayBuilder`1 lambdaDebugInfoBuilder, ArrayBuilder`1 lambdaRuntimeRudeEditsBuilder, ArrayBuilder`1 closureDebugInfoBuilder, ArrayBuilder`1 stateMachineStateDebugInfoBuilder, StateMachineTypeSymbol& stateMachineTypeOpt) line 1373
MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState) line 1159
MethodCompiler.CompileNamedType(NamedTypeSymbol containingType) line 530
<>c__DisplayClass25_0.<CompileNamedTypeAsync>b__0() line 432
<>c__DisplayClass5_0.<WithCurrentUICulture>b__0() line 139
Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
ExceptionDispatchInfo.Throw()
TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
TaskAwaiter.GetResult()
MethodCompiler.WaitForWorkers() line 331
MethodCompiler.CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, Boolean emittingPdb, Boolean hasDeclarationErrors, Boolean emitMethodBodies, BindingDiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) line 160
CSharpCompilation.CompileMethods(CommonPEModuleBuilder moduleBuilder, Boolean emittingPdb, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) line 3505
Compilation.Emit(Stream peStream, Stream metadataPEStream, Stream pdbStream, Stream xmlDocumentationStream, Stream win32Resources, IEnumerable`1 manifestResources, EmitOptions options, IMethodSymbol debugEntryPoint, Stream sourceLinkStream, IEnumerable`1 embeddedTexts, RebuildData rebuildData, CompilationTestData testData, CancellationToken cancellationToken) line 2952
Compilation.Emit(Stream peStream, Stream pdbStream, Stream xmlDocumentationStream, Stream win32Resources, IEnumerable`1 manifestResources, EmitOptions options, IMethodSymbol debugEntryPoint, Stream sourceLinkStream, IEnumerable`1 embeddedTexts, Stream metadataPEStream, RebuildData rebuildData, CancellationToken cancellationToken) line 2893
Compilation.Emit(Stream peStream, Stream pdbStream, Stream xmlDocumentationStream, Stream win32Resources, IEnumerable`1 manifestResources, EmitOptions options, IMethodSymbol debugEntryPoint, Stream sourceLinkStream, IEnumerable`1 embeddedTexts, Stream metadataPEStream, CancellationToken cancellationToken) line 2781
DiagnosticExtensions.GetEmitDiagnostics[TCompilation](TCompilation c, EmitOptions options, IEnumerable`1 manifestResources) line 367
DiagnosticExtensions.VerifyEmitDiagnostics[TCompilation](TCompilation c, EmitOptions options, DiagnosticDescription[] expected) line 356
DiagnosticExtensions.VerifyEmitDiagnostics[TCompilation](TCompilation c, DiagnosticDescription[] expected) line 373
CustomModifierCopyTests.TestPropertyOverrideCombinations_CollectionExpressionConversion() line 405
The text was updated successfully, but these errors were encountered:
RikkiGibson
changed the title
Custom modifiers are not copied in array type collection expression conversion
Custom modifiers are not copied in array type collection expression lowering
May 31, 2024
Add the following test in 'CustomModifierCopyTests'. It appears that lowering is dropping the custom modifier which was present in the type of
[]
in initial binding.It's not obvious to me whether this difference represents a real problem or not. Perhaps when the array type is created in the method implementation, and custom modifiers are missing which were present on the return type, then bad things could happen.
Failure message:
The text was updated successfully, but these errors were encountered: