Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-826] Conditional compilation over methods seem to do syntax check but only a simple one #43438

Closed
swift-ci opened this issue Feb 26, 2016 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-826
Radar rdar://problem/20478766
Original Reporter epatel (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee epatel (JIRA)
Priority Medium

md5: e7942a692ebfb68e5e2914291a592cee

is duplicated by:

  • SR-1656 Build Configuration statement breaks method overloading inside of a type

Issue Description:

This compile fine as the two methods has different signatures

class MyClass {
   func hello(one: Int, two: Int) {
   }
   func hello(one: Int, three: Int) {
   }
}

but below with a build configuration to disable both methods will give an error in Xcode Version 7.2.1 (7C1002) when NOT_NOW is not defined. The compiler seem to do a simple syntax check in the disabled code and regard that as an error.

class MyClass {
   #if NOT_NOW
   func hello(one: Int, two: Int) {
   }
   func hello(one: Int, three: Int) {
   }
   #endif
}
@swift-ci
Copy link
Collaborator Author

Comment by Edward Patel (JIRA)

Have referenced this from SR-2

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 3, 2016

I don't think SR-2 is related. That bug covers the fact that conditional compilation directives can only contain complete declarations/statements and cannot contain e.g. just some cases of a switch, or just the else block of an if-else. This bug here is instead reporting that the syntax checking of a non-active conditional compilation branch is incorrectly reporting overloaded methods as conflicting.

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 3, 2016

From looking at the code, it appears to be hitting the exact same code path that is responsible for throwing errors on shadowed variables, e.g.

var foo = 1
var foo = 2

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 3, 2016

Interestingly, moving the entire class into the conditional compilation directive compiles just fine:

#if NOT_NOW
class MyClass {
   func hello(one: Int, two: Int) {
   }
   func hello(one: Int, three: Int) {
   }
}
#endif

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 3, 2016

Submitted as PR #1522.

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 26, 2016

This was merged as d251c7a.

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 26, 2016

Please verify.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant