Skip to content

Commit e939de4

Browse files
committed
[Type checker] If any argument to an application failed to type-check, don’t check the application.
Eliminates an assertion that came up while investigating rdar://problem/27940842.
1 parent 62a3de6 commit e939de4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/Sema/TypeCheckError.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ class ApplyClassifier {
406406
SmallVector<Expr*, 4> args;
407407
auto fnRef = AbstractFunction::decomposeApply(E, args);
408408

409+
// If any of the arguments didn't type check, fail.
410+
for (auto arg : args) {
411+
if (!arg->getType() || arg->getType()->is<ErrorType>())
412+
return Classification::forInvalidCode();
413+
}
414+
409415
// If we're applying more arguments than the natural argument
410416
// count, then this is a call to the opaque value returned from
411417
// the function.

test/decl/func/operator.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,11 @@ class C5 {
345345
_ = x == x
346346
}
347347
}
348+
349+
class C6 {
350+
static func == (lhs: C6, rhs: C6) -> Bool { return false }
351+
352+
func test1(x: C6) {
353+
if x == x && x = x { } // expected-error{{cannot assign to value: '&&' returns immutable value}}
354+
}
355+
}

0 commit comments

Comments
 (0)