mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Previously, type checking arguments worked fine if the entire arg was UnresolvedType, but if the type just contained UnresolvedType, the constraint system always failed via explicitly constraining to unresolved. Now in TypeCheckConstraints, if the solution allows for free variables that are UnresolvedType, then also convert any incoming UnresolvedTypes into variables. At worst, in the solution these just get converted back into the same Unresolved that they started with. This change allows for incorrect tuple/function type possibilities to make it back out to CSDiag, where they can be more precisely diagnosed with callee info. The rest of the changes are to correctly figure out the failure info when evaluating more types of Types. New diagnosis for a partial part of an arg type not confroming. Tests added for that. Expected errors changed in several places where we now get real types in the diagnosis instead of '(_)' unresolved.
27 lines
729 B
Swift
27 lines
729 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
import StdlibUnittest
|
|
|
|
// Also import modules which are used by StdlibUnittest internally. This
|
|
// workaround is needed to link all required libraries in case we compile
|
|
// StdlibUnittest with -sil-serialize-all.
|
|
import SwiftPrivate
|
|
#if _runtime(_ObjC)
|
|
import ObjectiveC
|
|
#endif
|
|
|
|
struct S1 {}
|
|
struct S2 {}
|
|
|
|
func test_expectType() {
|
|
var s1 = S1()
|
|
expectType(S1.self, &s1)
|
|
expectType(S2.self, &s1) // expected-error {{cannot convert value of type 'S1' to expected argument type 'S2'}}
|
|
}
|
|
|
|
func test_expectEqualType() {
|
|
expectEqualType(S1.self, S1.self)
|
|
expectEqualType(S1.self, S2.self) // expected-error {{cannot convert value of type 'S2.Type' to expected argument type 'S1.Type'}}
|
|
}
|
|
|