Skip to content

Commit fc02ac7

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 7a6f917 + 26461ad commit fc02ac7

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

lib/Sema/CSGen.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,19 +2504,16 @@ namespace {
25042504

25052505
// If the 'self' parameter is not configured, something went
25062506
// wrong elsewhere and should have been diagnosed already.
2507-
if (!selfDecl->hasType())
2507+
if (!selfDecl->hasInterfaceType())
25082508
return ErrorType::get(tc.Context);
25092509

2510-
// If the method returns 'Self', the type of 'self' is a
2511-
// DynamicSelfType. Unwrap it before getting the superclass.
2512-
auto selfTy = selfDecl->getType()->getRValueInstanceType();
2513-
if (auto *dynamicSelfTy = selfTy->getAs<DynamicSelfType>())
2514-
selfTy = dynamicSelfTy->getSelfType();
2515-
2510+
auto selfTy = CS.DC->mapTypeIntoContext(
2511+
typeContext->getDeclaredInterfaceType());
25162512
auto superclassTy = selfTy->getSuperclass(&tc);
25172513

2518-
if (selfDecl->getType()->is<MetatypeType>())
2514+
if (selfDecl->getInterfaceType()->is<MetatypeType>())
25192515
superclassTy = MetatypeType::get(superclassTy);
2516+
25202517
return superclassTy;
25212518
}
25222519

test/SILGen/super.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,35 @@ public extension ResilientOutsideChild {
110110
super.classMethod()
111111
}
112112
}
113+
114+
public class GenericBase<T> {
115+
public func method() {}
116+
}
117+
118+
public class GenericDerived<T> : GenericBase<T> {
119+
public override func method() {
120+
// CHECK-LABEL: sil shared @_T05super14GenericDerivedC6methodyyFyycfU_ : $@convention(thin) <T> (@owned GenericDerived<T>) -> ()
121+
// CHECK: upcast {{.*}} : $GenericDerived<T> to $GenericBase<T>
122+
// CHECK: return
123+
{
124+
super.method()
125+
}()
126+
127+
// CHECK-LABEL: sil shared @_T05super14GenericDerivedC6methodyyF13localFunctionL_yylF : $@convention(thin) <T> (@owned GenericDerived<T>) -> ()
128+
// CHECK: upcast {{.*}} : $GenericDerived<T> to $GenericBase<T>
129+
// CHECK: return
130+
131+
func localFunction() {
132+
super.method()
133+
}
134+
localFunction()
135+
136+
// CHECK-LABEL: sil shared @_T05super14GenericDerivedC6methodyyF15genericFunctionL_yqd__r__lF : $@convention(thin) <T><U> (@in U, @owned GenericDerived<T>) -> ()
137+
// CHECK: upcast {{.*}} : $GenericDerived<T> to $GenericBase<T>
138+
// CHECK: return
139+
func genericFunction<U>(_: U) {
140+
super.method()
141+
}
142+
genericFunction(0)
143+
}
144+
}

0 commit comments

Comments
 (0)