Skip to content

Commit 87dd893

Browse files
egorzhdanzoecarver
authored andcommitted
[cxx-interop] Update tests for mutable struct fields
Methods that are marked as `const` in C++ can still modify a field of the object if the field is marked as `mutable`. We previously imported all methods of structs with mutable fields as mutating in Swift. Unfortunately this doesn't work well with libstdc++, which uses mutable fields for some commonly used container types. Our current user model assumes that we trust the `const` keyword on a C++ method, and import them as non-mutating in Swift. Let's make sure the tests reflect that.
1 parent 624f553 commit 87dd893

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// RUN: %target-swift-ide-test -print-module -module-to-print=MutableMembers -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
22

3-
// REQUIRES: rdar91961524
4-
53
// CHECK: struct HasPublicMutableMember {
6-
// CHECK: mutating func foo() -> Int32
4+
// CHECK: func foo() -> Int32
75
// CHECK: var a: Int32
86
// CHECK: }
97

108
// CHECK: struct HasPrivateMutableMember {
11-
// CHECK: mutating func bar()
9+
// CHECK: func bar()
1210
// CHECK: }
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// RUN: %target-typecheck-verify-swift -I %S/Inputs -enable-experimental-cxx-interop
2-
3-
// REQUIRES: rdar91961524
2+
// expect-no-diagnostics
43

54
import MutableMembers
65

7-
let obj = HasPublicMutableMember(a: 42) // expected-note {{change 'let' to 'var' to make it mutable}}
8-
let i = obj.foo() // expected-error {{cannot use mutating member on immutable value: 'obj' is a 'let' constant}}
6+
let obj = HasPublicMutableMember(a: 42)
7+
let i = obj.foo()

test/Interop/Cxx/class/mutable-members.swift

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)