Files
swift-mirror/validation-test/compiler_crashers_2_fixed/sr14454.swift
Alex Hoppen 78d6fb2e26 [TypeChecker] Fix assertion failure when using Self in extension that’s not on top-level
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
2021-04-08 18:50:14 +02:00

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
}
}
}