Skip to content

Commit e481a98

Browse files
authored
Merge pull request #24985 from xedin/sr-10696-5.1
[5.1][Sema] Fix compiler crasher SR-10696
2 parents 3a1f298 + 9e5cecb commit e481a98

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4716,7 +4716,11 @@ static bool isViableOverloadSet(const CalleeCandidateInfo &CCI,
47164716
for (unsigned i = 0; i < CCI.size(); ++i) {
47174717
auto &&cand = CCI[i];
47184718
auto funcDecl = dyn_cast_or_null<AbstractFunctionDecl>(cand.getDecl());
4719-
if (!funcDecl)
4719+
4720+
// If we don't have a func decl or we haven't resolved its parameters,
4721+
// continue. The latter case can occur with `type(of:)`, which is introduced
4722+
// as a type variable.
4723+
if (!funcDecl || !cand.hasParameters())
47204724
continue;
47214725

47224726
auto params = cand.getParameters();

test/Constraints/type_of.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,9 @@ func bar() -> UInt {} // expected-note {{found this candidate}}
7878
foo(type(of: G.T.self)) // Ok
7979
let _: Any = type(of: G.T.self) // Ok
8080
foo(type(of: bar())) // expected-error {{ambiguous use of 'bar()'}}
81+
82+
struct SR10696 {
83+
func bar(_ s: SR10696.Type) {
84+
type(of: s)() // expected-error {{cannot invoke value of type 'SR10696.Type.Type' with argument list '()'}}
85+
}
86+
}

0 commit comments

Comments
 (0)