Files
swift-mirror/test/stdlib/UnicodeScalarDiagnostics.swift
Joe Pamer cae36c9c9d Broaden the "favored constraint" binop optimization to work with simplified expression types, and not just default literal tyvars.
This addresses or improves several existing TC perf bugs (rdar://problem/15933674, rdar://problem/17110608, rdar://problem/17240816, rdar://problem/17244974), and seems to speed up our unit test runs by ~5%. (On my MacBook Pro, total average execution time is reduced from 557.28s to 531.89s.)

Swift SVN r19939
2014-07-14 19:20:49 +00:00

28 lines
1.5 KiB
Swift

// RUN: %swift %s -parse -verify
func isString(inout s: String) {}
func test_UnicodeScalarDoesNotImplementArithmetic(us: UnicodeScalar, i: Int) {
var a1 = "a" + "b" // OK
isString(&a1)
let a2 = "a" - "b" // expected-error {{type 'UInt8' does not conform to protocol 'ExtendedGraphemeClusterLiteralConvertible'}}
let a3 = "a" * "b" // expected-error {{type 'UInt8' does not conform to protocol 'ExtendedGraphemeClusterLiteralConvertible'}}
let a4 = "a" / "b" // expected-error {{type 'UInt8' does not conform to protocol 'ExtendedGraphemeClusterLiteralConvertible'}}
let b1 = us + us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let b2 = us - us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let b3 = us * us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let b4 = us / us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let c1 = us + i // expected-error {{'UnicodeScalar' is not convertible to 'Int'}}
let c2 = us - i // expected-error {{'UnicodeScalar' is not convertible to 'Int'}}
let c3 = us * i // expected-error {{'UnicodeScalar' is not convertible to 'Int'}}
let c4 = us / i // expected-error {{'UnicodeScalar' is not convertible to 'Int'}}
let d1 = i + us // expected-error {{'Int' is not convertible to 'UInt8'}}
let d2 = i - us // expected-error {{'Int' is not convertible to 'UInt8'}}
let d3 = i * us // expected-error {{'Int' is not convertible to 'UInt8'}}
let d4 = i / us // expected-error {{'Int' is not convertible to 'UInt8'}}
}