Skip to content

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

@vanvoorden

Description

@vanvoorden

Description

This looks similar to #69241.

struct S1 {
  let w1 = Wrapper(getProto())
  //  Error: Property definition has inferred type 'Wrapper<some Proto>', involving the 'some' return type of another declaration
  let w2 = Wrapper(value)
  //  Error: Property definition has inferred type 'Wrapper<some Proto>', involving the 'some' return type of another declaration
}

Reproduction

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

let value = getProto()

struct Wrapper<P: Proto> {
  let value: P
  
  init(_ wrappedValue: P) {
    self.value = wrappedValue
  }
  
  var wrappedValue: P {
    self.value
  }
}

let w1 = Wrapper(getProto())

let w2 = Wrapper(value)

struct S1 {
  let w1 = Wrapper(getProto())
  //  Error: Property definition has inferred type 'Wrapper<some Proto>', involving the 'some' return type of another declaration
  let w2 = Wrapper(value)
  //  Error: Property definition has inferred type 'Wrapper<some Proto>', involving the 'some' return type of another declaration
}

Expected behavior

Compiles with no errors.

Environment

Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Apple Swift version 6.0-dev (LLVM 5b202efbc95a8bf, Swift a17d360d1cc66ab)
Apple Swift version 6.0-dev (LLVM 3417addab6ff197, Swift d677b7c23fd6355)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfnot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer erroropaque result typesFeature → types → opaque types: opaque result typesopaque typesFeature → types: opaque typespropertiesFeature: propertiesswift 6.0type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions