Files
swift-mirror/test/embedded/weak-unowned.swift
Doug Gregor 7d21bc332a [Embedded] Diagnose untyped throws as an Embedded Swift restriction
Untyped throws depends on existentials (`any Error`), and is therefore
not available in Embedded Swift. Introduce a diagnostic that diagnoses
any use of untyped throws, suggesting that one use typed throws
instead.

Make this an opt-in diagnostic enabled with `-Wwarning
EmbeddedRestrictions`, whether in Embedded Swift or not, using the
"default ignore" flag on these new warnings. Document this new
diagnostic group, and put the existing Embedded Swift error about
weak/unowned references in it as well.

Part of the general push to have the type checker identify code that
will not compile as Embedded Swift earlier, rdar://133874555.
2025-09-14 21:48:50 -07:00

17 lines
588 B
Swift

// RUN: %target-swift-emit-ir %s -wmo
// RUN: %target-swift-emit-ir %s -enable-experimental-feature Embedded -verify
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: swift_feature_Embedded
public class MyClass { }
public struct MyStruct {
var normalVar: MyClass
weak var weakVar: MyClass? // expected-error {{attribute 'weak' cannot be used in Embedded Swift}}
unowned var unownedVar: MyClass // expected-error {{attribute 'unowned' cannot be used in Embedded Swift}}
unowned(unsafe) var unownedUnsafe: MyClass
}