@@ -1060,9 +1060,10 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
10601060 switch state {
10611061 case . topLevel:
10621062 staticContext = nil
1063- case . classBody( let className , _ ) :
1063+ case . classBody( _ , let classKey ) :
10641064 if isStatic {
1065- staticContext = . className( className)
1065+ let classAbiName = exportedClassByName [ classKey] ? . abiName ?? " unknown "
1066+ staticContext = . className( classAbiName)
10661067 } else {
10671068 staticContext = nil
10681069 }
@@ -1077,20 +1078,21 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
10771078 staticContext = isNamespaceEnum ? . namespaceEnum( swiftCallName) : . enumName( enumName)
10781079 case . protocolBody( _, _) :
10791080 return nil
1080- case . structBody( let structName , _ ) :
1081+ case . structBody( _ , let structKey ) :
10811082 if isStatic {
1082- staticContext = . structName( structName)
1083+ let structAbiName = exportedStructByName [ structKey] ? . abiName ?? " unknown "
1084+ staticContext = . structName( structAbiName)
10831085 } else {
10841086 staticContext = nil
10851087 }
10861088 }
10871089
10881090 let classNameForABI : String ?
10891091 switch state {
1090- case . classBody( let className , _ ) :
1091- classNameForABI = className
1092- case . structBody( let structName , _ ) :
1093- classNameForABI = structName
1092+ case . classBody( _ , let classKey ) :
1093+ classNameForABI = exportedClassByName [ classKey ] ? . abiName
1094+ case . structBody( _ , let structKey ) :
1095+ classNameForABI = exportedStructByName [ structKey ] ? . abiName
10941096 default :
10951097 classNameForABI = nil
10961098 }
@@ -1179,7 +1181,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
11791181 guard let jsAttribute = node. attributes. firstJSAttribute else { return . skipChildren }
11801182
11811183 switch state {
1182- case . classBody( let className , let classKey) :
1184+ case . classBody( _ , let classKey) :
11831185 if extractNamespace ( from: jsAttribute) != nil {
11841186 diagnose (
11851187 node: jsAttribute,
@@ -1194,14 +1196,15 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
11941196 return . skipChildren
11951197 }
11961198
1199+ let classAbiName = exportedClassByName [ classKey] ? . abiName ?? " unknown "
11971200 let constructor = ExportedConstructor (
1198- abiName: " bjs_ \( className ) _init " ,
1201+ abiName: " bjs_ \( classAbiName ) _init " ,
11991202 parameters: parameters,
12001203 effects: effects
12011204 )
12021205 exportedClassByName [ classKey] ? . constructor = constructor
12031206
1204- case . structBody( let structName , let structKey) :
1207+ case . structBody( _ , let structKey) :
12051208 if extractNamespace ( from: jsAttribute) != nil {
12061209 diagnose (
12071210 node: jsAttribute,
@@ -1216,8 +1219,9 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
12161219 return . skipChildren
12171220 }
12181221
1222+ let structAbiName = exportedStructByName [ structKey] ? . abiName ?? " unknown "
12191223 let constructor = ExportedConstructor (
1220- abiName: " bjs_ \( structName ) _init " ,
1224+ abiName: " bjs_ \( structAbiName ) _init " ,
12211225 parameters: parameters,
12221226 effects: effects
12231227 )
@@ -1263,8 +1267,13 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
12631267 let staticContext : StaticContext ?
12641268
12651269 switch state {
1266- case . classBody( let className, _) :
1267- staticContext = isStatic ? . className( className) : nil
1270+ case . classBody( _, let classKey) :
1271+ if isStatic {
1272+ let classAbiName = exportedClassByName [ classKey] ? . abiName ?? " unknown "
1273+ staticContext = . className( classAbiName)
1274+ } else {
1275+ staticContext = nil
1276+ }
12681277 case . enumBody( let enumName, let enumKey) :
12691278 if !isStatic {
12701279 diagnose ( node: node, message: " Only static properties are supported in enums " )
@@ -1280,9 +1289,10 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
12801289 return . skipChildren
12811290 case . protocolBody( let protocolName, let protocolKey) :
12821291 return visitProtocolProperty ( node: node, protocolName: protocolName, protocolKey: protocolKey)
1283- case . structBody( let structName , _ ) :
1292+ case . structBody( _ , let structKey ) :
12841293 if isStatic {
1285- staticContext = . structName( structName)
1294+ let structAbiName = exportedStructByName [ structKey] ? . abiName ?? " unknown "
1295+ staticContext = . structName( structAbiName)
12861296 } else {
12871297 diagnose ( node: node, message: " @JS var must be static in structs (instance fields don't need @JS) " )
12881298 return . skipChildren
0 commit comments