Comments (4)
Everything I'm seeing indicates that when SE-0316 (which defines global actors, such as the main actor) gives the following criteria for when a class can be annotated with a global actor:
A class can only be annotated with a global actor if it has no superclass, the superclass is annotated with the same global actor, or the superclass is NSObject. A subclass of a global-actor-annotated class must be isolated to the same global actor.
What it actually means is that, you can annotate a subclass with a global actor, but unless the above criteria is met, then only methods on that subclass will run on the global actor.
Additionally, I think the "superclass is NSObject" criteria is also misleading, and on Apple platforms means "the superclass is implemented in Objective-C".
My evidence for this is based on the fact that the SPM version of Quick has QuickSpec.spec defined in Swift, but the Cocoapods version of Quick has QuickSpec.spec defined in Objective-C. The following sample code should also demonstrate the issue. (which I wrote off the top of my head and have not verified if it compiles - I imagine there's weird completionHandler -> async in subclass thing that's probably invalid with the compiler. Regardless, you get the idea, I hope):
@interface ObjcBaseClass: NSObject
- (void)someMethod:(void (^)(void))completionHandler;
@end
@implementation ObjcBaseClass
- (void)someMethod:(void (^)(void))completionHandler { completionHandler(); }
@end
class SwiftBaseClass {
func someMethod() async {}
}
@MainActor class SwiftSubClass: SwiftBaseClass {
override func someMethod() async {
assert(NSThread.isMainThread) // this assert will almost certainly fail.
}
}
@MainActor class ObjcSubClass: ObjcBaseClass {
override func someMethod() {
assert(NSThread.isMainThread) // this assert will never fail.
}
}
I have not filed any feedbacks/swift bugs based off this observation. I assume that the cocoapods version of Quick is relying on undefined behavior, so a feedback wouldn't be all that helpful anyway.
from quick.
This is a known issue. I don't have a good solution for it. I'm sorry.
from quick.
I'm trying to find more information about this issue and could not find anything. Are there discussions or open bugs (in this project or another) elaborating why this doesn't work in SPM?
EDIT: after some browsing I was able to find some of issues that were previously raised. Linking them here for posterity:
It's not clear to me yet why the behavior is so different when using SPM, I'll keep digging a bit more and update this post if I find anything.
from quick.
Thank you very much for the detailed explanation and the link @younata , I wasn't aware of the difference in the implementation used between SPM and Cocoapods but now it makes perfect sense.
from quick.
Related Issues (20)
- Is this framework support SwiftUI Unit / UI testing ? HOT 1
- Mutation of captured var 'ocean' in concurrently-executing code HOT 1
- Framework in the release assets doesn't work on Apple Silicon Macs. HOT 6
- `configure(_:)` on a `QuickConfiguration` subclass is not called when you do not have any `QuickSpec`s or `AsyncSpec`s.
- Add visionOS support HOT 3
- Instance member '' cannot be used on type ''
- 'afterEach' cannot be used inside 'it', 'afterEach' may only be used inside 'context' or 'describe' HOT 2
- When testing a class with `@MainActor` annotation the `QuickSpec` doesn't work HOT 1
- Privacy Manifest
- Sometimes TestState crashes for AsyncSpec HOT 1
- Release 7.3.1 is not available through cocoapods source repo/CDN HOT 1
- XCTestPlan with "Automatically include new tests" unchecked HOT 1
- Can't Override Method Spec() HOT 3
- .from in .whereIn subquery incorrectly results in parent entity table HOT 2
- Does Quick support DocC generation?
- Is Carthage no longer supported? HOT 8
- Investigate parallelizing test discovery
- `sharedExamples` not available in `AsyncDSLUser` HOT 1
- quick/nimble test case grouping question HOT 2
- Use of undeclared identifier 'World'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quick.