Completely disallow static methods in interfaces.
All checks were successful
The build was successful.
All checks were successful
The build was successful.
This commit is contained in:
parent
984429bc55
commit
cd9ff68ae9
|
@ -3417,11 +3417,6 @@ static sxi32 PH7_GenStateCompileClassMethod(
|
||||||
/* Assemble method signature only */
|
/* Assemble method signature only */
|
||||||
doBody = FALSE;
|
doBody = FALSE;
|
||||||
}
|
}
|
||||||
if(iFlags & PH7_CLASS_ATTR_STATIC && pClass->iFlags & PH7_CLASS_INTERFACE) {
|
|
||||||
PH7_GenCompileError(pGen, E_ERROR, nLine,
|
|
||||||
"A method '%z::%z()' cannot be declared as static in an interface",
|
|
||||||
&pClass->sName, pName);
|
|
||||||
}
|
|
||||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_LPAREN) == 0) {
|
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_LPAREN) == 0) {
|
||||||
/* Syntax error */
|
/* Syntax error */
|
||||||
PH7_GenCompileError(pGen, E_ERROR, nLine, "Expected '(' after method name '%z::%z()'", &pClass->sName, pName);
|
PH7_GenCompileError(pGen, E_ERROR, nLine, "Expected '(' after method name '%z::%z()'", &pClass->sName, pName);
|
||||||
|
@ -3614,27 +3609,9 @@ static sxi32 PH7_CompileClassInterface(ph7_gen_state *pGen) {
|
||||||
} else {
|
} else {
|
||||||
sxi32 iFlags = 0;
|
sxi32 iFlags = 0;
|
||||||
if(nKwrd == PH7_KEYWORD_STATIC) {
|
if(nKwrd == PH7_KEYWORD_STATIC) {
|
||||||
/* Static method,record that */
|
PH7_GenCompileError(pGen, E_ERROR, nLine,
|
||||||
iFlags |= PH7_CLASS_ATTR_STATIC;
|
"Cannot declare a static method in an interface '%z'",
|
||||||
/* Advance the stream cursor */
|
pName);
|
||||||
pGen->pIn++;
|
|
||||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_KEYWORD) == 0) {
|
|
||||||
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine,
|
|
||||||
"Expecting method signature inside interface '%z'", pName);
|
|
||||||
}
|
|
||||||
/* Extract the keyword */
|
|
||||||
nKwrd = SX_PTR_TO_INT(pGen->pIn->pUserData);
|
|
||||||
if(nKwrd == PH7_KEYWORD_PRIVATE || nKwrd == PH7_KEYWORD_PROTECTED) {
|
|
||||||
/* Emit a warning and switch to public visibility */
|
|
||||||
PH7_GenCompileError(&(*pGen), E_WARNING, pGen->pIn->nLine, "interface: Access type must be public");
|
|
||||||
nKwrd = PH7_KEYWORD_PUBLIC;
|
|
||||||
}
|
|
||||||
if(nKwrd == PH7_KEYWORD_PUBLIC) {
|
|
||||||
/* Advance the stream cursor */
|
|
||||||
pGen->pIn++;
|
|
||||||
/* Extract the keyword */
|
|
||||||
nKwrd = SX_PTR_TO_INT(pGen->pIn->pUserData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if((nKwrd & PH7_KEYWORD_TYPEDEF) == 0) {
|
if((nKwrd & PH7_KEYWORD_TYPEDEF) == 0) {
|
||||||
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine,
|
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user