Skip to content

[SR-3908] Extension methods visible without importing module in a file #46493

@aciidgh

Description

@aciidgh
Previous ID SR-3908
Radar rdar://problem/16154294
Original Reporter @aciidb0mb3r
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 9
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 7cc3dd991a1637efb2f2ca9e6d75b83d

is duplicated by:

Issue Description:

The attached package contains three targets:

  1. foo - defines a Version struct which can be initialized by a string param.
  2. bar - depends on foo and defines an extension with an initializer to Version with no parameters
  3. exe - depends on foo and bar and has two files.
  • other.swift - imports bar
  • main.swift - imports foo and calls Version()

This should not compile or run because Version() is defined in bar and bar is not imported in main.swift.
It works as expected after removing import bar from other.swift (needs a swift package clean though).

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselfdeclarationsFeature: declarationsextensionFeature → declarations: `extension` declarationsimportFeature → declarations: `import` declarationsmultiple modulesFlag: An issue whose reproduction requires multiple modulesname lookupArea → compiler → type checker: Name lookupswift 5.9swift evolution implementedFlag → feature: A feature that was approved through the Swift evolution process and implementedunexpected behaviorBug: Unexpected behavior or incorrect output

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions