File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -1279,16 +1279,11 @@ ConstraintSystem::getTypeOfMemberReference(
1279
1279
// For a static member referenced through a metatype or an instance
1280
1280
// member referenced through an instance, strip off the 'self'.
1281
1281
type = openedFnType->getResult ();
1282
- } else if (isDynamicResult && isa<AbstractFunctionDecl>(value)) {
1283
- // For a dynamic result referring to an instance function through
1284
- // an object of metatype type, replace the 'Self' parameter with
1285
- // a AnyObject member.
1286
- auto anyObjectTy = TC.Context .getAnyObjectType ();
1287
- type = openedFnType->replaceSelfParameterType (anyObjectTy);
1288
1282
} else {
1289
1283
// For an unbound instance method reference, replace the 'Self'
1290
1284
// parameter with the base type.
1291
- type = openedFnType->replaceSelfParameterType (baseObjTy);
1285
+ openedType = openedFnType->replaceSelfParameterType (baseObjTy);
1286
+ type = openedType;
1292
1287
}
1293
1288
1294
1289
// When accessing protocol members with an existential base, replace
Original file line number Diff line number Diff line change @@ -167,3 +167,25 @@ struct StructWithStaticVar {
167
167
init ( ) {
168
168
}
169
169
}
170
+
171
+ // Make sure unbound method references on class hierarchies are
172
+ // properly represented in the AST
173
+
174
+ class Base {
175
+ func method1( ) -> Self { return self }
176
+ func method2( ) -> Self { return self }
177
+ }
178
+
179
+ class Derived : Base {
180
+ override func method2( ) -> Self { return self }
181
+ }
182
+
183
+ func generic< T> ( arg: T ) { }
184
+
185
+ func unboundMethodReferences( ) {
186
+ generic ( arg: Derived . method1)
187
+ generic ( arg: Derived . method2)
188
+
189
+ _ = type ( of: Derived . method1)
190
+ _ = type ( of: Derived . method2)
191
+ }
You can’t perform that action at this time.
0 commit comments