Files
swift-mirror/test/SILOptimizer/moveonly_checking_class_method.swift
Joe Groff 23747bbb8e SILGen: Coordinate access strategy determination with actual codegen in findStorageReferenceExprForMoveOnly.
Looking at the AST-level `getReadImpl` doesn't always correspond to what
accessor SILGen prefers to use, due to resilience, ABI rules, and other
concerns. In findStorageReferenceExprForMoveOnly, when determining whether
a storage reference is borrowable, use the same logic as SILGenLValue actually
uses to determine what storage or accessor access strategy to use.

Fixes rdar://142509673
2025-01-10 16:12:09 -08:00

23 lines
367 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify %s
// rdar://142509673
struct Foo: ~Copyable {
var storage: UnsafeRawPointer
}
class Bar {
class var foo: Foo { fatalError() }
}
func test(foo: borrowing Foo) -> Bool {
fatalError()
}
func test2(bar: Bar.Type) -> Bool {
guard test(foo: bar.foo) else {
return false
}
return true
}