Skip to content

Commit f4c0bc7

Browse files
committed
[Sema] Fix compiler crasher SR-10696
1 parent 8aa7401 commit f4c0bc7

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
@@ -4662,7 +4662,11 @@ static bool isViableOverloadSet(const CalleeCandidateInfo &CCI,
46624662
for (unsigned i = 0; i < CCI.size(); ++i) {
46634663
auto &&cand = CCI[i];
46644664
auto funcDecl = dyn_cast_or_null<AbstractFunctionDecl>(cand.getDecl());
4665-
if (!funcDecl)
4665+
4666+
// If we don't have a func decl or we haven't resolved its parameters,
4667+
// continue. The latter case can occur with `type(of:)`, which is introduced
4668+
// as a type variable.
4669+
if (!funcDecl || !cand.hasParameters())
46664670
continue;
46674671

46684672
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)