Skip to content

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Oct 27, 2025

  • fix the compiler dropping forward-referenced smart contracts by collecting
    all smart contract symbols before building the dependency graph
  • rebuild the dependency list using symbol equality so members referencing
    contracts declared later are preserved and _nonDependencies cannot trim
    required types
  • guard against duplicate and abstract dependency entries while keeping the
    rest of the compilation flow unchanged

Issue:
CompilationEngine only added a smart contract to classDependencies after it
had already been visited, so a field or property that pointed to a contract
declared later looked like a plain class reference. When _nonDependencies
ran, those untracked contracts were considered foreign and stripped from the
compilation context, leading to partial NEF output in multi-contract projects.

Fix Details:
The change executes two passes over the syntax trees:

  1. Record every public, non-abstract type that derives from SmartContract.
  2. For each of those contracts, walk its members and add any referenced smart
    contract symbol to the dependency list, deduplicating and skipping abstract
    types.

This ensures the subsequent topological sort sees the full dependency graph
regardless of declaration order, so every required contract is compiled and
emitted.


foreach (var classSymbol in classSymbols)
{
if (!allSmartContracts.Contains(classSymbol))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check if it's abstract here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @Jim8y

ajara87
ajara87 previously approved these changes Oct 27, 2025
@Wi1l-B0t
Copy link
Contributor

Any test for this ?
How to test this ?

@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 5, 2025

Any test for this ? How to test this ?

this is hard to be tested.... cuase it will be related to multiple contract situations. This is not a serious issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants