mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CS] Correctly set compound bit for UnresolvedMemberExprs
Now that IUOs are supported for compound function
references, we can properly set the compound bit
here.
This is a source breaking change since this used
to be legal:
```swift
struct S {
static func foo(x: Int) -> Self { .init() }
}
let _: S = .foo(x:)(x: 0)
```
However I somewhat doubt anyone is intentionally
writing code like that.
This commit is contained in:
@@ -1898,18 +1898,7 @@ public:
|
||||
bool implicit)
|
||||
: Expr(ExprKind::UnresolvedMember, implicit), DotLoc(dotLoc),
|
||||
NameLoc(nameLoc), Name(name) {
|
||||
// FIXME(FunctionRefInfo): Really, we should be passing `nameLoc` directly,
|
||||
// allowing the FunctionRefInfo to be treated as compound. This would
|
||||
// require us to enable IUOs for compound names, e.g:
|
||||
// ```
|
||||
// struct S {
|
||||
// static func makeS(_: Int) -> S! { S() }
|
||||
// }
|
||||
//
|
||||
// let s: S = .makeS(_:)(0)
|
||||
// ```
|
||||
setFunctionRefInfo(
|
||||
FunctionRefInfo::unapplied(DeclNameLoc(nameLoc.getBaseNameLoc())));
|
||||
setFunctionRefInfo(FunctionRefInfo::unapplied(nameLoc));
|
||||
}
|
||||
|
||||
DeclNameRef getName() const { return Name; }
|
||||
|
||||
@@ -837,3 +837,13 @@ do {
|
||||
// expected-note@-2 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
|
||||
}
|
||||
}
|
||||
|
||||
func testCompoundLeadingDot() {
|
||||
struct S {
|
||||
static func foo(x: Int) -> Self { .init() }
|
||||
}
|
||||
|
||||
// Make sure we correctly strip the argument label.
|
||||
let _: S = .foo(x:)(0)
|
||||
let _: S = .foo(x:)(x: 0) // expected-error {{extraneous argument label 'x:' in call}}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ struct S0 {
|
||||
}
|
||||
|
||||
// Determine context from type.
|
||||
let s0_static: S0 = .f3(_:y:z:)(0, y: 0, z: 0)
|
||||
let s0_static: S0 = .f3(_:y:z:)(0, 0, 0)
|
||||
|
||||
class C0 {
|
||||
init(x: Int, y: Int, z: Int) { }
|
||||
|
||||
Reference in New Issue
Block a user