Skip to content

public enum inaccessible due to @_spi isolation level #84710

@Drejzer

Description

@Drejzer

Description

Compiler considers a public enum(conforming to Hashable and Sendable) from a dependency as "inaccessible due to @_spi isolation level" when a case is not inferred (passed as EnumName.caseName).

This has come up with the wrapper for a C++ library that I'm working on, hence the dependency on it in the reproduction.

Reproduction

Create a fresh package using swift package init and add a dependency on PrivMXEndpointSwiftExtra and setting interoperability to .Cxx and setting cxxLangauageStandard to .cxx17:
Package.swift

//(Default package)

    dependencies:[
		.package(//path:"../privmx-endpoint-swift-extra")
			url:"https://github.com/simplito/privmx-endpoint-swift-extra",
			.upToNextMinor(from: .init(2, 6, 0,prereleaseIdentifiers: ["rc5"]))),
	],

// in target
            dependencies:[.product(name:"PrivMXEndpointSwiftExtra", package:"privmx-endpoint-swift-extra")],
            swiftSettings:[.interoperabilityMode(.Cxx),]
        ),
    ],
    cxxLanguageStandard: .cxx17
)

in the source:

class PrivMXSnippetClass {
	var endpointSession: PrivMXEndpoint?
	
	func handlingConnectionEvents(){
		//let x:PMXEventSubscriptionRequest //uncommenting this will make the errors go away
		
		
		// uncomment the call to change errors
		// shows "cannot be constructed because it has no accessible initializers
		// and cannot infer contextual base in reference to member 'library'
		//try? endpointSession?.registerCallback(
		//	for: .init(
		//		request:.library(eventType: LibEventType.LIB_CONNECTED),
		//		group: "Some_group"){_ in})
		
		try? endpointSession?.registerCallback(
			for: PMXEventCallbackRegistration.init(
				request:PMXEventSubscriptionRequest.core(
				//request:.core( //swap with above to remove error
					eventType: privmx.endpoint.core.USER_STATUS,
					contextId: "some_ID"),
				group: "Some_group"){_ in})
		try? endpointSession?.registerCallback(
			for: PMXEventCallbackRegistration.init(
				request:PMXEventSubscriptionRequest.thread(
					eventType: privmx.endpoint.thread.THREAD_UPDATE,
					selectorType: .Container,
					selectorId: "other_ID"),
				group: "Some_group"){_ in})
	}
}

Expected behavior

Code compiles

Environment

swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx26.0

Additional information

Forum thread: https://forums.swift.org/t/public-enum-inaccessible-due-to-spi-isolation-level-error/82499

Sometimes calling some other method (or in this case declaring an unused variable/constant of this type) before the problematic place makes the error disappear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions