Skip to content

Commit c098175

Browse files
committed
Add test case involving circular references with @Observable
Add a test case for Observable types that are extended from other source files. Prior to the recent changes to make `TypeRefinementContext` more lazy, this would trigger circular references through the `TypeRefinementContextBuilder`. Finishes rdar://112079160.
1 parent 0d779df commit c098175

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
import Observation
3+
4+
@available(SwiftStdlib 5.9, *)
5+
@Observable final public class ObservableClass {
6+
public var state: State = .unused
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// REQUIRES: swift_swift_parser
2+
3+
// RUN: %target-swift-frontend -typecheck -parse-as-library -enable-experimental-feature InitAccessors -external-plugin-path %swift-host-lib-dir/plugins#%swift-plugin-server -primary-file %s %S/Inputs/ObservableClass.swift
4+
5+
// RUN: %target-swift-frontend -typecheck -parse-as-library -enable-experimental-feature InitAccessors -external-plugin-path %swift-host-lib-dir/plugins#%swift-plugin-server %s -primary-file %S/Inputs/ObservableClass.swift
6+
7+
// REQUIRES: observation
8+
// REQUIRES: concurrency
9+
// REQUIRES: objc_interop
10+
// UNSUPPORTED: use_os_stdlib
11+
// UNSUPPORTED: back_deployment_runtime
12+
13+
@available(SwiftStdlib 5.9, *)
14+
extension ObservableClass {
15+
@frozen public enum State: Sendable {
16+
case unused
17+
case used
18+
}
19+
}

0 commit comments

Comments
 (0)