Files
swift-mirror/test/Constraints/dynamic_lookup_swift6.swift
Becca Royal-Gordon 1fbded6629 Allow -swift-version 6 in asserts compilers only
To allow us to start testing language changes tied to a future Swift 6 mode without actually *shipping* a Swift 6 mode to customers who might accidentally use it before it's ready.

This commit also adds parallel tests for a number of already existing (but untested) Swift 6 mode behaviors.
2021-08-03 18:44:49 -07:00

25 lines
1.0 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module %S/Inputs/PrivateObjC.swift -o %t
// RUN: %target-typecheck-verify-swift -swift-version 6 -I %t -verify-ignore-unknown
// REQUIRES: objc_interop && asserts
import Foundation
import PrivateObjC
func test_dynamic_subscript_accepts_type_name_argument() {
@objc class A {
@objc subscript(a: A.Type) -> Int { get { 42 } }
}
func test(a: AnyObject, optA: AnyObject?) {
let _ = a[A] // expected-error {{expected member name or constructor call after type name}}
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{16-16=()}}
// expected-note@-2 {{use '.self' to reference the type object}} {{16-16=.self}}
let _ = optA?[A] // expected-error {{expected member name or constructor call after type name}}
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{20-20=()}}
// expected-note@-2 {{use '.self' to reference the type object}} {{20-20=.self}}
}
}