Skip to content

Instantly share code, notes, and snippets.

@matux
Created January 17, 2019 18:03
Show Gist options
  • Save matux/cf08132b597ffb80b1ec775c4f141475 to your computer and use it in GitHub Desktop.
Save matux/cf08132b597ffb80b1ec775c4f141475 to your computer and use it in GitHub Desktop.
// Swift compilation issue
// Shadowing across modules
// Module 1
public struct S {
public static var a = S(a: 0)
public var a: Int
public init(a: Int) { self.a = a }
}
// Module 2
extension S {
public static var z: S {
S.a.a = 0
return S.a // If S.a is in another module: Instance member 'a' cannot be used on type 'S'
}
}
////////////////
// Module 1
public struct S {
public var a: Int
public init(a: Int) { self.a = a }
}
// Module 2
extension S {
public static var a = S(a: 0)
public static var z: S {
S.a.a = 0 // Static member 'a' cannot be used on instance of type 'S'
return S.a
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment