Skip to content

Commit a4625ba

Browse files
committed
Sema: Fix crash with invalid member reference to macro
1 parent cc8f060 commit a4625ba

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

lib/Sema/TypeOfReference.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,9 @@ static bool isExistentialMemberAccessWithExplicitBaseExpression(
17581758
Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
17591759
Type type, Type baseObjTy, ValueDecl *value,
17601760
ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup) {
1761+
if (isa<MacroDecl>(value) || type->is<ErrorType>())
1762+
return ErrorType::get(getASTContext());
1763+
17611764
auto *outerDC = value->getDeclContext();
17621765

17631766
// Cope with dynamic 'Self'.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// {"kind":"complete","original":"098f0ede","signature":"swift::constraints::ConstraintSystem::getMemberReferenceTypeFromOpenedType(swift::Type, swift::Type, swift::ValueDecl*, swift::constraints::ConstraintLocator*, bool, bool)","signatureAssert":"Assertion failed: (isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"), function cast"}
2-
// RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
2+
// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
33
enum a<b> {
44
c=d#^^# macro d()
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// {"kind":"typecheck","original":"098f0ede","signature":"swift::constraints::ConstraintSystem::getMemberReferenceTypeFromOpenedType(swift::Type, swift::Type, swift::ValueDecl*, swift::constraints::ConstraintLocator*, bool, bool)","signatureAssert":"Assertion failed: (isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"), function cast"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
enum a<b> {
44
c = d macro d()
55
}

0 commit comments

Comments
 (0)