Skip to content

Commit 4b898ce

Browse files
committed
Fix rdar://23681566, a bug noticed by Marcin Krzyzanowski on twitter where
we would reject an invalid @objc enum with: <unknown>:0: error: cannot assign value of type '(progress: Int) -> Status' to type 'Status' because we were poking at the enum element before it was validated.
1 parent 714dcd5 commit 4b898ce

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,9 @@ static void checkEnumRawValues(TypeChecker &TC, EnumDecl *ED) {
26032603
llvm::SmallDenseMap<RawValueKey, RawValueSource, 8> uniqueRawValues;
26042604

26052605
for (auto elt : ED->getAllElements()) {
2606+
// Make sure the element is checked out before we poke at it.
2607+
TC.validateDecl(elt);
2608+
26062609
if (elt->isInvalid())
26072610
continue;
26082611

test/Parse/objc_enum.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ class Bar {
2929
@objc func foo(x: Foo) {}
3030
@objc func nonObjC(x: NonObjCEnum) {} //expected-error{{type of the parameter cannot be represented in Objective-C}} //expected-note{{non-'@objc' enums cannot be represented in Objective-C}}
3131
}
32+
33+
// <rdar://problem/23681566> @objc enums with payloads rejected with no source location info
34+
@objc enum r23681566 : Int { // expected-note {{declared raw type 'Int' here}}
35+
case Foo(progress: Int) // expected-error {{enum with raw type cannot have cases with arguments}}
36+
}
37+

test/Parse/pointer_conversion.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ func f23202128() {
243243
let pipe: [Int32] = [0, 0] // expected-note {{change 'let' to 'var' to make it mutable}}}}
244244
UMP(&pipe) // expected-error {{cannot pass immutable value as inout argument: 'pipe' is a 'let' constant}}
245245

246+
var pipe2: [Int] = [0, 0]
247+
UMP(&pipe2) // expected-error {{cannot convert value of type '[Int]' to expected argument type 'Int32'}}
248+
249+
246250
UP(pipe) // ok
247251
UP(&pipe) // expected-error {{'&' is not allowed passing array value as 'UnsafePointer<Int32>' argument}} {{6-7=}}
248252
}

0 commit comments

Comments
 (0)