File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -1214,8 +1214,6 @@ PotentialBindings::inferFromRelational(Constraint *constraint) {
1214
1214
if (!bindingTypeVar)
1215
1215
return None;
1216
1216
1217
- AdjacentVars.insert ({bindingTypeVar, constraint});
1218
-
1219
1217
// If current type variable is associated with a code completion token
1220
1218
// it's possible that it doesn't have enough contextual information
1221
1219
// to be resolved to anything, so let's note that fact in the potential
@@ -1237,14 +1235,24 @@ PotentialBindings::inferFromRelational(Constraint *constraint) {
1237
1235
assert (kind == AllowedBindingKind::Supertypes);
1238
1236
SupertypeOf.insert ({bindingTypeVar, constraint});
1239
1237
}
1238
+
1239
+ AdjacentVars.insert ({bindingTypeVar, constraint});
1240
1240
break ;
1241
1241
}
1242
1242
1243
1243
case ConstraintKind::Bind:
1244
1244
case ConstraintKind::BindParam:
1245
- case ConstraintKind::Equal:
1245
+ case ConstraintKind::Equal: {
1246
+ EquivalentTo.insert ({bindingTypeVar, constraint});
1247
+ AdjacentVars.insert ({bindingTypeVar, constraint});
1248
+ break ;
1249
+ }
1250
+
1246
1251
case ConstraintKind::UnresolvedMemberChainBase: {
1247
1252
EquivalentTo.insert ({bindingTypeVar, constraint});
1253
+
1254
+ // Don't record adjacency between base and result types,
1255
+ // this is just an auxiliary contraint to enforce ordering.
1248
1256
break ;
1249
1257
}
1250
1258
Original file line number Diff line number Diff line change @@ -316,3 +316,30 @@ func test_no_warning_about_optional_base() {
316
316
317
317
test ( . warnTest) // Ok and no warning even though the `warnTest` name is shadowed
318
318
}
319
+
320
+ // rdar://78425221 - invalid defaulting of literal argument when base is inferred from protocol
321
+
322
+ protocol Style { }
323
+
324
+ struct FormatString : ExpressibleByStringInterpolation {
325
+ init ( stringLiteral: String ) { }
326
+ }
327
+
328
+ struct Number : ExpressibleByIntegerLiteral {
329
+ init ( integerLiteral: Int ) { }
330
+ }
331
+
332
+ struct TestStyle : Style {
333
+ public init ( format: FormatString ) {
334
+ }
335
+ }
336
+
337
+ extension Style where Self == TestStyle {
338
+ static func formattedString( format: FormatString ) -> TestStyle { fatalError ( ) }
339
+ static func number( _: Number ) -> TestStyle { fatalError ( ) }
340
+ }
341
+
342
+ func acceptStyle< S: Style > ( _: S ) { }
343
+
344
+ acceptStyle ( . formattedString( format: " hi " ) ) // Ok
345
+ acceptStyle ( . number( 42 ) ) // Ok
You can’t perform that action at this time.
0 commit comments