Skip to content

Commit d8a6f2e

Browse files
authored
fixed resolving of inherited constants (#45)
1 parent c7e45ad commit d8a6f2e

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

server/src/e2e/suite/testcases/resolve/contracts.test

+15
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,18 @@ contract JettonMinter {
101101
6:12 -> 4:9 resolved
102102
7:13 -> 2:4 resolved
103103
8:12 -> 4:25 resolved
104+
105+
========================================================================
106+
Contract constant from trait
107+
========================================================================
108+
trait Foo {
109+
const FOO: Int = 100;
110+
}
111+
112+
contract JettonMinter with Foo {
113+
get fun foo(): Int {
114+
return self.<caret>FOO;
115+
}
116+
}
117+
------------------------------------------------------------------------
118+
6:20 -> 1:10 resolved

server/src/psi/Reference.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ export class Reference {
210210
if (methodRef) {
211211
if (!this.processNamedEls(proc, state, qualifierType.methods())) return false
212212
if (!this.processNamedEls(proc, state, qualifierType.ownFields())) return false
213-
if (!this.processNamedEls(proc, state, qualifierType.ownConstants())) return false
213+
if (!this.processNamedEls(proc, state, qualifierType.constants())) return false
214214
} else {
215215
if (!this.processNamedEls(proc, state, qualifierType.ownFields())) return false
216-
if (!this.processNamedEls(proc, state, qualifierType.ownConstants())) return false
216+
if (!this.processNamedEls(proc, state, qualifierType.constants())) return false
217217
if (!this.processNamedEls(proc, state, qualifierType.methods())) return false
218218
}
219219
}

server/src/types/BaseTy.ts

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export class StorageMembersOwnerTy<Anchor extends StorageMembersOwner> extends B
6666
return this.anchor.ownConstants()
6767
}
6868

69+
public constants(): Constant[] {
70+
if (this.anchor === null) return []
71+
return this.anchor.constants()
72+
}
73+
6974
public methods(): Fun[] {
7075
if (this.anchor === null) return []
7176
return this.anchor.methods()

0 commit comments

Comments
 (0)