mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We fail to resolve the extended type if an extension is not declared at the top level. This causes us to diagnose a lookup failure on `Self`. If the extended type is a protocol, we thus end up with a nominal Self type that’s not a class, violating the assertion that’s currently in place. To fix the crasher, convert the assertion to an `if` condition and issue a generic "cannot find type 'Self' in scope" in the else case. Fixes rdar://76329083
13 lines
227 B
Swift
13 lines
227 B
Swift
// RUN: not %target-swift-frontend -typecheck %s
|
|
protocol Foo {}
|
|
|
|
func withTrailingClosure(x: (Int) -> Void) {}
|
|
|
|
_ = withTrailingClosure { (x) in
|
|
extension Foo {
|
|
func foo() {
|
|
_ = MemoryLayout<Self>.size
|
|
}
|
|
}
|
|
}
|