Skip to content

Commit a88f64f

Browse files
committed
[NFC] BridgeJS: Remove added implementation and test comments
1 parent 19e0b1b commit a88f64f

6 files changed

Lines changed: 3 additions & 35 deletions

File tree

‎Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,14 +1478,6 @@ struct ProtocolCodegen {
14781478
externDecls.append(contentsOf: propertyExternDecls)
14791479
}
14801480

1481-
// The JS-backed implementations live on the protocol itself, constrained
1482-
// to wrapper types. A refining protocol's wrapper (`AnyC` for
1483-
// `C: A, B`) then satisfies A's and B's requirements through their
1484-
// extensions: Swift's conformance resolution does the "flattening",
1485-
// every extern stays owned by the protocol that declares the member,
1486-
// and a member the refining protocol re-declares resolves to the more
1487-
// specific extension. User conformers never see these defaults - they
1488-
// do not conform to `_BridgedSwiftProtocolWrapper`.
14891481
var decls: [DeclSyntax] = []
14901482
if !methodDecls.isEmpty || !propertyDecls.isEmpty {
14911483
let extensionPrinter = CodeFragmentPrinter()

‎Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3564,7 +3564,7 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor {
35643564

35653565
// MARK: - Parsing Methods
35663566

3567-
/// Validates and collects the generic parameters of an imported
3567+
/// Validates and collects the generic parameter names of an imported
35683568
/// `@JSFunction` declaration (function, method or initializer).
35693569
///
35703570
/// Returns `nil` when a diagnostic was emitted; an empty array when the

‎Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,6 @@ public struct BridgeJSLink {
10211021
for skeleton in exportedSkeletons {
10221022
for proto in skeleton.protocols {
10231023
printer.write(lines: renderJSDoc(documentation: proto.documentation, parameters: []))
1024-
// Inherited requirements come from `extends`, mirroring the Swift
1025-
// side where the refining wrapper picks them up from the base
1026-
// protocols' extensions.
10271024
let extendsClause =
10281025
inheritedProtocolTSNames(of: proto, in: exportedSkeletons)
10291026
.map { " extends \($0.joined(separator: ", "))" } ?? ""
@@ -1687,9 +1684,6 @@ public struct BridgeJSLink {
16871684
}
16881685
}
16891686

1690-
/// Resolves public TypeScript names without changing the skeleton's Swift type identities.
1691-
/// TypeScript names of the `@JS` protocols `proto` refines, resolved across
1692-
/// every linked skeleton so a renamed base protocol renders as its JS name.
16931687
private func inheritedProtocolTSNames(of proto: ExportedProtocol, in skeletons: [ExportedSkeleton]) -> [String]? {
16941688
guard let inherited = proto.inheritedJSProtocols, !inherited.isEmpty else { return nil }
16951689
return inherited.map { baseName in
@@ -1702,6 +1696,7 @@ public struct BridgeJSLink {
17021696
}
17031697
}
17041698

1699+
/// Resolves public TypeScript names without changing the skeleton's Swift type identities.
17051700
private func resolveTypeScriptType(_ type: BridgeType) -> String {
17061701
return Self.resolveTypeScriptType(type, exportedSkeletons: skeletons.compactMap(\.exported))
17071702
}

‎Plugins/BridgeJS/Tests/BridgeJSToolTests/GenericImportDiagnosticsTests.swift‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ import Testing
6262
)
6363
let exported = try #require(skeleton.exported)
6464
let node = try #require(exported.protocols.first { $0.name == "Node" })
65-
// The skeleton records only what each protocol declares plus the
66-
// refinement edge; inherited requirements are not copied.
6765
#expect(node.methods.isEmpty)
6866
#expect(node.properties.map(\.name) == ["value"])
6967
#expect(node.inheritedJSProtocols == ["Middle"])
@@ -76,12 +74,9 @@ import Testing
7674
let glue = try #require(
7775
try ExportSwift(progress: .silent, moduleName: skeleton.moduleName, skeleton: exported).finalize()
7876
)
79-
// Implementations live on the declaring protocol, constrained to
80-
// wrappers, so AnyNode inherits Base's `read`/`value` through the
81-
// extension instead of carrying copies with re-namespaced externs.
8277
#expect(glue.contains("extension Base where Self: _BridgedSwiftProtocolWrapper {"))
8378
#expect(glue.contains("extension Node where Self: _BridgedSwiftProtocolWrapper {"))
84-
#expect(!glue.contains("extension Middle where Self")) // nothing declared, nothing emitted
79+
#expect(!glue.contains("extension Middle where Self"))
8580
#expect(glue.contains("struct AnyNode: Node, _BridgedSwiftProtocolWrapper {"))
8681
#expect(glue.contains("name: \"bjs_Base_read\""))
8782
#expect(!glue.contains("bjs_Node_read"))

‎Tests/BridgeJSRuntimeTests/ImportGenericAPIs.swift‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,6 @@ extension GenericRTPoint: GenericRTNode {
306306
}
307307
}
308308

309-
// Protocol refinement is resolved by Swift, not by copying members: the
310-
// wrapper for a refining protocol picks up inherited requirements from the
311-
// base protocols' constrained extensions. This fixture covers the shapes
312-
// that used to need special handling in the generator: two parents, a
313-
// member re-declared by the refiner, and a `{ get set }` requirement
314-
// inherited unchanged. (Re-declaring an inherited `{ get set }` as `{ get }`
315-
// is rejected by Swift itself, so the generator never sees it.)
316309
@JS protocol RefineIdentified {
317310
var id: String { get }
318311
var score: Int { get set }
@@ -329,15 +322,11 @@ extension GenericRTPoint: GenericRTNode {
329322
}
330323

331324
@JS func describeRefinedEntity(_ entity: RefineEntity) -> String {
332-
// `id` and `label()` resolve to RefineEntity's extension (most specific);
333-
// `score` and its setter come from RefineIdentified's.
334325
var identified: any RefineIdentified = entity
335326
identified.score = entity.score + 1
336327
return "\(entity.id):\(entity.name):\(entity.label()):\(identified.score)"
337328
}
338329

339-
// A refining protocol with no requirements of its own emits no extension;
340-
// its wrapper still conforms through the parents' extensions.
341330
@JS protocol RefineTagged: RefineEntity {}
342331

343332
@JS func describeTaggedEntity(_ entity: RefineTagged) -> String {

‎Tests/prelude.mjs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ function BridgeJSRuntimeTests_runJsWorks(instance, exports) {
301301
const optDict = { hello: "world" };
302302
assert.deepEqual(exports.roundTripOptionalDictionaryExport(optDict), optDict);
303303
assert.equal(exports.roundTripOptionalDictionaryExport(null), null);
304-
// @JS protocol refinement: one JS object satisfies the refined protocol
305-
// and both of its parents; the Swift side reads inherited members and
306-
// writes the inherited settable one.
307304
const entity = { id: "e1", name: "Main", score: 10, label() { return "L" + this.score; } };
308305
assert.equal(exports.describeRefinedEntity(entity), "e1:Main:L11:11");
309306
assert.equal(entity.score, 11);

0 commit comments

Comments
 (0)