Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fixed resolving of inherited constants #45

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions server/src/e2e/suite/testcases/resolve/contracts.test
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,18 @@ contract JettonMinter {
6:12 -> 4:9 resolved
7:13 -> 2:4 resolved
8:12 -> 4:25 resolved

========================================================================
Contract constant from trait
========================================================================
trait Foo {
const FOO: Int = 100;
}

contract JettonMinter with Foo {
get fun foo(): Int {
return self.<caret>FOO;
}
}
------------------------------------------------------------------------
6:20 -> 1:10 resolved
4 changes: 2 additions & 2 deletions server/src/psi/Reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ export class Reference {
if (methodRef) {
if (!this.processNamedEls(proc, state, qualifierType.methods())) return false
if (!this.processNamedEls(proc, state, qualifierType.ownFields())) return false
if (!this.processNamedEls(proc, state, qualifierType.ownConstants())) return false
if (!this.processNamedEls(proc, state, qualifierType.constants())) return false
} else {
if (!this.processNamedEls(proc, state, qualifierType.ownFields())) return false
if (!this.processNamedEls(proc, state, qualifierType.ownConstants())) return false
if (!this.processNamedEls(proc, state, qualifierType.constants())) return false
if (!this.processNamedEls(proc, state, qualifierType.methods())) return false
}
}
Expand Down
5 changes: 5 additions & 0 deletions server/src/types/BaseTy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export class StorageMembersOwnerTy<Anchor extends StorageMembersOwner> extends B
return this.anchor.ownConstants()
}

public constants(): Constant[] {
if (this.anchor === null) return []
return this.anchor.constants()
}

public methods(): Fun[] {
if (this.anchor === null) return []
return this.anchor.methods()
Expand Down