Fix instance-call diagnostics and declaring scope for static methods
Build / AerScript (push) Successful in 38s
Build / AerScript (push) Successful in 38s
This commit is contained in:
+12
-3
@@ -1111,7 +1111,7 @@ static ph7_vm_func *VmOverload(
|
|||||||
sxi32 bInternal /* VM-invoked methods already have an access context */
|
sxi32 bInternal /* VM-invoked methods already have an access context */
|
||||||
) {
|
) {
|
||||||
sxu32 iTarget, j, k, iArgs, nCandidates, nCompatible, nCols, nPassed;
|
sxu32 iTarget, j, k, iArgs, nCandidates, nCompatible, nCols, nPassed;
|
||||||
sxi32 bDominated;
|
sxi32 bDominated, bInstanceOnly = 0;
|
||||||
ph7_vm_func **apSet;
|
ph7_vm_func **apSet;
|
||||||
ph7_vm_func *pLink;
|
ph7_vm_func *pLink;
|
||||||
ph7_vm_func_arg *pFuncArg;
|
ph7_vm_func_arg *pFuncArg;
|
||||||
@@ -1160,10 +1160,13 @@ static ph7_vm_func *VmOverload(
|
|||||||
for(pLink = pEntry ? (ph7_vm_func *)pEntry->pUserData : 0; pLink; pLink = pLink->pNextName) {
|
for(pLink = pEntry ? (ph7_vm_func *)pEntry->pUserData : 0; pLink; pLink = pLink->pNextName) {
|
||||||
pMeth = (ph7_class_method *)pLink;
|
pMeth = (ph7_class_method *)pLink;
|
||||||
if((pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL) ||
|
if((pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL) ||
|
||||||
(bStatic && !(pMeth->iFlags & PH7_CLASS_ATTR_STATIC)) ||
|
|
||||||
(!bInternal && !VmClassMemberAccess(pVm, pLink->pClass, pMeth->iProtection))) {
|
(!bInternal && !VmClassMemberAccess(pVm, pLink->pClass, pMeth->iProtection))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(bStatic && !(pMeth->iFlags & PH7_CLASS_ATTR_STATIC)) {
|
||||||
|
bInstanceOnly = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for(k = 0; k < SySetUsed(&sMethods); k++) {
|
for(k = 0; k < SySetUsed(&sMethods); k++) {
|
||||||
if(PH7_VmSameSignature(pLink, *(ph7_vm_func **)SySetAt(&sMethods, k))) {
|
if(PH7_VmSameSignature(pLink, *(ph7_vm_func **)SySetAt(&sMethods, k))) {
|
||||||
break;
|
break;
|
||||||
@@ -1181,6 +1184,11 @@ static ph7_vm_func *VmOverload(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(bInstanceOnly && SySetUsed(&sMethods) < 1) {
|
||||||
|
SySetRelease(&sMethods);
|
||||||
|
SySetRelease(&sSet);
|
||||||
|
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Instance method '%z()' requires an object", &pList->sName);
|
||||||
|
}
|
||||||
/* Put functions whose arguments are compatible with the current call */
|
/* Put functions whose arguments are compatible with the current call */
|
||||||
for(iMethod = 0; iMethod < SySetUsed(&sMethods); iMethod++) {
|
for(iMethod = 0; iMethod < SySetUsed(&sMethods); iMethod++) {
|
||||||
pLink = *(ph7_vm_func **)SySetAt(&sMethods, iMethod);
|
pLink = *(ph7_vm_func **)SySetAt(&sMethods, iMethod);
|
||||||
@@ -5743,7 +5751,8 @@ Resume:
|
|||||||
} else {
|
} else {
|
||||||
pVmFunc = (ph7_vm_func *)pInstr->p3;
|
pVmFunc = (ph7_vm_func *)pInstr->p3;
|
||||||
}
|
}
|
||||||
if(pThis && (pVmFunc->iFlags & VM_FUNC_CLASS_METHOD)) {
|
/* The selected declaration owns the scope, even without a receiver. */
|
||||||
|
if(pVmFunc->iFlags & VM_FUNC_CLASS_METHOD) {
|
||||||
pSelf = pVmFunc->pClass;
|
pSelf = pVmFunc->pClass;
|
||||||
}
|
}
|
||||||
if(pVmFunc->iFlags & VM_FUNC_CLOSURE) {
|
if(pVmFunc->iFlags & VM_FUNC_CLOSURE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user