Skip to content

Commit 4e106fb

Browse files
authored
Merge pull request #28012 from zoecarver/fix/optimizer-and-SR-11624
Fix crash when optimizing protocol composition
2 parents a73c1f4 + ddade0a commit 4e106fb

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ SILCombiner::buildConcreteOpenedExistentialInfoFromSoleConformingType(
907907
(archetypeTy->getConformsTo().size() == 1)) {
908908
PD = archetypeTy->getConformsTo()[0];
909909
} else if (ArgType.isExistentialType() && !ArgType.isAnyObject() &&
910-
!SwiftArgType->isAny()) {
910+
!SwiftArgType->isAny() && SwiftArgType->getAnyNominal()) {
911911
PD = dyn_cast<ProtocolDecl>(SwiftArgType->getAnyNominal());
912912
}
913913
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This source file is part of the Swift.org open source project
2+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
3+
// Licensed under Apache License v2.0 with Runtime Library Exception
4+
//
5+
// See https://swift.org/LICENSE.txt for license information
6+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
7+
8+
// RUN: not %target-swift-frontend %s -O -whole-module-optimization
9+
10+
class ClassA<T> { }
11+
protocol ProtocolA { }
12+
13+
class MainClass<H> {
14+
init(x: ClassA<H> & ProtocolA) { }
15+
}
16+
17+
final class ClassB: ClassA<String> { }
18+
extension ClassB: ProtocolA { }
19+
20+
_ = MainClass(x: ClassB())

0 commit comments

Comments
 (0)