File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -3043,12 +3043,21 @@ ProtocolConformanceRef ReplaceOpaqueTypesWithUnderlyingTypes::
3043
3043
operator ()(CanType maybeOpaqueType, Type replacementType,
3044
3044
ProtocolDecl *protocol) const {
3045
3045
auto abstractRef = ProtocolConformanceRef (protocol);
3046
-
3046
+
3047
3047
auto archetypeAndRoot = getArchetypeAndRootOpaqueArchetype (maybeOpaqueType);
3048
3048
if (!archetypeAndRoot) {
3049
- assert (maybeOpaqueType->isTypeParameter () ||
3050
- maybeOpaqueType->is <ArchetypeType>());
3051
- return abstractRef;
3049
+ if (maybeOpaqueType->isTypeParameter () ||
3050
+ maybeOpaqueType->is <ArchetypeType>())
3051
+ return abstractRef;
3052
+
3053
+ // SIL type lowering may have already substituted away the opaque type, in
3054
+ // which case we'll end up "substituting" the same type.
3055
+ if (maybeOpaqueType->isEqual (replacementType)) {
3056
+ return inContext->getParentModule ()
3057
+ ->lookupConformance (replacementType, protocol);
3058
+ }
3059
+
3060
+ llvm_unreachable (" origType should have been an opaque type or type parameter" );
3052
3061
}
3053
3062
3054
3063
auto archetype = archetypeAndRoot->first ;
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-emit-silgen -disable-availability-checking -verify %s
2
+ protocol P { }
3
+ extension Int : P { }
4
+
5
+ func foo( ) -> some P { return 0 }
6
+ func bar< T: P > ( _ x: T ) -> some P { return x }
7
+
8
+ struct Bas < T: P > { init ( _: T ) { } }
9
+
10
+ func abstraction_level< T> ( x: T ) -> ( T ) -> ( ) {
11
+ return { _ in ( ) }
12
+ }
13
+
14
+ func test( ) {
15
+ abstraction_level ( x: Bas ( bar ( foo ( ) ) ) ) ( Bas ( bar ( foo ( ) ) ) )
16
+ }
You can’t perform that action at this time.
0 commit comments