File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
validation-test/compiler_crashers_fixed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -274,8 +274,13 @@ Type TypeChecker::resolveTypeInContext(
274
274
275
275
assert (foundDC);
276
276
277
+ // selfType is the self type of the context, unless the
278
+ // context is a protocol type, in which case we might have
279
+ // to use the existential type or superclass bound as a
280
+ // parent type instead.
277
281
Type selfType;
278
- if (isa<NominalTypeDecl>(typeDecl)) {
282
+ if (isa<NominalTypeDecl>(typeDecl) &&
283
+ typeDecl->getDeclContext ()->getAsProtocolOrProtocolExtensionContext ()) {
279
284
// When looking up a nominal type declaration inside of a
280
285
// protocol extension, always use the nominal type and
281
286
// not the protocol 'Self' type.
@@ -292,7 +297,8 @@ Type TypeChecker::resolveTypeInContext(
292
297
293
298
if (selfType->is <GenericTypeParamType>() &&
294
299
typeDecl->getDeclContext ()->getAsClassOrClassExtensionContext ()) {
295
- // We found a member of a class from a protocol extension.
300
+ // We found a member of a class from a protocol or protocol
301
+ // extension.
296
302
//
297
303
// Get the superclass of the 'Self' type parameter.
298
304
auto *sig = foundDC->getGenericSignatureOfContext ();
Original file line number Diff line number Diff line change @@ -237,6 +237,8 @@ protocol ConformedProtocol {
237
237
class BaseWithAlias < T> : ConformedProtocol {
238
238
typealias ConcreteAlias = T
239
239
240
+ struct NestedNominal { }
241
+
240
242
func baseMethod( _: T ) { }
241
243
}
242
244
@@ -261,6 +263,8 @@ extension ExtendedProtocol where Self : DerivedWithAlias {
261
263
func f3( x: AbstractConformanceAlias ) {
262
264
let _: DerivedWithAlias = x
263
265
}
266
+
267
+ func f4( x: NestedNominal ) { }
264
268
}
265
269
266
270
// ----------------------------------------------------------------------------
Original file line number Diff line number Diff line change 6
6
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
7
7
8
8
// REQUIRES: asserts
9
- // RUN: not --crash %target-swift-frontend %s -emit-ir
9
+ // RUN: not %target-swift-frontend %s -emit-ir
10
10
protocol b: a { init( t: a } class a{ class a
You can’t perform that action at this time.
0 commit comments