File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -8755,8 +8755,17 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
8755
8755
if (shouldAttemptFixes() && result.isFailure()) {
8756
8756
auto *loc = getConstraintLocator(locator);
8757
8757
8758
- if (loc->isLastElement<LocatorPathElt::InstanceType>())
8759
- loc = getConstraintLocator(loc->getAnchor(), loc->getPath().drop_back());
8758
+ ArrayRef<LocatorPathElt> path = loc->getPath();
8759
+ while (!path.empty()) {
8760
+ if (!path.back().is<LocatorPathElt::InstanceType>())
8761
+ break;
8762
+
8763
+ path = path.drop_back();
8764
+ }
8765
+
8766
+ if (path.size() != loc->getPath().size()) {
8767
+ loc = getConstraintLocator(loc->getAnchor(), path);
8768
+ }
8760
8769
8761
8770
ConstraintFix *fix = nullptr;
8762
8771
if (loc->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
Original file line number Diff line number Diff line change @@ -125,7 +125,8 @@ func parameterizedExistentials() {
125
125
func testNestedMetatype( ) {
126
126
struct S : P { }
127
127
128
- func bar< T> ( _ x: T ) -> T . Type { type ( of: x) }
128
+ func bar< T> ( _ x: T ) -> T . Type { }
129
+ func metaBar< T> ( _ x: T ) -> T . Type . Type { }
129
130
func foo1( _ x: P . Type ) { }
130
131
func foo2( _ x: P . Type . Type ) { }
131
132
@@ -134,4 +135,5 @@ func testNestedMetatype() {
134
135
// Make sure we don't crash.
135
136
foo2 ( bar ( S . self) )
136
137
foo2 ( bar ( 0 ) ) // expected-error {{cannot convert value of type 'Int' to expected argument type 'any P.Type'}}
138
+ foo2 ( metaBar ( 0 ) ) // expected-error {{argument type 'Int' does not conform to expected type 'P'}}
137
139
}
You can’t perform that action at this time.
0 commit comments