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 @@ -4277,8 +4277,7 @@ bool ConstraintSystem::repairFailures(
4277
4277
// it's going to be diagnosed by specialized fix which deals
4278
4278
// with generic argument mismatches.
4279
4279
if (matchKind == ConstraintKind::BindToPointerType) {
4280
- auto *member = rhs->getAs <DependentMemberType>();
4281
- if (!(member && member->getBase ()->hasPlaceholder ()))
4280
+ if (!rhs->isPlaceholder ())
4282
4281
break ;
4283
4282
}
4284
4283
@@ -4619,6 +4618,12 @@ bool ConstraintSystem::repairFailures(
4619
4618
}
4620
4619
4621
4620
case ConstraintLocator::FunctionResult: {
4621
+ if (lhs->isPlaceholder () || rhs->isPlaceholder ()) {
4622
+ markAnyTypeVarsAsPotentialHoles (lhs);
4623
+ markAnyTypeVarsAsPotentialHoles (rhs);
4624
+ return true ;
4625
+ }
4626
+
4622
4627
auto *loc = getConstraintLocator (anchor, {path.begin (), path.end () - 1 });
4623
4628
// If this is a mismatch between contextual type and (trailing)
4624
4629
// closure with explicitly specified result type let's record it
@@ -4639,6 +4644,7 @@ bool ConstraintSystem::repairFailures(
4639
4644
break ;
4640
4645
}
4641
4646
}
4647
+
4642
4648
// Handle function result coerce expression wrong type conversion.
4643
4649
if (isExpr<CoerceExpr>(anchor)) {
4644
4650
auto *fix =
Original file line number Diff line number Diff line change @@ -2967,6 +2967,10 @@ Type ConstraintSystem::simplifyTypeImpl(Type type,
2967
2967
// Simplify the base.
2968
2968
Type newBase = simplifyTypeImpl (depMemTy->getBase (), getFixedTypeFn);
2969
2969
2970
+ if (newBase->isPlaceholder ()) {
2971
+ return PlaceholderType::get (getASTContext (), depMemTy);
2972
+ }
2973
+
2970
2974
// If nothing changed, we're done.
2971
2975
if (newBase.getPointer () == depMemTy->getBase ().getPointer ())
2972
2976
return type;
Original file line number Diff line number Diff line change @@ -893,3 +893,28 @@ func rdar78781552() {
893
893
// expected-error@-4 {{missing argument for parameter 'filter' in call}}
894
894
}
895
895
}
896
+
897
+ // rdar://79757320 - failured to produce a diagnostic when unresolved dependent member is used in function result position
898
+
899
+ protocol R_79757320 {
900
+ associatedtype In
901
+ associatedtype Out
902
+ }
903
+
904
+ func rdar79757320( ) {
905
+ struct Value < W> {
906
+ init ( _: W ) { }
907
+
908
+ func formatted( ) -> String { " " }
909
+ func formatted< T : R_79757320 > ( _: T ) -> T . Out where T. In == Value < W > { fatalError ( ) }
910
+ }
911
+
912
+ struct Container {
913
+ var value : String
914
+ }
915
+
916
+ // FIXME: There has to be a way to propagate holes that makes it easy to suppress failures caused by missing members.
917
+ _ = Container ( value: Value ( 42 ) . formatted ( . S( a: . a, b: . b( 0 ) ) ) ) // expected-error {{type 'R_79757320' has no member 'S'}}
918
+ // expected-error@-1 {{cannot infer contextual base in reference to member 'a'}}
919
+ // expected-error@-2 {{cannot infer contextual base in reference to member 'b'}}
920
+ }
You can’t perform that action at this time.
0 commit comments