Skip to content

[SR-11183] There should be a way to disambiguate methods/properties/nested types with the same name in the same type defined in extensions in different modules #53580

@swift-ci

Description

@swift-ci
Previous ID SR-11183
Radar rdar://problem/17275821
Original Reporter broadway_lamb (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 88bc464882feb2ff1ad6082004a35c49

relates to:

  • SR-1842 Introduce syntax for explicitly invoking extension methods.

Issue Description:

Right now if two modules extend a type with a method/property with the same name, there's no way to refer to any of them in a client module:

// Module A
extension Int {
    public struct Nested {
        public init() {}
    }
    public func whatModuleIsThis() -> String { "A" }
}

// Module B
extension Int {
    public struct Nested {
        public init() {}
    }
    public func whatModuleIsThis() -> String { "B" }
}

// Module C
import A
import B

func ambiguous(_ n: Int) -> String {
    // error: Ambiguous type name 'Nested' in 'Int'
    return n.whatModuleIsThis() + String(describing: Int.Nested())
}

I couldn't find a bug for this, so I figured I should create one.

I'd like to work on supporting this in the compiler, and then pitch a syntax for disambiguation, with a working implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions