-
-
Save kntkymt/b0e28932d5a2dad6c1502c3ada7120c5 to your computer and use it in GitHub Desktop.
sample of debug constraints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// swiftc -Xfrontend -debug-constraints Source.swift | |
// swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2) | |
// Target: arm64-apple-macosx14.0 | |
---Constraint solving at [Source.swift:7:5 - line:7:22]--- | |
(overload set choice binding $T1 := () -> Cat) | |
---Initial constraints for the given expression--- | |
(array_expr type="[Cat]" location=Source.swift:7:16 range=[Source.swift:7:16 - line:7:22] initializer="**NULL**" | |
(call_expr type="Cat" location=Source.swift:7:17 range=[Source.swift:7:17 - line:7:21] isolation_crossing="none" | |
(type_expr type="Cat.Type" location=Source.swift:7:17 range=[Source.swift:7:17 - line:7:17] typerepr="Cat") | |
(argument_list))) | |
Score: <default 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0> | |
Contextual Type: [Cat] at [Source.swift:7:8 - line:7:12] | |
Type Variables: | |
$T0 as Cat @ locator@0x122131630 [[email protected]:7:17 → function result] | |
$T1 as () -> Cat @ locator@0x122131700 [[email protected]:7:17 → apply function → constructor member type (for short-form or self.init call)] | |
$T2 as () @ locator@0x1221316d8 [[email protected]:7:17 → apply argument] | |
$T3 as [Cat] @ locator@0x122131950 [[email protected]:7:16 → contextual type → pattern match → pattern match → named pattern decl] | |
Resolved overloads: | |
selected overload set choice Cat.Type.init: $T1 == () -> Cat for locator@0x122131770 [[email protected]:7:17 → apply function → constructor member] | |
(found solution: <default 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0>) | |
---Solver statistics--- | |
Total number of scopes explored: 1 | |
Maximum depth reached while exploring solutions: 1 | |
Time: 1.383000e+00ms | |
---Solution--- | |
Fixed score: <default 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0> | |
Type variables: | |
$T0 as Cat @ locator@0x122131630 [[email protected]:7:17 → function result] | |
$T1 as () -> Cat @ locator@0x122131700 [[email protected]:7:17 → apply function → constructor member type (for short-form or self.init call)] | |
$T2 as () @ locator@0x1221316d8 [[email protected]:7:17 → apply argument] | |
$T3 as [Cat] @ locator@0x122131950 [[email protected]:7:16 → contextual type → pattern match → pattern match → named pattern decl] | |
Overload choices: | |
locator@0x122131770 [[email protected]:7:17 → apply function → constructor member] with Source.(file).Cat.init()@Source.swift:2:19 as Cat.Type.init: () -> Cat | |
Trailing closure matching: | |
locator@0x1221316d8 [[email protected]:7:17 → apply argument]: forward | |
---Type-checked expression--- | |
(array_expr type="[Cat]" location=Source.swift:7:16 range=[Source.swift:7:16 - line:7:22] initializer="Swift.(file).Array extension.init(arrayLiteral:) [with (substitution_map generic_signature=<Element where Element : Copyable, Element : Escapable> Element -> Cat)]" | |
(call_expr type="Cat" location=Source.swift:7:17 range=[Source.swift:7:17 - line:7:21] isolation_crossing="none" | |
(constructor_ref_call_expr type="() -> Cat" location=Source.swift:7:17 range=[Source.swift:7:17 - line:7:17] isolation_crossing="none" | |
(declref_expr implicit type="(Cat.Type) -> () -> Cat" location=Source.swift:7:17 range=[Source.swift:7:17 - line:7:17] decl="Source.(file).Cat.init()@Source.swift:2:19" function_ref=single) | |
(argument_list implicit | |
(argument | |
(type_expr type="Cat.Type" location=Source.swift:7:17 range=[Source.swift:7:17 - line:7:17] typerepr="Cat")))) | |
(argument_list))) | |
---Constraint solving at [Source.swift:8:1 - line:8:4]--- | |
(overload set choice binding $T1 := [Cat]) | |
(common result type for $T0 is ()) | |
---Initial constraints for the given expression--- | |
(call_expr type="()" location=Source.swift:8:1 range=[Source.swift:8:1 - line:8:4] isolation_crossing="none" | |
(overloaded_decl_ref_expr type="$T0" location=Source.swift:8:1 range=[Source.swift:8:1 - line:8:1] name="f" number_of_decls=2 function_ref=single | |
(candidate_decl "Source.(file)[email protected]:4:6") | |
(candidate_decl "Source.(file)[email protected]:5:6")) | |
(argument_list | |
(argument | |
(declref_expr type="[Cat]" location=Source.swift:8:3 range=[Source.swift:8:3 - line:8:3] decl="Source.(file)[email protected]:7:5" function_ref=unapplied)))) | |
Score: <default 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0> | |
Type Variables: | |
$T0 [allows bindings to: lvalue, noescape] [attributes: delayed] [with possible bindings: <empty>] @ locator@0x121019a00 [[email protected]:8:1] | |
$T1 as [Cat] @ locator@0x121019b98 [[email protected]:8:3] | |
$T2 as () @ locator@0x121019bf8 [[email protected]:8:1 → function result] | |
Inactive Constraints: | |
disjunction @ locator@0x121019a00 [[email protected]:8:1]: | |
> $T0 bound to decl Source.(file)[email protected]:4:6 : ([Cat?]) -> () | |
> $T0 bound to decl Source.(file)[email protected]:5:6 : ([Any]) -> () | |
([Cat]) -> $T2 applicable fn $T0 @ locator@0x121019c90 [[email protected]:8:1 → apply function] | |
Resolved overloads: | |
selected overload set choice a: $T1 == [Cat] for locator@0x121019b98 [[email protected]:8:3] | |
(Potential Binding(s): | |
Disjunction(s) = [$T0] | |
) | |
(attempting disjunction choice $T0 bound to decl Source.(file)[email protected]:4:6 : ([Cat?]) -> () @ locator@0x121019a00 [[email protected]:8:1] | |
(overload set choice binding $T0 := ([Cat?]) -> ()) | |
(considering: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x121019c90 [[email protected]:8:1 → apply function] | |
(simplification result: | |
(added constraint: disjunction @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]: | |
> [favored] [Cat] bind [Cat?] [deep equality] | |
> [Cat] arg conv [Cat?] [array-upcast]) | |
(removed constraint: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x121019c90 [[email protected]:8:1 → apply function]) | |
) | |
(outcome: simplified) | |
) | |
(Changes: | |
(Newly Bound: | |
> $T0 := ([Cat?]) -> () | |
) | |
(Added Constraint: | |
> disjunction @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]: | |
> [favored] [Cat] bind [Cat?] [deep equality] | |
> [Cat] arg conv [Cat?] [array-upcast] | |
) | |
(Removed Constraint: | |
> ([Cat]) -> $T2 applicable fn $T0 @ locator@0x121019c90 [[email protected]:8:1 → apply function] | |
) | |
) | |
(attempting disjunction choice [Cat] bind [Cat?] [deep equality] @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0] | |
(failed constraint [Cat] bind [Cat?] [deep equality] @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]) | |
) | |
(attempting disjunction choice [Cat] arg conv [Cat?] [array-upcast] @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0] | |
(increasing 'collection upcast conversion' score by 1 @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]) | |
(increasing 'value to optional promotion' score by 1 @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0] -> generic argument #0) | |
(Changes: | |
) | |
(found solution: [component: collection upcast conversion(s), value: 1] [component: value to optional promotion(s), value: 1]) | |
) | |
) | |
(attempting disjunction choice $T0 bound to decl Source.(file)[email protected]:5:6 : ([Any]) -> () @ locator@0x121019a00 [[email protected]:8:1] | |
(overload set choice binding $T0 := ([Any]) -> ()) | |
(considering: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x121019c90 [[email protected]:8:1 → apply function] | |
(simplification result: | |
(added constraint: disjunction @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]: | |
> [favored] [Cat] bind [Any] [deep equality] | |
> [Cat] arg conv [Any] [array-upcast]) | |
(removed constraint: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x121019c90 [[email protected]:8:1 → apply function]) | |
) | |
(outcome: simplified) | |
) | |
(Changes: | |
(Newly Bound: | |
> $T0 := ([Any]) -> () | |
) | |
(Added Constraint: | |
> disjunction @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]: | |
> [favored] [Cat] bind [Any] [deep equality] | |
> [Cat] arg conv [Any] [array-upcast] | |
) | |
(Removed Constraint: | |
> ([Cat]) -> $T2 applicable fn $T0 @ locator@0x121019c90 [[email protected]:8:1 → apply function] | |
) | |
) | |
(attempting disjunction choice [Cat] bind [Any] [deep equality] @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0] | |
(failed constraint [Cat] bind [Any] [deep equality] @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]) | |
) | |
(attempting disjunction choice [Cat] arg conv [Any] [array-upcast] @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0] | |
(increasing 'collection upcast conversion' score by 1 @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0]) | |
(increasing 'empty-existential conversion' score by 1 @ locator@0x121019d90 [[email protected]:8:1 → apply argument → comparing call argument #0 to parameter #0] -> generic argument #0) | |
(Changes: | |
) | |
(found solution: [component: collection upcast conversion(s), value: 1] [component: empty-existential conversion(s), value: 1]) | |
) | |
) | |
---Solver statistics--- | |
Total number of scopes explored: 7 | |
Maximum depth reached while exploring solutions: 3 | |
Time: 1.053000e+00ms | |
Comparing 2 viable solutions | |
--- Solution #0 --- | |
Fixed score: [component: collection upcast conversion(s), value: 1] [component: value to optional promotion(s), value: 1] | |
Type variables: | |
$T0 as ([Cat?]) -> () @ locator@0x121019a00 [[email protected]:8:1] | |
$T1 as [Cat] @ locator@0x121019b98 [[email protected]:8:3] | |
$T2 as () @ locator@0x121019bf8 [[email protected]:8:1 → function result] | |
Overload choices: | |
locator@0x121019a00 [[email protected]:8:1] with Source.(file)[email protected]:4:6 as f: ([Cat?]) -> () | |
locator@0x121019b98 [[email protected]:8:3] with Source.(file)[email protected]:7:5 as a: [Cat] | |
Constraint restrictions: | |
Array<Cat> to Array<Optional<Cat>> is [array-upcast] | |
Cat to Optional<Cat> is [value-to-optional] | |
Trailing closure matching: | |
locator@0x121019d68 [[email protected]:8:1 → apply argument]: forward | |
--- Solution #1 --- | |
Fixed score: [component: collection upcast conversion(s), value: 1] [component: empty-existential conversion(s), value: 1] | |
Type variables: | |
$T0 as ([Any]) -> () @ locator@0x121019a00 [[email protected]:8:1] | |
$T1 as [Cat] @ locator@0x121019b98 [[email protected]:8:3] | |
$T2 as () @ locator@0x121019bf8 [[email protected]:8:1 → function result] | |
Overload choices: | |
locator@0x121019a00 [[email protected]:8:1] with Source.(file)[email protected]:5:6 as f: ([Any]) -> () | |
locator@0x121019b98 [[email protected]:8:3] with Source.(file)[email protected]:7:5 as a: [Cat] | |
Constraint restrictions: | |
Cat to Any is [existential] | |
Array<Cat> to Array<Any> is [array-upcast] | |
Trailing closure matching: | |
locator@0x121019d68 [[email protected]:8:1 → apply argument]: forward | |
comparing solutions 1 and 0 | |
comparing solutions 1 and 0 | |
---Solution--- | |
Fixed score: [component: collection upcast conversion(s), value: 1] [component: empty-existential conversion(s), value: 1] | |
Type variables: | |
$T0 as ([Any]) -> () @ locator@0x121019a00 [[email protected]:8:1] | |
$T1 as [Cat] @ locator@0x121019b98 [[email protected]:8:3] | |
$T2 as () @ locator@0x121019bf8 [[email protected]:8:1 → function result] | |
Overload choices: | |
locator@0x121019a00 [[email protected]:8:1] with Source.(file)[email protected]:5:6 as f: ([Any]) -> () | |
locator@0x121019b98 [[email protected]:8:3] with Source.(file)[email protected]:7:5 as a: [Cat] | |
Constraint restrictions: | |
Cat to Any is [existential] | |
Array<Cat> to Array<Any> is [array-upcast] | |
Trailing closure matching: | |
locator@0x121019d68 [[email protected]:8:1 → apply argument]: forward | |
---Type-checked expression--- | |
(call_expr type="()" location=Source.swift:8:1 range=[Source.swift:8:1 - line:8:4] isolation_crossing="none" | |
(declref_expr type="([Any]) -> ()" location=Source.swift:8:1 range=[Source.swift:8:1 - line:8:1] decl="Source.(file)[email protected]:5:6" function_ref=single) | |
(argument_list | |
(argument | |
(collection_upcast_expr implicit type="[Any]" location=Source.swift:8:3 range=[Source.swift:8:3 - line:8:3] | |
(declref_expr type="[Cat]" location=Source.swift:8:3 range=[Source.swift:8:3 - line:8:3] decl="Source.(file)[email protected]:7:5" function_ref=unapplied) | |
(value_conversion=erasure_expr implicit type="Any" location=Source.swift:8:3 range=[Source.swift:8:3 - line:8:3] | |
(builtin_conformance type="Cat" protocol="Copyable") | |
(builtin_conformance type="Cat" protocol="Escapable") | |
(opaque_value_expr implicit type="Cat" location=Source.swift:8:3 range=[Source.swift:8:3 - line:8:3] "0x12101c050")))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Animal {} | |
class Cat: Animal {} | |
func f(_ a: [Cat?]) { } | |
func f(_ a: [Any]) { } | |
let a: [Cat] = [Cat()] | |
f(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment