diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 2e40abf8317e6c289736f15c9d9f792682e9eb47..d89dd851913966afd1087118bc1f5e62974b129d 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -870,6 +870,7 @@ Signature *ETSChecker::FindMostSpecificSignature(const ArenaVector currentMinLength = result->Function()->Params().size(); } else if (candidateLength >= currentLength) { continue; + // NOTE (smartin): all other cases below are unreachable code } else if (!isGeneric(candidate) && isGeneric(result)) { result = candidate; } else if (isGeneric(candidate) && !isGeneric(result)) { @@ -950,6 +951,15 @@ void ETSChecker::SearchAmongMostSpecificTypes(Type *&mostSpecificType, Signature Relation()->SetNode(nullptr); return; } + + if (idx >= prevSig->MinArgCount() && idx < sig->MinArgCount()) { + // NOTE (smartin): prefer non-optional parameters over optional ones + Relation()->Result(true); + mostSpecificType = sigType; + prevSig = sig; + return; + } + if (isClassType && sigType->AsETSObjectType()->IsBoxedPrimitive() && mostSpecificType->IsETSObjectType() && mostSpecificType->AsETSObjectType()->IsBoxedPrimitive()) { // NOTE (smartin): when a param with type int is available, make it more specific than other primitive