Skip to content

Missing fix-it when opaque property type is inferred #69241

Open
@natecook1000

Description

@natecook1000

Description
When the type of a variable or property is inferred as an opaque type, the compiler emits an error to that effect:

Property definition has inferred type 'some Proto', involving the 'some' return type of another declaration

Steps to reproduce
When compiling this code, the last line has the above error attached.:

protocol Proto {}
struct Concrete: Proto {}
func getProto() -> some Proto { Concrete() }

let value = getProto() // error

Expected behavior
Since the fix is straightforward and included in the error message, the compiler should offer a fixit that would rectify the problem:

let value: some Proto = getProto()

Environment

  • Swift compiler version info Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1) Target: arm64-apple-macosx14.0

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationfix-itsFeature: diagnostic fix-itsgood first issueGood for newcomersimprovementopaque result typesFeature → types → opaque types: opaque result typesopaque typesFeature → types: opaque typesswift 6.0type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions