mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSSimplify] Rework how/when mismatches between optional types are fixed
- Don't attempt to insert fixes if there are restrictions present, they'd inform the failures. Inserting fixes too early doesn't help the solver because restriction matching logic would record the same fixes. - Adjust impact of the fixes. Optional conversions shouldn't impact the score in any way because they are not the source of the issue. - Look through one level of optional when failure is related to optional injection. The diagnostic is going to be about underlying type, so there is no reason to print optional on right-hand side.
This commit is contained in:
@@ -3978,8 +3978,19 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
|
||||
path.back().is<LocatorPathElt::GenericArgument>()))
|
||||
path.pop_back();
|
||||
|
||||
auto *fixLoc = getConstraintLocator(anchor, path);
|
||||
// If after looking through optionals and generic arguments
|
||||
// we end up directly on assignment this is a source/destination
|
||||
// type mismatch.
|
||||
if (fixLoc->directlyAt<AssignExpr>()) {
|
||||
auto *fix = IgnoreAssignmentDestinationType::create(
|
||||
*this, type1, type2, fixLoc);
|
||||
return recordFix(fix) ? getTypeMatchFailure(locator)
|
||||
: getTypeMatchSuccess();
|
||||
}
|
||||
|
||||
auto *fix = AllowNonClassTypeToConvertToAnyObject::create(
|
||||
*this, type1, getConstraintLocator(anchor, path));
|
||||
*this, type1, fixLoc);
|
||||
|
||||
return recordFix(fix) ? getTypeMatchFailure(locator)
|
||||
: getTypeMatchSuccess();
|
||||
@@ -5341,6 +5352,9 @@ bool ConstraintSystem::repairFailures(
|
||||
if (repairViaBridgingCast(*this, lhs, rhs, conversionsOrFixes, locator))
|
||||
return true;
|
||||
|
||||
if (hasAnyRestriction())
|
||||
return false;
|
||||
|
||||
// If destination is `AnyObject` it means that source doesn't conform.
|
||||
if (rhs->getWithoutSpecifierType()
|
||||
->lookThroughAllOptionalTypes()
|
||||
@@ -5350,60 +5364,6 @@ bool ConstraintSystem::repairFailures(
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we are trying to assign e.g. `Array<Int>` to `Array<Float>` let's
|
||||
// give solver a chance to determine which generic parameters are
|
||||
// mismatched and produce a fix for that.
|
||||
if (hasConversionOrRestriction(ConversionRestrictionKind::DeepEquality))
|
||||
return false;
|
||||
|
||||
// An attempt to assign `Int?` to `String?`.
|
||||
if (hasConversionOrRestriction(
|
||||
ConversionRestrictionKind::OptionalToOptional)) {
|
||||
conversionsOrFixes.push_back(IgnoreAssignmentDestinationType::create(
|
||||
*this, lhs, rhs, getConstraintLocator(locator)));
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the situation has to do with protocol composition types and
|
||||
// destination doesn't have one of the conformances e.g. source is
|
||||
// `X & Y` but destination is only `Y` or vice versa, there is a
|
||||
// tailored "missing conformance" fix for that.
|
||||
if (hasConversionOrRestriction(ConversionRestrictionKind::Existential))
|
||||
return false;
|
||||
|
||||
if (hasConversionOrRestriction(
|
||||
ConversionRestrictionKind::MetatypeToExistentialMetatype) ||
|
||||
hasConversionOrRestriction(
|
||||
ConversionRestrictionKind::ExistentialMetatypeToMetatype) ||
|
||||
hasConversionOrRestriction(ConversionRestrictionKind::Superclass)) {
|
||||
conversionsOrFixes.push_back(IgnoreAssignmentDestinationType::create(
|
||||
*this, lhs, rhs, getConstraintLocator(locator)));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasConversionOrRestriction(
|
||||
ConversionRestrictionKind::ValueToOptional)) {
|
||||
lhs = lhs->lookThroughAllOptionalTypes();
|
||||
rhs = rhs->lookThroughAllOptionalTypes();
|
||||
|
||||
// If both object types are functions, let's allow the solver to
|
||||
// structurally compare them before trying to fix anything.
|
||||
if (lhs->is<FunctionType>() && rhs->is<FunctionType>())
|
||||
return false;
|
||||
|
||||
// If either object type is a generic, nominal or existential type
|
||||
// it means that follow-up to value-to-optional is going to be:
|
||||
//
|
||||
// 1. "deep equality" check, which is handled by generic argument(s)
|
||||
// or contextual mismatch fix, or
|
||||
// 2. "existential" check, which is handled by a missing conformance
|
||||
// fix.
|
||||
if ((lhs->is<BoundGenericType>() && rhs->is<BoundGenericType>()) ||
|
||||
(lhs->is<NominalType>() && rhs->is<NominalType>()) ||
|
||||
rhs->isAnyExistentialType())
|
||||
return false;
|
||||
}
|
||||
|
||||
auto *destExpr = AE->getDest();
|
||||
// Literal expression as well as call/operator application can't be
|
||||
// used as an assignment destination because resulting type is immutable.
|
||||
@@ -14216,14 +14176,23 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
|
||||
if (hasFixFor(loc, FixKind::AllowTupleTypeMismatch))
|
||||
return true;
|
||||
|
||||
if (restriction == ConversionRestrictionKind::ValueToOptional ||
|
||||
restriction == ConversionRestrictionKind::OptionalToOptional)
|
||||
++impact;
|
||||
if (restriction == ConversionRestrictionKind::ValueToOptional) {
|
||||
// If this is an optional injection we can drop optional from
|
||||
// "to" type since it's not significant for the diagnostic.
|
||||
toType = toType->getOptionalObjectType();
|
||||
}
|
||||
|
||||
auto *fix =
|
||||
loc->isLastElement<LocatorPathElt::ApplyArgToParam>()
|
||||
? AllowArgumentMismatch::create(*this, fromType, toType, loc)
|
||||
: ContextualMismatch::create(*this, fromType, toType, loc);
|
||||
ConstraintFix *fix = nullptr;
|
||||
if (loc->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
|
||||
fix = AllowArgumentMismatch::create(*this, fromType, toType, loc);
|
||||
} else if (loc->isForAssignment()) {
|
||||
fix = IgnoreAssignmentDestinationType::create(*this, fromType, toType,
|
||||
loc);
|
||||
} else {
|
||||
fix = ContextualMismatch::create(*this, fromType, toType, loc);
|
||||
}
|
||||
|
||||
assert(fix);
|
||||
return !recordFix(fix, impact);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ import APINotesFrameworkTest
|
||||
|
||||
|
||||
func testChangedTypes(tc: TypeChanges, a: A, i: Int) {
|
||||
_ = tc.method(with: i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'A?'}}
|
||||
_ = tc.method(with: i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'A'}}
|
||||
let _: Int = tc.method(with: a) // expected-error{{cannot convert value of type 'A' to specified type 'Int'}}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ BridgingHeader.takeForward(SwiftClass(x: 42))
|
||||
BridgingHeader.takeRenamedForward(CustomNameClass())
|
||||
|
||||
// Check that we're compiling at all.
|
||||
BridgingHeader.takeRenamedForward(SwiftClass(x: 42)) // expected-error {{cannot convert value of type 'SwiftClass' to expected argument type 'CustomNameClass?'}}
|
||||
BridgingHeader.takeRenamedForward(SwiftClass(x: 42)) // expected-error {{cannot convert value of type 'SwiftClass' to expected argument type 'CustomNameClass'}}
|
||||
|
||||
@@ -16,7 +16,7 @@ func test0(_ fridge: CCRefrigerator) {
|
||||
|
||||
func test1(_ power: Unmanaged<CCPowerSupply>) {
|
||||
assertUnmanaged(power)
|
||||
let fridge = CCRefrigeratorCreate(power) // expected-error {{cannot convert value of type 'Unmanaged<CCPowerSupply>' to expected argument type 'CCPowerSupply?'}}
|
||||
let fridge = CCRefrigeratorCreate(power) // expected-error {{cannot convert value of type 'Unmanaged<CCPowerSupply>' to expected argument type 'CCPowerSupply'}}
|
||||
assertUnmanaged(fridge) // expected-error {{generic parameter 'T' could not be inferred}}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ func test9() {
|
||||
CCRefrigeratorOpen(fridge)
|
||||
let item = CCRefrigeratorGet(fridge, 0).takeUnretainedValue()
|
||||
// TODO(diagnostics): In this case we should probably suggest to flip `item` and `fridge`
|
||||
CCRefrigeratorInsert(item, fridge) // expected-error {{cannot convert value of type 'CCItem' to expected argument type 'CCMutableRefrigerator?'}}
|
||||
// expected-error@-1 {{cannot convert value of type 'CCMutableRefrigerator' to expected argument type 'CCItem?'}}
|
||||
CCRefrigeratorInsert(constFridge, item) // expected-error {{cannot convert value of type 'CCRefrigerator' to expected argument type 'CCMutableRefrigerator?'}}
|
||||
CCRefrigeratorInsert(item, fridge) // expected-error {{cannot convert value of type 'CCItem' to expected argument type 'CCMutableRefrigerator'}}
|
||||
// expected-error@-1 {{cannot convert value of type 'CCMutableRefrigerator' to expected argument type 'CCItem'}}
|
||||
CCRefrigeratorInsert(constFridge, item) // expected-error {{cannot convert value of type 'CCRefrigerator' to expected argument type 'CCMutableRefrigerator'}}
|
||||
CCRefrigeratorInsert(fridge, item)
|
||||
CCRefrigeratorClose(fridge)
|
||||
}
|
||||
@@ -121,12 +121,12 @@ func testOutParametersBad() {
|
||||
|
||||
let power: CCPowerSupply?
|
||||
CCRefrigeratorGetPowerSupplyIndirect(0, power)
|
||||
// expected-error@-1:40 {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator?'}}
|
||||
// expected-error@-1:40 {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator'}}
|
||||
// expected-error@-2:43 {{cannot convert value of type 'CCPowerSupply?' to expected argument type 'AutoreleasingUnsafeMutablePointer<CCPowerSupply?>'}}
|
||||
|
||||
let item: CCItem?
|
||||
CCRefrigeratorGetItemUnaudited(0, 0, item)
|
||||
// expected-error@-1:34 {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator?'}}
|
||||
// expected-error@-1:34 {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator'}}
|
||||
// expected-error@-2:40 {{cannot convert value of type 'CCItem?' to expected argument type 'UnsafeMutablePointer<Unmanaged<CCItem>?>?'}}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,8 +187,8 @@ func test_nested_pointers() {
|
||||
nested_pointer_audited(nil)
|
||||
nested_pointer_audited2(nil) // expected-error {{'nil' is not compatible with expected argument type 'UnsafePointer<UnsafePointer<Int32>?>'}}
|
||||
|
||||
nested_pointer(0) // expected-error {{expected argument type 'UnsafePointer<UnsafePointer<Int32>?>?'}}
|
||||
nested_pointer_audited(0) // expected-error {{expected argument type 'UnsafePointer<UnsafePointer<Int32>>?'}}
|
||||
nested_pointer(0) // expected-error {{expected argument type 'UnsafePointer<UnsafePointer<Int32>?>'}}
|
||||
nested_pointer_audited(0) // expected-error {{expected argument type 'UnsafePointer<UnsafePointer<Int32>>'}}
|
||||
nested_pointer_audited2(0) // expected-error {{expected argument type 'UnsafePointer<UnsafePointer<Int32>?>'}}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,5 +66,5 @@ func testCF(_ fridge: CCRefrigerator) {
|
||||
CCRefrigeratorOpenMaybeDoSomething(fridge) // okay
|
||||
CCRefrigeratorOpenMaybeDoSomething(nil) // okay
|
||||
|
||||
CCRefrigeratorOpenMaybeDoSomething(5) // expected-error{{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator?'}}
|
||||
CCRefrigeratorOpenMaybeDoSomething(5) // expected-error{{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator'}}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ idLover.takesArray(ofId: &y) // expected-error{{cannot convert value of type 'Un
|
||||
idLover.takesId(x)
|
||||
idLover.takesId(y)
|
||||
|
||||
install_global_event_handler(idLover) // expected-error {{cannot convert value of type 'NSIdLover' to expected argument type 'event_handler?' (aka 'Optional<@convention(c) (Any) -> ()>')}}
|
||||
install_global_event_handler(idLover) // expected-error {{cannot convert value of type 'NSIdLover' to expected argument type 'event_handler' (aka '@convention(c) (Any) -> ()')}}
|
||||
|
||||
// FIXME: this should not type-check!
|
||||
// Function conversions are not legal when converting to a thin function type.
|
||||
|
||||
@@ -483,7 +483,7 @@ actor A2 {
|
||||
await { (self: isolated Self) in }(self)
|
||||
// expected-typechecker-error@-1 {{cannot convert value of type 'A2' to expected argument type 'Self'}}
|
||||
await { (self: isolated Self?) in }(self)
|
||||
// expected-typechecker-error@-1 {{cannot convert value of type 'A2' to expected argument type 'Self?'}}
|
||||
// expected-typechecker-error@-1 {{cannot convert value of type 'A2' to expected argument type 'Self'}}
|
||||
#endif
|
||||
}
|
||||
nonisolated func f2() async -> Self {
|
||||
|
||||
@@ -85,6 +85,6 @@ class С_56396 {
|
||||
var callback: ((С_56396) -> Void)!
|
||||
|
||||
func setCallback(_ callback: @escaping (Self) -> Void) {
|
||||
self.callback = callback // expected-error {{cannot assign value of type '(Self) -> Void' to type '((С_56396) -> Void)?'}}
|
||||
self.callback = callback // expected-error {{cannot assign value of type '(Self) -> Void' to type '(С_56396) -> Void'}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ var afterMessageCount : Int?
|
||||
func uintFunc() -> UInt {}
|
||||
func takeVoidVoidFn(_ a : () -> ()) {}
|
||||
takeVoidVoidFn { () -> Void in
|
||||
afterMessageCount = uintFunc() // expected-error {{cannot assign value of type 'UInt' to type 'Int?'}} {{23-23=Int(}} {{33-33=)}}
|
||||
afterMessageCount = uintFunc() // expected-error {{cannot assign value of type 'UInt' to type 'Int'}} {{23-23=Int(}} {{33-33=)}}
|
||||
}
|
||||
|
||||
// <rdar://problem/19997471> Swift: Incorrect compile error when calling a function inside a closure
|
||||
|
||||
@@ -362,5 +362,5 @@ func testKeyPathSubscriptArgFixes(_ fn: @escaping () -> Int) {
|
||||
|
||||
// https://github.com/apple/swift/issues/54865
|
||||
func f_54865(a: Any, _ str: String?) {
|
||||
a == str // expected-error {{binary operator '==' cannot be applied to operands of type 'Any' and 'String?'}}
|
||||
a == str // expected-error {{cannot convert value of type 'Any' to expected argument type 'String'}}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func rdar_59703585() {
|
||||
var cb: Fn? = nil
|
||||
|
||||
cb = swiftCallback
|
||||
// expected-error@-1 {{cannot assign value of type '(UnsafePointer<Int8>, UnsafeMutableRawPointer?) -> ()' to type 'Fn?' (aka 'Optional<@convention(c) (Optional<UnsafePointer<Int8>>, Optional<UnsafeMutableRawPointer>) -> ()>')}}
|
||||
// expected-error@-1 {{cannot assign value of type '(UnsafePointer<Int8>, UnsafeMutableRawPointer?) -> ()' to type 'Fn' (aka '@convention(c) (Optional<UnsafePointer<Int8>>, Optional<UnsafeMutableRawPointer>) -> ()')}}
|
||||
}
|
||||
|
||||
// https://github.com/apple/swift/issues/57216
|
||||
|
||||
@@ -277,7 +277,7 @@ func rdar_60185506() {
|
||||
func rdar60727310() {
|
||||
func myAssertion<T>(_ a: T, _ op: ((T,T)->Bool), _ b: T) {}
|
||||
var e: Error? = nil
|
||||
myAssertion(e, ==, nil) // expected-error {{binary operator '==' cannot be applied to two '(any Error)?' operands}}
|
||||
myAssertion(e, ==, nil) // expected-error {{cannot convert value of type '(any Error)?' to expected argument type '(any Any.Type)?'}}
|
||||
}
|
||||
|
||||
// https://github.com/apple/swift/issues/54877
|
||||
|
||||
@@ -304,12 +304,12 @@ func test_array_to_pointer_conversion() {
|
||||
void_ptr_func(&x${Size}) // Ok
|
||||
const_void_ptr_func(x${Size}) // Ok
|
||||
opt_void_ptr_func(x${Size})
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutableRawPointer?'}}
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
|
||||
char_ptr_func(x${Size})
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>' (aka 'UnsafeMutablePointer<Int8>')}}
|
||||
opt_char_ptr_func(x${Size})
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>?' (aka 'Optional<UnsafeMutablePointer<Int8>>')}}
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>' (aka 'UnsafeMutablePointer<Int8>')}}
|
||||
|
||||
const_char_ptr_func(x${Size}) // Ok
|
||||
const_opt_char_ptr_func(x${Size}) // Ok
|
||||
@@ -320,9 +320,9 @@ func test_array_to_pointer_conversion() {
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>'}}
|
||||
|
||||
opt_int_${Size}_ptr_func(x${Size})
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<Int${Size}>?'}}
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<Int${Size}>'}}
|
||||
opt_uint_${Size}_ptr_func(x${Size})
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>?'}}
|
||||
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>'}}
|
||||
|
||||
const_int_${Size}_ptr_func(x${Size}) // OK
|
||||
const_uint_${Size}_ptr_func(x${Size}) // OK
|
||||
|
||||
@@ -269,7 +269,7 @@ class Dinner {}
|
||||
|
||||
func microwave() -> Dinner? {
|
||||
let d: Dinner? = nil
|
||||
return (n: d) // expected-error{{cannot convert return expression of type '(n: Dinner?)' to return type 'Dinner?'}}
|
||||
return (n: d) // expected-error{{cannot convert return expression of type '(n: Dinner?)' to return type 'Dinner'}}
|
||||
}
|
||||
|
||||
func microwave() -> Dinner {
|
||||
@@ -335,7 +335,7 @@ tuple = (bignum, 1) // expected-error {{cannot assign value of type '(Int64, Int
|
||||
|
||||
var optionalTuple: (Int, Int)?
|
||||
var optionalTuple2: (Int64, Int)? = (bignum, 1)
|
||||
var optionalTuple3: (UInt64, Int)? = (bignum, 1) // expected-error {{cannot convert value of type '(Int64, Int)' to specified type '(UInt64, Int)?'}}
|
||||
var optionalTuple3: (UInt64, Int)? = (bignum, 1) // expected-error {{cannot convert value of type '(Int64, Int)' to specified type '(UInt64, Int)'}}
|
||||
|
||||
optionalTuple = (bignum, 1) // expected-error {{cannot assign value of type '(Int64, Int)' to type '(Int, Int)'}}
|
||||
// Optional to Optional
|
||||
|
||||
@@ -30,8 +30,8 @@ func givesPtr(_ str: String) {
|
||||
takesMutableDoubleOptionalPtr(&arr)
|
||||
takesMutableDoubleOptionalTypedPtr(&d)
|
||||
|
||||
takesDoubleOptionalPtr(i) // expected-error {{cannot convert value of type 'Int' to expected argument type 'UnsafeRawPointer??'}}
|
||||
takesMutableDoubleOptionalPtr(arr) // expected-error {{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer??'}}
|
||||
takesDoubleOptionalPtr(i) // expected-error {{cannot convert value of type 'Int' to expected argument type 'UnsafeRawPointer?'}}
|
||||
takesMutableDoubleOptionalPtr(arr) // expected-error {{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer?'}}
|
||||
|
||||
takesMutableDoubleOptionalTypedPtr(&i) // expected-error {{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Double>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int' and 'Double') are expected to be equal}}
|
||||
|
||||
@@ -12,13 +12,10 @@
|
||||
%{
|
||||
if OPT_KIND == 'Optional':
|
||||
suffix='?'
|
||||
diag_suffix='?'
|
||||
elif OPT_KIND == 'ImplicitlyUnwrappedOptional':
|
||||
suffix='!'
|
||||
diag_suffix='?'
|
||||
else:
|
||||
suffix=''
|
||||
diag_suffix=''
|
||||
}%
|
||||
|
||||
class C {}
|
||||
@@ -44,21 +41,21 @@ func mutablePointerArguments(_ p: UnsafeMutablePointer<Int>,
|
||||
% end
|
||||
|
||||
takesMutablePointer(p)
|
||||
takesMutablePointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'UnsafeMutablePointer<Int>${diag_suffix}'}}
|
||||
takesMutablePointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
var i: Int = 0
|
||||
var f: Float = 0
|
||||
takesMutablePointer(&i)
|
||||
takesMutablePointer(&f) // expected-error{{cannot convert value of type 'UnsafeMutablePointer<Float>' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Float' and 'Int') are expected to be equal}}
|
||||
takesMutablePointer(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'UnsafeMutablePointer<Int>${diag_suffix}'}}
|
||||
takesMutablePointer(f) // expected-error{{cannot convert value of type 'Float' to expected argument type 'UnsafeMutablePointer<Int>${diag_suffix}'}}
|
||||
takesMutablePointer(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
takesMutablePointer(f) // expected-error{{cannot convert value of type 'Float' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
var ii: [Int] = [0, 1, 2]
|
||||
var ff: [Float] = [0, 1, 2]
|
||||
takesMutablePointer(&ii)
|
||||
takesMutablePointer(&ff) // expected-error{{cannot convert value of type 'UnsafeMutablePointer<Float>' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Float' and 'Int') are expected to be equal}}
|
||||
takesMutablePointer(ii) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutablePointer<Int>${diag_suffix}'}}
|
||||
takesMutablePointer(ff) // expected-error{{cannot convert value of type '[Float]' to expected argument type 'UnsafeMutablePointer<Int>${diag_suffix}'}}
|
||||
takesMutablePointer(ii) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
takesMutablePointer(ff) // expected-error{{cannot convert value of type '[Float]' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
|
||||
takesMutableArrayPointer(&i) // expected-error{{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<[Int]>'}}
|
||||
//expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int' and '[Int]') are expected to be equal}}
|
||||
@@ -80,21 +77,21 @@ func mutableVoidPointerArguments(_ p: UnsafeMutablePointer<Int>,
|
||||
|
||||
takesMutableVoidPointer(p)
|
||||
takesMutableVoidPointer(fp)
|
||||
takesMutableVoidPointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableVoidPointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
var i: Int = 0
|
||||
var f: Float = 0
|
||||
takesMutableVoidPointer(&i)
|
||||
takesMutableVoidPointer(&f)
|
||||
takesMutableVoidPointer(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableVoidPointer(f) // expected-error{{cannot convert value of type 'Float' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableVoidPointer(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesMutableVoidPointer(f) // expected-error{{cannot convert value of type 'Float' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
var ii: [Int] = [0, 1, 2]
|
||||
var dd: [CInt] = [1, 2, 3]
|
||||
var ff: [Int] = [0, 1, 2]
|
||||
takesMutableVoidPointer(&ii)
|
||||
takesMutableVoidPointer(&dd)
|
||||
takesMutableVoidPointer(&ff)
|
||||
takesMutableVoidPointer(ii) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableVoidPointer(ff) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableVoidPointer(ii) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesMutableVoidPointer(ff) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
|
||||
// We don't allow these conversions outside of function arguments.
|
||||
var x: UnsafeMutableRawPointer = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
|
||||
@@ -114,22 +111,22 @@ func mutableRawPointerArguments(_ p: UnsafeMutablePointer<Int>,
|
||||
|
||||
takesMutableRawPointer(p)
|
||||
takesMutableRawPointer(fp)
|
||||
takesMutableRawPointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableRawPointer(rp) // expected-error{{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableRawPointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesMutableRawPointer(rp) // expected-error{{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
var i: Int = 0
|
||||
var f: Float = 0
|
||||
takesMutableRawPointer(&i)
|
||||
takesMutableRawPointer(&f)
|
||||
takesMutableRawPointer(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableRawPointer(f) // expected-error{{cannot convert value of type 'Float' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableRawPointer(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesMutableRawPointer(f) // expected-error{{cannot convert value of type 'Float' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
var ii: [Int] = [0, 1, 2]
|
||||
var dd: [CInt] = [1, 2, 3]
|
||||
var ff: [Int] = [0, 1, 2]
|
||||
takesMutableRawPointer(&ii)
|
||||
takesMutableRawPointer(&dd)
|
||||
takesMutableRawPointer(&ff)
|
||||
takesMutableRawPointer(ii) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableRawPointer(ff) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableRawPointer(ii) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesMutableRawPointer(ff) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
|
||||
// We don't allow these conversions outside of function arguments.
|
||||
var x: UnsafeMutableRawPointer = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
|
||||
@@ -256,14 +253,14 @@ func stringArguments(_ s: String) {
|
||||
takesConstRawPointer(s)
|
||||
takesConstInt8Pointer(s)
|
||||
takesConstUInt8Pointer(s)
|
||||
takesConstPointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafePointer<Int>${diag_suffix}'}}
|
||||
takesConstPointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafePointer<Int>'}}
|
||||
|
||||
takesMutableVoidPointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableRawPointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutableInt8Pointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutablePointer<Int8>${diag_suffix}'}}
|
||||
takesMutableVoidPointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesMutableRawPointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesMutableInt8Pointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutablePointer<Int8>'}}
|
||||
takesMutableInt8Pointer(&s) // expected-error{{cannot convert value of type 'UnsafeMutablePointer<String>' to expected argument type 'UnsafeMutablePointer<Int8>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('String' and 'Int8') are expected to be equal}}
|
||||
takesMutablePointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutablePointer<Int>${diag_suffix}'}}
|
||||
takesMutablePointer(s) // expected-error{{cannot convert value of type 'String' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
takesMutablePointer(&s) // expected-error{{cannot convert value of type 'UnsafeMutablePointer<String>' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('String' and 'Int') are expected to be equal}}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,10 @@
|
||||
%{
|
||||
if OPT_KIND == 'Optional':
|
||||
suffix='?'
|
||||
diag_suffix='?'
|
||||
elif OPT_KIND == 'ImplicitlyUnwrappedOptional':
|
||||
suffix='!'
|
||||
diag_suffix='?'
|
||||
else:
|
||||
suffix=''
|
||||
diag_suffix=''
|
||||
}%
|
||||
|
||||
class C {}
|
||||
@@ -36,8 +33,8 @@ func takesAutoreleasingPointer(_ x: AutoreleasingUnsafeMutablePointer<C>${suffix
|
||||
|
||||
func pointerArgumentsObjC(ap: AutoreleasingUnsafeMutablePointer<Int>,
|
||||
afp: AutoreleasingUnsafeMutablePointer<Float>) {
|
||||
takesMutablePointer(ap) // expected-error{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Int>${diag_suffix}'}}
|
||||
takesMutableVoidPointer(ap) // expected-error{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
|
||||
takesMutablePointer(ap) // expected-error{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
takesMutableVoidPointer(ap) // expected-error{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
takesConstPointer(ap)
|
||||
takesConstVoidPointer(ap)
|
||||
takesConstVoidPointer(afp)
|
||||
@@ -55,17 +52,17 @@ func autoreleasingPointerArguments(p: UnsafeMutablePointer<Int>,
|
||||
// expected-error@-2 {{'nil' is not compatible with expected argument type}}
|
||||
% end
|
||||
|
||||
takesAutoreleasingPointer(p) // expected-error{{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>${diag_suffix}'}}
|
||||
takesAutoreleasingPointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>${diag_suffix}'}}
|
||||
takesAutoreleasingPointer(p) // expected-error{{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>'}}
|
||||
takesAutoreleasingPointer(cp) // expected-error{{cannot convert value of type 'UnsafePointer<Int>' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>'}}
|
||||
takesAutoreleasingPointer(ap)
|
||||
|
||||
var c: C = C()
|
||||
takesAutoreleasingPointer(&c)
|
||||
takesAutoreleasingPointer(c) // expected-error{{cannot convert value of type 'C' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>${diag_suffix}'}}
|
||||
takesAutoreleasingPointer(c) // expected-error{{cannot convert value of type 'C' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>'}}
|
||||
var d: D = D()
|
||||
takesAutoreleasingPointer(&d) // expected-error{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<D>' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('D' and 'C') are expected to be equal}}
|
||||
takesAutoreleasingPointer(d) // expected-error{{cannot convert value of type 'D' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>${diag_suffix}'}}
|
||||
takesAutoreleasingPointer(d) // expected-error{{cannot convert value of type 'D' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>'}}
|
||||
var cc: [C] = [C(), C()]
|
||||
var dd: [D] = [D(), D()]
|
||||
takesAutoreleasingPointer(&cc) // expected-error{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<[C]>' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>'}}
|
||||
|
||||
@@ -40,10 +40,10 @@ let _ : @convention(c, cType: "size_t (*)(size_t)") (Int) -> Int = fs
|
||||
let f2 : (@convention(c) ((@convention(c, cType: "size_t (*)(size_t)") (Swift.Int) -> Swift.Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Swift.Int) -> Swift.Int)?)? = getHigherOrderFunctionPointer()!
|
||||
|
||||
let _ : (@convention(c) ((@convention(c) (Swift.Int) -> Swift.Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Swift.Int) -> Swift.Int)?)? = f2!
|
||||
// expected-error@-1{{cannot convert value of type '@convention(c) ((@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?' to specified type '(@convention(c) ((@convention(c) (Int) -> Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?)?'}}
|
||||
// expected-error@-1{{cannot convert value of type '@convention(c) ((@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?' to specified type '@convention(c) ((@convention(c) (Int) -> Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?'}}
|
||||
|
||||
let _ : (@convention(c) ((@convention(c) (Swift.Int) -> Swift.Int)?) -> (@convention(c) (Swift.Int) -> Swift.Int)?)? = f2!
|
||||
// expected-error@-1{{cannot convert value of type '@convention(c) ((@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?' to specified type '(@convention(c) ((@convention(c) (Int) -> Int)?) -> (@convention(c) (Int) -> Int)?)?'}}
|
||||
// expected-error@-1{{cannot convert value of type '@convention(c) ((@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?) -> (@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?' to specified type '@convention(c) ((@convention(c) (Int) -> Int)?) -> (@convention(c) (Int) -> Int)?'}}
|
||||
|
||||
let f3 = getFunctionPointer3
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class IBOutletWrapperTy {
|
||||
var value : IBOutletWrapperTy! = IBOutletWrapperTy() // no-warning
|
||||
|
||||
@IBOutlet
|
||||
class var staticValue: IBOutletWrapperTy? = 52 // expected-error {{cannot convert value of type 'Int' to specified type 'IBOutletWrapperTy?'}}
|
||||
class var staticValue: IBOutletWrapperTy? = 52 // expected-error {{cannot convert value of type 'Int' to specified type 'IBOutletWrapperTy'}}
|
||||
// expected-error@-2 {{only class instance properties can be declared @IBOutlet}} {{3-12=}}
|
||||
// expected-error@-2 {{class stored properties not supported}}
|
||||
|
||||
|
||||
@@ -1140,12 +1140,12 @@ struct TestComposition {
|
||||
@Wrapper<String> @Wrapper var value: Int // expected-error{{composed wrapper type 'Wrapper<Int>' does not match type of 'Wrapper<String>.wrappedValue', which is 'String'}}
|
||||
|
||||
func triggerErrors(d: Double) { // expected-note 6 {{mark method 'mutating' to make 'self' mutable}} {{2-2=mutating }}
|
||||
p1 = d // expected-error{{cannot assign value of type 'Double' to type 'Int?'}} {{8-8=Int(}} {{9-9=)}}
|
||||
p1 = d // expected-error{{cannot assign value of type 'Double' to type 'Int'}} {{8-8=Int(}} {{9-9=)}}
|
||||
// expected-error@-1 {{cannot assign to property: 'self' is immutable}}
|
||||
p2 = d // expected-error{{cannot assign value of type 'Double' to type 'String?'}}
|
||||
p2 = d // expected-error{{cannot assign value of type 'Double' to type 'String'}}
|
||||
// expected-error@-1 {{cannot assign to property: 'self' is immutable}}
|
||||
// TODO(diagnostics): Looks like source range for 'd' here is reported as starting at 10, but it should be 8
|
||||
p3 = d // expected-error{{cannot assign value of type 'Double' to type 'Int?'}} {{10-10=Int(}} {{11-11=)}}
|
||||
p3 = d // expected-error{{cannot assign value of type 'Double' to type 'Int'}} {{10-10=Int(}} {{11-11=)}}
|
||||
// expected-error@-1 {{cannot assign to property: 'self' is immutable}}
|
||||
|
||||
_p1 = d // expected-error{{cannot assign value of type 'Double' to type 'WrapperA<WrapperB<WrapperC<Int>>>'}}
|
||||
|
||||
@@ -619,8 +619,8 @@ class C {
|
||||
}
|
||||
|
||||
_ = C(3) // expected-error {{missing argument label 'other:' in call}}
|
||||
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'C?'}}
|
||||
_ = C(other: 3) // expected-error {{cannot convert value of type 'Int' to expected argument type 'C?'}}
|
||||
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'C'}}
|
||||
_ = C(other: 3) // expected-error {{cannot convert value of type 'Int' to expected argument type 'C'}}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Unary Operators
|
||||
|
||||
@@ -78,13 +78,17 @@ func unsafePointerConversionAvailability(
|
||||
|
||||
_ = UnsafeMutablePointer<Int>(rp) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
_ = UnsafeMutablePointer<Int>(mrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
_ = UnsafeMutablePointer<Int>(orp) // expected-error {{cannot convert value of type 'UnsafeRawPointer?' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
_ = UnsafeMutablePointer<Int>(omrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafeMutablePointer<Int>'}}
|
||||
// Two candidates here: OpaquePointer? and UnsafeMutablePointer<Int>?
|
||||
_ = UnsafeMutablePointer<Int>(orp) // expected-error {{no exact matches in call to initializer}}
|
||||
// Two candidates here: OpaquePointer? and UnsafeMutablePointer<Int>?
|
||||
_ = UnsafeMutablePointer<Int>(omrp) // expected-error {{no exact matches in call to initializer}}
|
||||
|
||||
_ = UnsafePointer<Int>(rp) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafePointer<Int>'}}
|
||||
_ = UnsafePointer<Int>(mrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafePointer<Int>'}}
|
||||
_ = UnsafePointer<Int>(orp) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafePointer<Int>'}}
|
||||
_ = UnsafePointer<Int>(omrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafePointer<Int>'}}
|
||||
// Two candidates here: OpaquePointer? and UnsafeMutablePointer<Int>?
|
||||
_ = UnsafePointer<Int>(orp) // expected-error {{no exact matches in call to initializer}}
|
||||
// Two candidates here: OpaquePointer? and UnsafeMutablePointer<Int>?
|
||||
_ = UnsafePointer<Int>(omrp) // expected-error {{no exact matches in call to initializer}}
|
||||
|
||||
_ = UnsafePointer<Int>(ups) // expected-error {{cannot convert value of type 'UnsafePointer<String>' to expected argument type 'UnsafePointer<Int>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('String' and 'Int') are expected to be equal}}
|
||||
@@ -109,7 +113,7 @@ func unsafeRawBufferPointerConversions(
|
||||
|
||||
_ = UnsafeMutableRawBufferPointer(start: mrp, count: 1)
|
||||
_ = UnsafeRawBufferPointer(start: mrp, count: 1)
|
||||
_ = UnsafeMutableRawBufferPointer(start: rp, count: 1) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafeMutableRawPointer?'}}
|
||||
_ = UnsafeMutableRawBufferPointer(start: rp, count: 1) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafeMutableRawPointer'}}
|
||||
_ = UnsafeRawBufferPointer(start: rp, count: 1)
|
||||
_ = UnsafeMutableRawBufferPointer(mrbp)
|
||||
_ = UnsafeRawBufferPointer(mrbp)
|
||||
|
||||
@@ -36,7 +36,7 @@ struct CountdownEditor : View {
|
||||
Spacer()
|
||||
Image(systemName: symbol)
|
||||
.foregroundColor(selectedColor.color)
|
||||
// expected-error@-1 {{cannot convert value of type 'Binding<Subject>' to expected argument type 'Color?'}}
|
||||
// expected-error@-1 {{cannot convert value of type 'Binding<Subject>' to expected argument type 'Color'}}
|
||||
// expected-error@-2 {{referencing subscript 'subscript(dynamicMember:)' requires wrapper 'Binding<ColorScheme>'}}
|
||||
// expected-error@-3 {{value of type 'ColorScheme' has no dynamic member 'color' using key path from root type 'ColorScheme'}}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class Test {
|
||||
static func invalidVar() {
|
||||
_ = [0, 1, 2].compactMap {
|
||||
@WrapperValue var value: Bool? = $0
|
||||
// expected-error@-1 {{cannot convert value of type 'Int' to specified type 'Bool?'}}
|
||||
// expected-error@-1 {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}}
|
||||
if true {
|
||||
$value.printValue()
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ struct Test {
|
||||
_ = {
|
||||
// FIXME(diagnostics): We need to figure out how to avoid mentioning <<error type>> in the second diagnostic
|
||||
self.tuple = (v, 42)
|
||||
// expected-error@-1 {{cannot assign value of type '(Value<T>, Int)' to type '(value: any AnyValue, id: Int)'}}
|
||||
// expected-error@-2 {{generic struct 'Value' requires the types 'T' and '<<error type>>' be equivalent}}
|
||||
// expected-error@-1 {{generic struct 'Value' requires the types 'T' and '<<error type>>' be equivalent}}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public protocol rdar28048391 {
|
||||
extension rdar28048391 {
|
||||
public static func oops() -> Self? {
|
||||
return self
|
||||
// expected-error@-1 {{cannot convert return expression of type 'Self.Type' to return type 'Self?'}}
|
||||
// expected-error@-1 {{cannot convert return expression of type 'Self.Type' to return type 'Self'}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user