Skip to content

References to @JS annotated objects in other Swift files may fail #487

@krodak

Description

@krodak

Issue

When processing multiple Swift files with @js annotations, BridgeJS fails to resolve type references to classes defined in other files.

  // ClassA.swift
  @JS class ClassA {
      @JS var linkedB: ClassB?  // Error triggered here
  }

  // ClassB.swift
  @JS class ClassB {
      @JS init() {}
  }

Error:

// error: Unsupported type: ClassB
Hint: Only primitive types and types defined in the same module are allowed

Root Cause

ExportSwift.addSourceFile() immediately parses each file when called. Type resolution happens during parsing, but typeDeclResolver only knows about types from files already processed, so the process depends on files order, which it shouldn't.

If files are processed in alphabetical order (ClassA.swift before ClassB.swift), ClassA references ClassB before it's registered.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions