Skip to content

Commit

Permalink
[sema] Fix interpolated string with a forward-referenced class argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfusik committed Mar 23, 2024
1 parent 30f58a1 commit 3036fd2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Sema.fu
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,8 @@ public class FuSema
method.Type = this.Host.Program.System.VoidType;
else
ResolveType(method);
if (method.Name == "ToString" && method.CallType != FuCallType.Static && method.Parameters.Count() == 1)
method.Id = FuId.ClassToString;
for (FuVar!? param = method.FirstParameter(); param != null; param = param.NextVar()) {
ResolveType(param);
if (param.Value != null) {
Expand Down Expand Up @@ -2213,8 +2215,6 @@ public class FuSema
}
break;
case FuMethod! method:
if (method.Name == "ToString" && method.CallType != FuCallType.Static && method.Parameters.Count() == 1)
method.Id = FuId.ClassToString;
if (method.Body != null) {
if (method.CallType == FuCallType.Override || method.CallType == FuCallType.Sealed) {
if (klass.Parent.TryLookup(method.Name, false) is FuMethod! baseMethod) {
Expand Down
4 changes: 2 additions & 2 deletions libfut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6515,6 +6515,8 @@ void FuSema::resolveTypes(FuClass * klass)
method->type = this->host->program->system->voidType;
else
resolveType(method);
if (method->name == "ToString" && method->callType != FuCallType::static_ && method->parameters.count() == 1)
method->id = FuId::classToString;
for (FuVar * param = method->firstParameter(); param != nullptr; param = param->nextVar()) {
resolveType(param);
if (param->value != nullptr) {
Expand Down Expand Up @@ -6581,8 +6583,6 @@ void FuSema::resolveCode(FuClass * klass)
}
}
else if (FuMethod *method = dynamic_cast<FuMethod *>(symbol)) {
if (method->name == "ToString" && method->callType != FuCallType::static_ && method->parameters.count() == 1)
method->id = FuId::classToString;
if (method->body != nullptr) {
if (method->callType == FuCallType::override_ || method->callType == FuCallType::sealed) {
if (FuMethod *baseMethod = dynamic_cast<FuMethod *>(klass->parent->tryLookup(method->name, false).get())) {
Expand Down
4 changes: 2 additions & 2 deletions libfut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6612,6 +6612,8 @@ void ResolveTypes(FuClass klass)
method.Type = this.Host.Program.System.VoidType;
else
ResolveType(method);
if (method.Name == "ToString" && method.CallType != FuCallType.Static && method.Parameters.Count() == 1)
method.Id = FuId.ClassToString;
for (FuVar param = method.FirstParameter(); param != null; param = param.NextVar()) {
ResolveType(param);
if (param.Value != null) {
Expand Down Expand Up @@ -6677,8 +6679,6 @@ void ResolveCode(FuClass klass)
}
break;
case FuMethod method:
if (method.Name == "ToString" && method.CallType != FuCallType.Static && method.Parameters.Count() == 1)
method.Id = FuId.ClassToString;
if (method.Body != null) {
if (method.CallType == FuCallType.Override || method.CallType == FuCallType.Sealed) {
if (klass.Parent.TryLookup(method.Name, false) is FuMethod baseMethod) {
Expand Down
4 changes: 2 additions & 2 deletions libfut.js
Original file line number Diff line number Diff line change
Expand Up @@ -6977,6 +6977,8 @@ export class FuSema
method.type = this.#host.program.system.voidType;
else
this.#resolveType(method);
if (method.name == "ToString" && method.callType != FuCallType.STATIC && method.parameters.count() == 1)
method.id = FuId.CLASS_TO_STRING;
for (let param = method.firstParameter(); param != null; param = param.nextVar()) {
this.#resolveType(param);
if (param.value != null) {
Expand Down Expand Up @@ -7043,8 +7045,6 @@ export class FuSema
}
else if (symbol instanceof FuMethod) {
const method = symbol;
if (method.name == "ToString" && method.callType != FuCallType.STATIC && method.parameters.count() == 1)
method.id = FuId.CLASS_TO_STRING;
if (method.body != null) {
if (method.callType == FuCallType.OVERRIDE || method.callType == FuCallType.SEALED) {
let baseMethod;
Expand Down

0 comments on commit 3036fd2

Please sign in to comment.