mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
For Swift 3 / 4: Deprecate the spelling "ImplicitlyUnwrappedOptional", emitting a warning and suggesting "!" in places where they are allowed according to SE-0054. In places where SE-0054 disallowed IUOs but we continued to accept them in previous compilers, emit a warning suggesting "Optional" or "?" as an alternative depending on context and treat the IUO as an Optional, noting this in the diagnostic. For Swift 5: Treat "ImplicitlyUnwrappedOptional" as an error, suggesting "!" in places where they are allowed by SE-0054. In places where SE-0054 disallowed IUOs, emit an error suggestion "Optional" or "?" as an alternative depending on context.
63 lines
3.5 KiB
Plaintext
63 lines
3.5 KiB
Plaintext
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -generic-specializer -module-name inherit | %FileCheck %s
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
class MMFont {
|
|
}
|
|
|
|
struct MMStorage<Key : Hashable, Value> {
|
|
}
|
|
|
|
func ==(lhs: MMObject, rhs: MMObject) -> Bool
|
|
|
|
class MMObject : Hashable {
|
|
var hashValue: Int { get }
|
|
}
|
|
|
|
class MMString : MMObject {
|
|
}
|
|
|
|
// CHECK-LABEL: @caller : $@convention(thin) (Int, Int) -> @owned MMStorage<MMString, Optional<MMFont>> {
|
|
sil @caller : $@convention(thin) (Int, Int) -> @owned MMStorage<MMString, Optional<MMFont>> {
|
|
bb0(%0 : $Int, %1 : $Int):
|
|
%3 = metatype $@thin MMStorage<MMString, Optional<MMFont>>.Type
|
|
%13 = function_ref @ext_fn1 : $@convention(thin) (Int, @thin MMStorage<MMString, Optional<MMFont>>.Type) -> @owned MMStorage<MMString, Optional<MMFont>>
|
|
%14 = apply %13(%0, %3) : $@convention(thin) (Int, @thin MMStorage<MMString, Optional<MMFont>>.Type) -> @owned MMStorage<MMString, Optional<MMFont>>
|
|
|
|
// CHECK: [[STACK:%[0-9]+]] = alloc_stack $MMString
|
|
%37 = alloc_stack $MMString
|
|
// CHECK: [[ID:%[0-9]+]] = function_ref @_T06callee7inherit8MMStringC_AB6MMFontCSgTg5 : $@convention(method) (@owned MMString, Int, @owned MMStorage<MMString, Optional<MMFont>>) -> Bool
|
|
%34 = function_ref @callee : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in τ_0_0, Int, @owned MMStorage<τ_0_0, τ_0_1>) -> Bool
|
|
// CHECK: [[LOAD:%[0-9]+]] = load [[STACK]]
|
|
// CHECK: apply [[ID]]([[LOAD]], %1, %{{[0-9]+}}) : $@convention(method) (@owned MMString, Int, @owned MMStorage<MMString, Optional<MMFont>>) -> Bool
|
|
%45 = apply %34<MMString, MMFont?>(%37, %1, %14) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in τ_0_0, Int, @owned MMStorage<τ_0_0, τ_0_1>) -> Bool
|
|
dealloc_stack %37 : $*MMString
|
|
|
|
return %14 : $MMStorage<MMString, Optional<MMFont>>
|
|
}
|
|
|
|
// CHECK-LABEL: @_T06callee7inherit8MMStringC_AB6MMFontCSgTg5 : $@convention(method) (@owned MMString, Int, @owned MMStorage<MMString, Optional<MMFont>>) -> Bool {
|
|
// CHECK: [[META:%[0-9]+]] = metatype $@thick MMString.Type
|
|
// CHECK: [[ID3:%[0-9]+]] = witness_method $MMString, #Equatable."=="!1 :
|
|
// CHECK: [[STACK2:%[0-9]+]] = alloc_stack $MMString
|
|
// CHECK: [[STACK3:%[0-9]+]] = alloc_stack $MMString
|
|
// CHECK: apply [[ID3]]<MMString>([[STACK2]], [[STACK3]], [[META]]) : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable> (@in τ_0_0, @in τ_0_0, @thick τ_0_0.Type) -> Bool
|
|
|
|
// CHECK-LABEL: @callee : $@convention(method) <Key, Value where Key : Hashable> (@in Key, Int, @owned MMStorage<Key, Value>) -> Bool {
|
|
sil [noinline] @callee : $@convention(method) <Key, Value where Key : Hashable> (@in Key, Int, @owned MMStorage<Key, Value>) -> Bool {
|
|
bb0(%0 : $*Key, %1 : $Int, %2 : $MMStorage<Key, Value>):
|
|
%25 = metatype $@thick Key.Type
|
|
// CHECK: [[ID2:%[0-9]+]] = witness_method $Key, #Equatable."=="!1 :
|
|
%26 = witness_method $Key, #Equatable."=="!1 : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable> (@in τ_0_0, @in τ_0_0, @thick τ_0_0.Type) -> Bool
|
|
%27 = alloc_stack $Key
|
|
%33 = alloc_stack $Key
|
|
// CHECK: apply [[ID2]]<Key>
|
|
%35 = apply %26<Key>(%27, %33, %25) : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable> (@in τ_0_0, @in τ_0_0, @thick τ_0_0.Type) -> Bool
|
|
dealloc_stack %33 : $*Key
|
|
dealloc_stack %27 : $*Key
|
|
return %35 : $Bool
|
|
}
|
|
|
|
sil @ext_fn1 : $@convention(thin) (Int, @thin MMStorage<MMString, Optional<MMFont>>.Type) -> @owned MMStorage<MMString, Optional<MMFont>>
|