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-12646] Ambiguous type name error in Module Interface #55090

Open
swift-ci opened this issue Apr 21, 2020 · 2 comments
Open

[SR-12646] Ambiguous type name error in Module Interface #55090

swift-ci opened this issue Apr 21, 2020 · 2 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Apr 21, 2020

Previous ID SR-12646
Radar rdar://problem/62202466
Original Reporter leavez (JIRA User)
Type Bug

Attachment: Download

Environment

Test on xcode 11.4 and Swift toolchain snapshot 2020-04-19

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ParseableInterfaces
Assignee @slavapestov
Priority Medium

md5: 61fa54ea5c7a0723325eb34c5b8b74da

Issue Description:

Problem

The generated module interface file below will got an error when parsed by xcode.

// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.3-dev (LLVM 5e4413896d, Swift f0df46771f)
// swift-module-flags: -target x86_64-apple-ios8.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -module-name A
@_exported import A
import Foundation
import Swift
public protocol Pt {
  typealias AnotherName = Swift.String
}
@_hasMissingDesignatedInitializers public class Name<T> : A.Pt {
  public typealias AnotherName = Swift.Int
  public func hi() -> A.Name<T>.AnotherName
  @objc deinit
}

("A" is the name of the framework)

Source code

public protocol Pt {
    typealias AnotherName = String
}

public class Name<T>: Pt {
    public typealias AnotherName = Int
    public func hi() -> AnotherName {
        return 0
    }
}

Steps to Reproduce

  1. build a framework with the source above, with "Build Libraries for Distribution" enabled

  2. delete the .swiftinterface files in the framework

  3. add the generated framework to another project, import and build

Why Important

The module interface cannot be used , which means module stability never achieve its goal.

@slavapestov
Copy link
Member

@slavapestov slavapestov commented Apr 22, 2020

Ah, nice catch!

It appears that qualified lookup and unqualified lookup behave inconsistently here. If I change the source code to reference AnotherName as a member of Name, I get the same error:

qq.swift:7:33: error: ambiguous type name 'AnotherName' in 'Name<T>'
    public func hi() -> Name<T>.AnotherName {
                        ~~~~~~~ ^
qq.swift:6:22: note: found candidate with type 'Name<T>.AnotherName' (aka 'Int')
    public typealias AnotherName = Int
                     ^
qq.swift:2:15: note: found candidate with type 'Name<T>.AnotherName' (aka 'String')
    typealias AnotherName = String
              ^

It would make sense for qualified lookup to have the same shadowing behavior as unqualified here, and ignore the protocol member if we find a member in the immediate type. I'll take a look.

@slavapestov
Copy link
Member

@slavapestov slavapestov commented Apr 22, 2020

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants