From b9e8dda61b3c46e34f7ca519b33bf376c874beb0 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Mon, 19 Jun 2023 15:04:53 -0700 Subject: [PATCH 1/2] Fix issue where type validation checker failed to instantiate signature before performing signature comparison --- .../DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs index 7f8a754f256981..c83b3291b05b57 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs @@ -314,7 +314,7 @@ Task ValidateTypeWorkerHelper(TypeDesc typeToCheckForSkipValidation) var methodDecl = type.EcmaModule.GetMethod(methodImpl.MethodDeclaration); // Validate that all MethodImpls actually match signatures closely enough - if (!methodBody.Signature.EqualsWithCovariantReturnType(methodDecl.Signature)) + if (!methodBody.Signature.ApplySubstitution(type.Instantiation).EqualsWithCovariantReturnType(methodDecl.Signature)) { AddTypeValidationError(type, $"MethodImpl with Body '{methodBody}' and Decl '{methodDecl}' do not have matching signatures"); return false; From 5c5160d13559451b39353511b863286cbd7f1836 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Mon, 19 Jun 2023 18:01:02 -0700 Subject: [PATCH 2/2] Fix other cases where covariant type checking is done --- .../DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs index c83b3291b05b57..0b23b756c00da6 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs @@ -314,7 +314,7 @@ Task ValidateTypeWorkerHelper(TypeDesc typeToCheckForSkipValidation) var methodDecl = type.EcmaModule.GetMethod(methodImpl.MethodDeclaration); // Validate that all MethodImpls actually match signatures closely enough - if (!methodBody.Signature.ApplySubstitution(type.Instantiation).EqualsWithCovariantReturnType(methodDecl.Signature)) + if (!methodBody.Signature.ApplySubstitution(type.Instantiation).EqualsWithCovariantReturnType(methodDecl.Signature.ApplySubstitution(type.Instantiation))) { AddTypeValidationError(type, $"MethodImpl with Body '{methodBody}' and Decl '{methodDecl}' do not have matching signatures"); return false; @@ -437,7 +437,7 @@ Task ValidateTypeWorkerHelper(TypeDesc typeToCheckForSkipValidation) if ((virtualMethod.OwningType != type.BaseType) && (virtualMethod.OwningType != type) && (baseTypeVirtualMethodAlgorithm != null)) { var implementationOnBaseType = baseTypeVirtualMethodAlgorithm.FindVirtualFunctionTargetMethodOnObjectType(virtualMethod, type.BaseType); - if (!implementationMethod.Signature.EqualsWithCovariantReturnType(implementationOnBaseType.Signature)) + if (!implementationMethod.Signature.ApplySubstitution(type.Instantiation).EqualsWithCovariantReturnType(implementationOnBaseType.Signature.ApplySubstitution(type.Instantiation))) { AddTypeValidationError(type, $"Virtual method '{virtualMethod}' overriden by method '{implementationMethod}' does not satisfy the covariant return type introduced with '{implementationOnBaseType}'"); return false;