mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Embedded] Downgrade type-checker error about non-final generic class methods to a warning
The existing SIL-level diagnostic for this check only triggers when the type is actually used, while the type-checker version is more eager. Stage in the stricter check as a warning and we'll clamp down on things later.
This commit is contained in:
@@ -8612,9 +8612,10 @@ GROUPED_ERROR(weak_unowned_in_embedded_swift, EmbeddedRestrictions, none,
|
||||
GROUPED_WARNING(untyped_throws_in_embedded_swift, EmbeddedRestrictions,
|
||||
DefaultIgnore,
|
||||
"untyped throws is not available in Embedded Swift; add a thrown error type with '(type)'", ())
|
||||
GROUPED_ERROR(generic_nonfinal_in_embedded_swift, EmbeddedRestrictions, none,
|
||||
"generic %kind0 in a class %select{must be 'final'|cannot be 'required'}1 in Embedded Swift",
|
||||
(const Decl *, bool))
|
||||
GROUPED_WARNING(generic_nonfinal_in_embedded_swift, EmbeddedRestrictions,
|
||||
DefaultIgnore,
|
||||
"generic %kind0 in a class %select{must be 'final'|cannot be 'required'}1 in Embedded Swift",
|
||||
(const Decl *, bool))
|
||||
GROUPED_WARNING(use_generic_member_of_existential_in_embedded_swift,
|
||||
EmbeddedRestrictions, DefaultIgnore,
|
||||
"cannot use generic %kind0 on a value of type %1 in Embedded Swift",
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
// REQUIRES: swift_feature_Embedded
|
||||
|
||||
public class MyClass {
|
||||
public func foo<T>(t: T) { } // expected-error {{generic instance method 'foo(t:)' in a class must be 'final' in Embedded Swift}}
|
||||
public func foo<T>(t: T) { } // expected-warning {{generic instance method 'foo(t:)' in a class must be 'final' in Embedded Swift}}
|
||||
// expected-error@-1{{classes cannot have a non-final, generic method 'foo(t:)' in embedded Swift}}
|
||||
public func bar() { }
|
||||
}
|
||||
|
||||
@@ -24,7 +25,8 @@ func testit2() -> C2<S> {
|
||||
}
|
||||
|
||||
open class C3<X> {
|
||||
public func foo<T>(t: T) {} // expected-error {{generic instance method 'foo(t:)' in a class must be 'final' in Embedded Swift}}
|
||||
public func foo<T>(t: T) {} // expected-warning {{generic instance method 'foo(t:)' in a class must be 'final' in Embedded Swift}}
|
||||
// expected-error@-1{{classes cannot have a non-final, generic method 'foo(t:)' in embedded Swift}}
|
||||
}
|
||||
|
||||
func testit3() -> C3<S> {
|
||||
|
||||
@@ -71,18 +71,15 @@ public struct MyStruct {
|
||||
protocol P { }
|
||||
|
||||
class MyGenericClass<T> {
|
||||
func f<U>(value: U) { } // expected-nonembedded-warning{{generic instance method 'f(value:)' in a class must be 'final' in Embedded Swift}}
|
||||
// expected-embedded-error@-1{{generic instance method 'f(value:)' in a class must be 'final' in Embedded Swift}}
|
||||
func f<U>(value: U) { } // expected-warning{{generic instance method 'f(value:)' in a class must be 'final' in Embedded Swift}}
|
||||
func g() { }
|
||||
class func h() where T: P { } // expected-nonembedded-warning{{generic class method 'h()' in a class must be 'final' in Embedded Swift}}
|
||||
// expected-embedded-error@-1{{generic class method 'h()' in a class must be 'final' in Embedded Swift}}
|
||||
class func h() where T: P { } // expected-warning{{generic class method 'h()' in a class must be 'final' in Embedded Swift}}
|
||||
|
||||
init<U>(value: U) { } // okay, can be directly called
|
||||
|
||||
required init() { } // non-generic is okay
|
||||
|
||||
required init<V>(something: V) { } // expected-nonembedded-warning{{generic initializer 'init(something:)' in a class cannot be 'required' in Embedded Swift}}
|
||||
// expected-embedded-error@-1{{generic initializer 'init(something:)' in a class cannot be 'required' in Embedded Swift}}
|
||||
required init<V>(something: V) { } // expected-warning{{generic initializer 'init(something:)' in a class cannot be 'required' in Embedded Swift}}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user