Files
swift-mirror/test/Interop/Cxx/class/fixits-for-std-vector.swift

48 lines
1.3 KiB
Swift

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop 2>&1 | %FileCheck %s
//--- Inputs/module.modulemap
module Test {
header "test.h"
requires cplusplus
}
//--- Inputs/test.h
#include <vector>
using V = std::vector<int>;
//--- test.swift
import Test
import CxxStdlib.vector
public func test(v: V) {
// CHECK: note: C++ method 'begin' that returns an iterator unavailable
// CHECK: note: Do you want to make a Swift iterator instead?
// CHECK: ^~~~~
// CHECK: makeIterator
_ = v.begin()
// CHECK: note: C++ method 'end' that returns an iterator unavailable
// CHECK: note: Do you want to compare against 'nil' instead?'
// CHECK: ^~~~
// CHECK: nil
_ = v.end()
// CHECK: note: C++ method 'front' that returns a reference of type 'UnsafePointer' is unavailable.
// CHECK: note: C++ method 'front' may return an interior pointer.
// CHECK: note: Do you want to get the first element instead?
// CHECK: ^~~~~~~
// CHECK: first
_ = v.front()
// CHECK: note: C++ method 'back' that returns a reference of type 'UnsafePointer' is unavailable.
// CHECK: note: C++ method 'back' may return an interior pointer.
// CHECK: note: Do you want to get the last element instead?
// CHECK: ^~~~~~
// CHECK: last
_ = v.back()
}