Skip to content

Commit

Permalink
[cleanup] Static calls are already checked.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfusik committed Jun 27, 2024
1 parent fa5cf71 commit 73f302a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Sema.fu
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,6 @@ public class FuSema
return PoisonError(symbol, "Expected a method");
}

// TODO: check static
if (!method.IsStatic() && method.IsMutator()) {
if (symbol.Left == null) {
if (!this.CurrentMethod.IsMutator())
Expand Down Expand Up @@ -1367,7 +1366,7 @@ public class FuSema

symbol.Symbol = method;

if (method.CallType == FuCallType.Static
if (method.IsStatic()
&& method.Body is FuReturn! ret
&& arguments.All(arg => arg is FuLiteral)
&& !this.CurrentPureMethods.Contains(method)) {
Expand Down
2 changes: 1 addition & 1 deletion libfut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5870,7 +5870,7 @@ std::shared_ptr<FuExpr> FuSema::resolveCallWithArguments(std::shared_ptr<FuCallE
}
symbol->symbol = method;
FuReturn * ret;
if (method->callType == FuCallType::static_ && (ret = dynamic_cast<FuReturn *>(method->body.get())) && std::all_of(arguments->begin(), arguments->end(), [](const std::shared_ptr<FuExpr> &arg) { return dynamic_cast<const FuLiteral *>(arg.get()); }) && !this->currentPureMethods.contains(method)) {
if (method->isStatic() && (ret = dynamic_cast<FuReturn *>(method->body.get())) && std::all_of(arguments->begin(), arguments->end(), [](const std::shared_ptr<FuExpr> &arg) { return dynamic_cast<const FuLiteral *>(arg.get()); }) && !this->currentPureMethods.contains(method)) {
this->currentPureMethods.insert(method);
i = 0;
for (const FuVar * param = method->firstParameter(); param != nullptr; param = param->nextVar()) {
Expand Down
2 changes: 1 addition & 1 deletion libfut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5975,7 +5975,7 @@ FuExpr ResolveCallWithArguments(FuCallExpr expr, List<FuExpr> arguments)
ReportError(expr.Method, $"Method marked 'throws {exception.Name}' called from a method without it");
}
symbol.Symbol = method;
if (method.CallType == FuCallType.Static && method.Body is FuReturn ret && arguments.TrueForAll(arg => arg is FuLiteral) && !this.CurrentPureMethods.Contains(method)) {
if (method.IsStatic() && method.Body is FuReturn ret && arguments.TrueForAll(arg => arg is FuLiteral) && !this.CurrentPureMethods.Contains(method)) {
this.CurrentPureMethods.Add(method);
i = 0;
for (FuVar param = method.FirstParameter(); param != null; param = param.NextVar()) {
Expand Down
2 changes: 1 addition & 1 deletion libfut.js
Original file line number Diff line number Diff line change
Expand Up @@ -6298,7 +6298,7 @@ export class FuSema
}
symbol.symbol = method;
let ret;
if (method.callType == FuCallType.STATIC && (ret = method.body) instanceof FuReturn && arguments_.every(arg => arg instanceof FuLiteral) && !this.#currentPureMethods.has(method)) {
if (method.isStatic() && (ret = method.body) instanceof FuReturn && arguments_.every(arg => arg instanceof FuLiteral) && !this.#currentPureMethods.has(method)) {
this.#currentPureMethods.add(method);
i = 0;
for (let param = method.firstParameter(); param != null; param = param.nextVar()) {
Expand Down

0 comments on commit 73f302a

Please sign in to comment.