Files
swift-mirror/test/multifile/lazy.swift
John McCall 4f4d64b93e Various improvements to the variable-is-never-mutated diagnostic.
The main fixes here are:
- we weren't looking through open-existentials in the l-value
- we weren't handling mutating gets correctly unless CSApply wrapped
  the base in an InOutExpr, which seems to be multifile-sensitive
- we were missing diagnostics in some cases involving subscripts

A better fix would be to re-introduce LValueAccessKind, but I wanted
a workable short-term fix that I could try to get into 5.1.

Fixes rdar://49482742, which is specific to the lazy-getter problem.
2019-04-08 18:43:24 -04:00

18 lines
541 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify -primary-file %s %S/Inputs/external_lazy_property.swift
// RUN: %target-swift-frontend -emit-sil -verify -primary-file %s -primary-file %S/Inputs/external_lazy_property.swift
// rdar://45712204
func test1(s: Test1) {
_ = s.property // expected-error {{cannot use mutating getter on immutable value: 's' is a 'let' constant}}
}
func test2(s: Test2) {
_ = s.property
}
// rdar://49482742 - shouldn't warn about 's' never being mutated
func test3() {
var s = Test1()
_ = s.property
}