Skip to content

Commit 873da73

Browse files
committed
Parse: Improve MemberImportVisibility diags for appendLiteral(_:) calls.
Ensure compiler generated calls to `appendLiteral(_:)` have source locations for diagnostics. Partially resolves rdar://144535697.
1 parent 746cddc commit 873da73

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
19721972
new (Context) UnresolvedDotExpr(InterpolationVarRef,
19731973
/*dotloc=*/SourceLoc(),
19741974
appendLiteral,
1975-
/*nameloc=*/DeclNameLoc(),
1975+
/*nameloc=*/DeclNameLoc(TokenLoc),
19761976
/*Implicit=*/true);
19771977
auto *ArgList = ArgumentList::forImplicitUnlabeled(Context, {Literal});
19781978
auto AppendLiteralCall =

test/NameLookup/members_transitive_compiler_protocols.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
//--- main.swift
1010

1111
import Swift
12-
// expected-note 2 {{add import of module 'lib'}}
12+
// expected-note 6 {{add import of module 'lib'}}
1313

1414
for _ in makeSequence() { }
1515
// expected-error@-1 {{instance method 'makeIterator()' is not available due to missing import of defining module 'lib'}}
1616
// expected-error@-2 {{instance method 'next()' is not available due to missing import of defining module 'lib'}}
1717

18+
takesMessage("\(1)")
19+
// expected-error@-1 {{initializer 'init(stringInterpolation:)' is not available due to missing import of defining module 'lib'}}
20+
// expected-error@-2 {{instance method 'appendInterpolation' is not available due to missing import of defining module 'lib'}}
21+
// expected-error@-3 2 {{instance method 'appendLiteral' is not available due to missing import of defining module 'lib'}}
22+
1823
//--- other.swift
1924

2025
import lib
@@ -23,6 +28,8 @@ func makeSequence() -> EmptySequence {
2328
return MySequence()
2429
}
2530

31+
func takesMessage(_ x: Message) { }
32+
2633
//--- lib.swift
2734

2835
public struct EmptySequence: Sequence {
@@ -33,3 +40,14 @@ public struct EmptySequence: Sequence {
3340
public func makeIterator() -> Iterator { Iterator() }
3441
public init() { }
3542
}
43+
44+
public struct MessageInterpolation: StringInterpolationProtocol {
45+
public init(literalCapacity: Int, interpolationCount: Int) { }
46+
public mutating func appendInterpolation(_ value: @autoclosure () -> Int) { }
47+
public mutating func appendLiteral(_ literal: String) { }
48+
}
49+
50+
public struct Message: ExpressibleByStringInterpolation {
51+
public init(stringInterpolation: MessageInterpolation) { }
52+
public init(stringLiteral: String) { }
53+
}

0 commit comments

Comments
 (0)