File tree Expand file tree Collapse file tree 2 files changed +37
-8
lines changed Expand file tree Collapse file tree 2 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -2504,19 +2504,16 @@ namespace {
2504
2504
2505
2505
// If the 'self' parameter is not configured, something went
2506
2506
// wrong elsewhere and should have been diagnosed already.
2507
- if (!selfDecl->hasType ())
2507
+ if (!selfDecl->hasInterfaceType ())
2508
2508
return ErrorType::get (tc.Context );
2509
2509
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 ());
2516
2512
auto superclassTy = selfTy->getSuperclass (&tc);
2517
2513
2518
- if (selfDecl->getType ()->is <MetatypeType>())
2514
+ if (selfDecl->getInterfaceType ()->is <MetatypeType>())
2519
2515
superclassTy = MetatypeType::get (superclassTy);
2516
+
2520
2517
return superclassTy;
2521
2518
}
2522
2519
Original file line number Diff line number Diff line change @@ -110,3 +110,35 @@ public extension ResilientOutsideChild {
110
110
super. classMethod ( )
111
111
}
112
112
}
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
+ }
You can’t perform that action at this time.
0 commit comments