File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -4286,8 +4286,7 @@ bool ConstraintSystem::repairFailures(
4286
4286
// it's going to be diagnosed by specialized fix which deals
4287
4287
// with generic argument mismatches.
4288
4288
if (matchKind == ConstraintKind::BindToPointerType) {
4289
- auto *member = rhs->getAs <DependentMemberType>();
4290
- if (!(member && member->getBase ()->hasPlaceholder ()))
4289
+ if (!rhs->isPlaceholder ())
4291
4290
break ;
4292
4291
}
4293
4292
@@ -4634,6 +4633,12 @@ bool ConstraintSystem::repairFailures(
4634
4633
}
4635
4634
4636
4635
case ConstraintLocator::FunctionResult: {
4636
+ if (lhs->isPlaceholder () || rhs->isPlaceholder ()) {
4637
+ recordAnyTypeVarAsPotentialHole (lhs);
4638
+ recordAnyTypeVarAsPotentialHole (rhs);
4639
+ return true ;
4640
+ }
4641
+
4637
4642
auto *loc = getConstraintLocator (anchor, {path.begin (), path.end () - 1 });
4638
4643
// If this is a mismatch between contextual type and (trailing)
4639
4644
// closure with explicitly specified result type let's record it
@@ -4654,6 +4659,7 @@ bool ConstraintSystem::repairFailures(
4654
4659
break ;
4655
4660
}
4656
4661
}
4662
+
4657
4663
// Handle function result coerce expression wrong type conversion.
4658
4664
if (isExpr<CoerceExpr>(anchor)) {
4659
4665
auto *fix =
Original file line number Diff line number Diff line change @@ -2958,6 +2958,10 @@ Type ConstraintSystem::simplifyTypeImpl(Type type,
2958
2958
// Simplify the base.
2959
2959
Type newBase = simplifyTypeImpl (depMemTy->getBase (), getFixedTypeFn);
2960
2960
2961
+ if (newBase->isPlaceholder ()) {
2962
+ return PlaceholderType::get (getASTContext (), depMemTy);
2963
+ }
2964
+
2961
2965
// If nothing changed, we're done.
2962
2966
if (newBase.getPointer () == depMemTy->getBase ().getPointer ())
2963
2967
return type;
Original file line number Diff line number Diff line change @@ -905,3 +905,28 @@ func rdar78781552() {
905
905
// expected-error@-4 {{missing argument for parameter 'filter' in call}}
906
906
}
907
907
}
908
+
909
+ // rdar://79757320 - failured to produce a diagnostic when unresolved dependent member is used in function result position
910
+
911
+ protocol R_79757320 {
912
+ associatedtype In
913
+ associatedtype Out
914
+ }
915
+
916
+ func rdar79757320( ) {
917
+ struct Value < W> {
918
+ init ( _: W ) { }
919
+
920
+ func formatted( ) -> String { " " }
921
+ func formatted< T : R_79757320 > ( _: T ) -> T . Out where T. In == Value < W > { fatalError ( ) }
922
+ }
923
+
924
+ struct Container {
925
+ var value : String
926
+ }
927
+
928
+ // FIXME: There has to be a way to propagate holes that makes it easy to suppress failures caused by missing members.
929
+ _ = Container ( value: Value ( 42 ) . formatted ( . S( a: . a, b: . b( 0 ) ) ) ) // expected-error {{type 'R_79757320' has no member 'S'}}
930
+ // expected-error@-1 {{cannot infer contextual base in reference to member 'a'}}
931
+ // expected-error@-2 {{cannot infer contextual base in reference to member 'b'}}
932
+ }
You can’t perform that action at this time.
0 commit comments