From c4544f67d396ee7d5708694d3532ca0eeb1b00d6 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 22 Jun 2020 05:56:57 -0700 Subject: [PATCH] Disallowing generic arguments on ctors/dtors --- IDEHelper/Compiler/BfDefBuilder.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfDefBuilder.cpp b/IDEHelper/Compiler/BfDefBuilder.cpp index 694d34d6..afcf30f8 100644 --- a/IDEHelper/Compiler/BfDefBuilder.cpp +++ b/IDEHelper/Compiler/BfDefBuilder.cpp @@ -584,7 +584,20 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio int outerGenericSize = 0; if (outerMethodDef != NULL) outerGenericSize = (int)outerMethodDef->mGenericParams.size(); - ParseGenericParams(methodDeclaration->mGenericParams, methodDeclaration->mGenericConstraintsDeclaration, methodDef->mGenericParams, &methodDef->mExternalConstraints, outerGenericSize); + + if ((methodDef->mMethodType == BfMethodType_Normal) || + (methodDef->mMethodType == BfMethodType_Operator) || + (methodDef->mMethodType == BfMethodType_Mixin)) + { + ParseGenericParams(methodDeclaration->mGenericParams, methodDeclaration->mGenericConstraintsDeclaration, methodDef->mGenericParams, &methodDef->mExternalConstraints, outerGenericSize); + } + else + { + if (methodDeclaration->mGenericParams != NULL) + Fail("Generic parameters are only allowed on normal methods", methodDeclaration->mGenericParams); + if (methodDeclaration->mGenericConstraintsDeclaration != NULL) + Fail("Generic constraints are only allowed on normal methods", methodDeclaration->mGenericConstraintsDeclaration); + } bool didDefaultsError = false; bool hadParams = false;