Files
swift-mirror/test/ClangImporter/objc_class_subscript.swift
Henrik G. Olsson cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00

33 lines
1.3 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %build-clang-importer-objc-overlays
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -typecheck -I %S/Inputs/custom-modules %s -verify -verify-ignore-unrelated
// REQUIRES: objc_interop
import ObjCSubscripts
func testClass() {
_ = NoClassSubscript[0] // expected-error{{type 'NoClassSubscript' has no member 'subscript'}}
NoClassSubscript[0] = "" // expected-error{{type 'NoClassSubscript' has no member 'subscript'}}
_ = NoClassSubscript["foo"] // expected-error{{type 'NoClassSubscript' has no member 'subscript'}}
NoClassSubscript["foo"] = "" // expected-error{{type 'NoClassSubscript' has no member 'subscript'}}
}
func testInstance(x: NoClassSubscript) {
_ = x[0] // expected-error{{value of type 'NoClassSubscript' has no subscripts}}
x[0] = "" // expected-error{{value of type 'NoClassSubscript' has no subscripts}}
_ = x["foo"] // expected-error{{value of type 'NoClassSubscript' has no subscripts}}
x["foo"] = "" // expected-error{{value of type 'NoClassSubscript' has no subscripts}}
}
func testClassMethods() {
_ = NoClassSubscript.object(atIndexedSubscript: 0)
NoClassSubscript.setObject("", atIndexedSubscript: 0)
_ = NoClassSubscript.object(forKeyedSubscript: "foo")
NoClassSubscript.setObject("", forKeyedSubscript: "foo")
}