Skip to content

Commit 5b3e077

Browse files
authored
Merge pull request #9382 from slavapestov/fix-se-0110-issue-and-add-another-test
Fix SE-0110 issue and add another test
2 parents 38991ca + f2c46b6 commit 5b3e077

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,6 +3242,12 @@ Type TypeChecker::substMemberTypeWithBase(ModuleDecl *module,
32423242
}
32433243

32443244
Type TypeChecker::getSuperClassOf(Type type) {
3245+
if (auto *parenTy = dyn_cast<ParenType>(type.getPointer())) {
3246+
auto superclassTy = getSuperClassOf(parenTy->getUnderlyingType());
3247+
if (!superclassTy)
3248+
return Type();
3249+
return ParenType::get(Context, superclassTy);
3250+
}
32453251
return type->getSuperclass();
32463252
}
32473253

test/ClangImporter/objc_bridging_generics.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,3 +384,11 @@ func getContainerForPanda() -> AnimalContainer<Animal> {
384384
func getContainerForFungiblePanda() -> FungibleAnimalContainer<Animal & Fungible> {
385385
return Panda.getFungibleContainer()
386386
}
387+
388+
// rdar://problem/30832766 - Infinite recursion while checking conformance
389+
// to AnyObject
390+
let third: Third! = Third()
391+
392+
func useThird() {
393+
_ = third.description
394+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 3
2+
// RUN: %target-typecheck-verify-swift -swift-version 4
3+
4+
// rdar://problem/31969605
5+
6+
class Base {}
7+
class Derived : Base {}
8+
9+
protocol Refined {}
10+
protocol Proto : Refined {}
11+
extension Base : Refined {}
12+
13+
func baseFn(_: Base) {}
14+
15+
func superclassConversion(fn: @escaping (Base) -> ()) {
16+
let _: (Derived) -> () = fn
17+
}
18+
19+
func existentialConversion(fn: @escaping (Refined) -> ()) {
20+
let _: (Proto) -> () = fn
21+
let _: (Base) -> () = fn
22+
let _: (Derived) -> () = fn
23+
}

test/Inputs/clang-importer-sdk/usr/include/objc_generics.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,14 @@ typedef id <Fungible> FungibleObject;
101101
+ (FungibleAnimalContainer *)getFungibleContainer;
102102

103103
@end
104+
105+
@interface First<__covariant T> : NSObject
106+
@end
107+
108+
@interface Second<__covariant T> : First<T>
109+
@end
110+
111+
@class Third;
112+
113+
@interface Third : Second<Third *>
114+
@end

0 commit comments

Comments
 (0)