Skip to content

Commit 121f39c

Browse files
committed
sema: set locator properly when diagnosing constness mismatches
rdar://90210674
1 parent e2d6f5a commit 121f39c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ class ParameterTypeFlags {
20882088
return value.toRaw() != other.value.toRaw();
20892089
}
20902090

2091-
uint8_t toRaw() const { return value.toRaw(); }
2091+
uint16_t toRaw() const { return value.toRaw(); }
20922092
};
20932093

20942094
class YieldTypeFlags {

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
19321932
locator->getAnchor().isExpr(ExprKind::UnresolvedMemberChainResult)) {
19331933
locator =
19341934
cs.getConstraintLocator(cast<UnresolvedMemberChainResultExpr>(
1935-
locator->getAnchor().get<Expr*>())->getChainBase());
1935+
locator->getAnchor().get<Expr*>())->getSubExpr());
19361936
}
19371937
cs.recordFix(NotCompileTimeConst::create(cs, paramTy, locator));
19381938
}

test/Sema/const_enum_elements2.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
enum E {
4+
case a
5+
case b(Int)
6+
7+
var c: E { .b(42) }
8+
}
9+
10+
func test(_: _const E) {}
11+
12+
test(.a.c) // expected-error {{expect a compile-time constant literal}}

0 commit comments

Comments
 (0)