File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
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"
@@ -2441,7 +2442,11 @@ bool ClangImporter::Implementation::matchesHashableBound(Type type) {
2441
2442
}
2442
2443
}
2443
2444
2444
- // Class type or existential that inherits from NSObject.
2445
+ // Existentials cannot match the Hashable bound.
2446
+ if (type->isAnyExistentialType ())
2447
+ return false ;
2448
+
2449
+ // Class type that inherits from NSObject.
2445
2450
if (NSObjectType->isExactSuperclassOf (type))
2446
2451
return true ;
2447
2452
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 ) {
You can’t perform that action at this time.
0 commit comments