File tree Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 23
23
#include " swift/AST/Decl.h"
24
24
#include " swift/AST/DiagnosticEngine.h"
25
25
#include " swift/AST/DiagnosticsClangImporter.h"
26
+ #include " swift/AST/ExistentialLayout.h"
26
27
#include " swift/AST/GenericEnvironment.h"
27
28
#include " swift/AST/Module.h"
28
29
#include " swift/AST/NameLookup.h"
@@ -2448,7 +2449,11 @@ bool ClangImporter::Implementation::matchesHashableBound(Type type) {
2448
2449
}
2449
2450
}
2450
2451
2451
- // Class type or existential that inherits from NSObject.
2452
+ // Existentials cannot match the Hashable bound.
2453
+ if (type->isAnyExistentialType ())
2454
+ return false ;
2455
+
2456
+ // Class type that inherits from NSObject.
2452
2457
if (NSObjectType->isExactSuperclassOf (type))
2453
2458
return true ;
2454
2459
Original file line number Diff line number Diff line change 27
27
@interface ObjCBridgeGenericConstrainedExtra <Element: NSObject <ExtraElementProtocol> *> : NSObject
28
28
@property NSSet <Element> * _Nonnull foo;
29
29
@end
30
+
31
+ @interface ObjCBridgeExistential : NSObject
32
+ @property NSSet <NSObject <ExtraElementProtocol> *> * _Nonnull foo;
33
+ @end
Original file line number Diff line number Diff line change @@ -408,11 +408,13 @@ func testHashableGenerics(
408
408
any: ObjCBridgeGeneric < ElementConcrete > ,
409
409
constrained: ObjCBridgeGenericConstrained < ElementConcrete > ,
410
410
insufficient: ObjCBridgeGenericInsufficientlyConstrained < ElementConcrete > ,
411
- extra: ObjCBridgeGenericConstrainedExtra < ElementConcrete > ) {
411
+ extra: ObjCBridgeGenericConstrainedExtra < ElementConcrete > ,
412
+ existential: ObjCBridgeExistential ) {
412
413
let _: Int = any. foo // expected-error{{cannot convert value of type 'Set<AnyHashable>' to specified type 'Int'}}
413
414
let _: Int = constrained. foo // expected-error{{cannot convert value of type 'Set<ElementConcrete>' to specified type 'Int'}}
414
415
let _: Int = insufficient. foo // expected-error{{cannot convert value of type 'Set<AnyHashable>' to specified type 'Int'}}
415
416
let _: Int = extra. foo // expected-error{{cannot convert value of type 'Set<ElementConcrete>' to specified type 'Int'}}
417
+ let _: Int = existential. foo // expected-error{{cannot convert value of type 'Set<AnyHashable>' to specified type 'Int'}}
416
418
}
417
419
418
420
func testGenericsWithTypedefBlocks( hba: HasBlockArray ) {
Original file line number Diff line number Diff line change 1
1
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
2
2
3
- // Ensure that the superclass's generid argument canonicalizes to
3
+ // Ensure that the superclass's generic argument canonicalizes to
4
4
// Sequence.Element.
5
5
6
6
// CHECK: @"symbolic _____y7ElementSTQzG
You can’t perform that action at this time.
0 commit comments