Skip to content

Commit

Permalink
Merge pull request #1522 from kballard/conditional-compilation-overloads
Browse files Browse the repository at this point in the history
[Parse] Don't error on overloads in a conditional compilation block
  • Loading branch information
DougGregor committed Mar 14, 2016
2 parents d525309 + a734063 commit d251c7a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion include/swift/Parse/Scope.h
Expand Up @@ -78,7 +78,6 @@ enum class ScopeKind {
CatchVars,
WhileVars,
IfVars,
ActiveConfigBlock,

ClosureParams,
};
Expand Down
3 changes: 2 additions & 1 deletion lib/Parse/ParseDecl.cpp
Expand Up @@ -2790,7 +2790,8 @@ ParserResult<IfConfigDecl> Parser::parseDeclIfConfig(ParseDeclOptions Flags) {

Optional<Scope> scope;
if (!ConfigState.isConditionActive())
scope.emplace(this, ScopeKind::Brace, /*inactiveConfigBlock=*/true);
scope.emplace(this, getScopeInfo().getCurrentScope()->getKind(),
/*inactiveConfigBlock=*/true);

SmallVector<Decl*, 8> Decls;
if (ConfigState.shouldParse()) {
Expand Down
1 change: 0 additions & 1 deletion lib/Parse/Scope.cpp
Expand Up @@ -38,7 +38,6 @@ static bool isResolvableScope(ScopeKind SK) {
case ScopeKind::ConstructorBody:
case ScopeKind::DestructorBody:
case ScopeKind::Brace:
case ScopeKind::ActiveConfigBlock:
case ScopeKind::ForVars:
case ScopeKind::ForeachVars:
case ScopeKind::ClosureParams:
Expand Down
5 changes: 5 additions & 0 deletions test/Parse/ConditionalCompilation/basicDeclarations.swift
Expand Up @@ -26,6 +26,11 @@ class D {
x = 1
#endif
}

#if !BAR
func overload(a: Int) {}
func overload(b: String) {} // should not result in an error
#endif
}

var d = D()
Expand Down

0 comments on commit d251c7a

Please sign in to comment.