-
-
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.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) | |
// Target: arm64-apple-macosx14.0 | |
---Constraint solving at [Source.swift:10:5 - line:10:22]--- | |
(overload set choice binding $T1 := () -> Cat) | |
---Initial constraints for the given expression--- | |
(array_expr type='[Cat]' location=Source.swift:10:16 range=[Source.swift:10:16 - line:10:22] initializer=**NULL** | |
(call_expr type='Cat' location=Source.swift:10:17 range=[Source.swift:10:17 - line:10:21] isolationCrossing=none | |
(type_expr type='Cat.Type' location=Source.swift:10:17 range=[Source.swift:10:17 - line:10: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:10:8 - line:10:12] | |
Type Variables: | |
$T0 as Cat @ locator@0x1601c3230 [Call@Source.swift:10:17 → function result] | |
$T1 as () -> Cat @ locator@0x1601c3300 [Call@Source.swift:10:17 → apply function → constructor member type (for short-form or self.init call)] | |
$T2 as () @ locator@0x1601c32d8 [Call@Source.swift:10:17 → apply argument] | |
$T3 as [Cat] @ locator@0x1601c3550 [Array@Source.swift:10:16 → contextual type → pattern match → pattern match → named pattern decl] | |
Resolved overloads: | |
selected overload set choice Cat.Type.init: $T1 == () -> Cat for locator@0x1601c3370 [Call@Source.swift:10: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: 4.030000e-01ms | |
---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@0x1601c3230 [Call@Source.swift:10:17 → function result] | |
$T1 as () -> Cat @ locator@0x1601c3300 [Call@Source.swift:10:17 → apply function → constructor member type (for short-form or self.init call)] | |
$T2 as () @ locator@0x1601c32d8 [Call@Source.swift:10:17 → apply argument] | |
$T3 as [Cat] @ locator@0x1601c3550 [Array@Source.swift:10:16 → contextual type → pattern match → pattern match → named pattern decl] | |
Overload choices: | |
locator@0x1601c3370 [Call@Source.swift:10:17 → apply function → constructor member] with Source.(file).Cat.init()@Source.swift:2:19 as Cat.Type.init: () -> Cat | |
Trailing closure matching: | |
locator@0x1601c32d8 [Call@Source.swift:10:17 → apply argument]: forward | |
---Type-checked expression--- | |
(array_expr type='[Cat]' location=Source.swift:10:16 range=[Source.swift:10:16 - line:10:22] initializer=Swift.(file).Array extension.init(arrayLiteral:) [with (substitution_map generic_signature=<Element> (substitution Element -> Cat))] | |
(call_expr type='Cat' location=Source.swift:10:17 range=[Source.swift:10:17 - line:10:21] isolationCrossing=none | |
(constructor_ref_call_expr type='() -> Cat' location=Source.swift:10:17 range=[Source.swift:10:17 - line:10:17] isolationCrossing=none | |
(declref_expr implicit type='(Cat.Type) -> () -> Cat' location=Source.swift:10:17 range=[Source.swift:10:17 - line:10: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:10:17 range=[Source.swift:10:17 - line:10:17] typerepr='Cat')))) | |
(argument_list))) | |
---Constraint solving at [Source.swift:12:1 - line:12: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:12:1 range=[Source.swift:12:1 - line:12:4] isolationCrossing=none | |
(overloaded_decl_ref_expr type='$T0' location=Source.swift:12:1 range=[Source.swift:12:1 - line:12:1] name=f number_of_decls=3 function_ref=single decls=[ | |
Source.(file).f@Source.swift:4:6, | |
Source.(file).f@Source.swift:6:6, | |
Source.(file).f@Source.swift:8:6]) | |
(argument_list | |
(argument | |
(declref_expr type='[Cat]' location=Source.swift:12:3 range=[Source.swift:12:3 - line:12:3] decl=Source.(file).a@Source.swift:10: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@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
$T1 as [Cat] @ locator@0x15781d408 [DeclRef@Source.swift:12:3] | |
$T2 as () @ locator@0x15781d468 [Call@Source.swift:12:1 → function result] | |
Inactive Constraints: | |
disjunction @ locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1]: | |
> $T0 bound to decl Source.(file).f@Source.swift:4:6 : ([Cat?]) -> () | |
> $T0 bound to decl Source.(file).f@Source.swift:6:6 : ([Any]) -> () | |
> $T0 bound to decl Source.(file).f@Source.swift:8:6 : (UnsafePointer<Cat>) -> () | |
([Cat]) -> $T2 applicable fn $T0 @ locator@0x15781d500 [Call@Source.swift:12:1 → apply function] | |
Resolved overloads: | |
selected overload set choice a: $T1 == [Cat] for locator@0x15781d408 [DeclRef@Source.swift:12:3] | |
(Potential Binding(s): | |
Disjunction(s) = [$T0] | |
) | |
(attempting disjunction choice $T0 bound to decl Source.(file).f@Source.swift:4:6 : ([Cat?]) -> () @ locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
(overload set choice binding $T0 := ([Cat?]) -> ()) | |
(considering: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x15781d500 [Call@Source.swift:12:1 → apply function] | |
(simplification result: | |
(added constraint: disjunction @ locator@0x15781d600 [Call@Source.swift:12: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@0x15781d500 [Call@Source.swift:12:1 → apply function]) | |
) | |
(outcome: simplified) | |
) | |
(Changes: | |
(Newly Bound: | |
> $T0 := ([Cat?]) -> () | |
) | |
(Added Constraint: | |
> disjunction @ locator@0x15781d600 [Call@Source.swift:12: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@0x15781d500 [Call@Source.swift:12:1 → apply function] | |
) | |
) | |
(attempting disjunction choice [Cat] bind [Cat?] [deep equality] @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0] | |
(failed constraint [Cat] bind [Cat?] [deep equality] @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0]) | |
) | |
(attempting disjunction choice [Cat] arg conv [Cat?] [array-upcast] @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0] | |
(increasing 'collection upcast conversion' score by 1 @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0]) | |
(increasing 'value to optional promotion' score by 1 @ locator@0x15781d600 [Call@Source.swift:12: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).f@Source.swift:6:6 : ([Any]) -> () @ locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
(overload set choice binding $T0 := ([Any]) -> ()) | |
(considering: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x15781d500 [Call@Source.swift:12:1 → apply function] | |
(simplification result: | |
(added constraint: disjunction @ locator@0x15781d600 [Call@Source.swift:12: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@0x15781d500 [Call@Source.swift:12:1 → apply function]) | |
) | |
(outcome: simplified) | |
) | |
(Changes: | |
(Newly Bound: | |
> $T0 := ([Any]) -> () | |
) | |
(Added Constraint: | |
> disjunction @ locator@0x15781d600 [Call@Source.swift:12: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@0x15781d500 [Call@Source.swift:12:1 → apply function] | |
) | |
) | |
(attempting disjunction choice [Cat] bind [Any] [deep equality] @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0] | |
(failed constraint [Cat] bind [Any] [deep equality] @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0]) | |
) | |
(attempting disjunction choice [Cat] arg conv [Any] [array-upcast] @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0] | |
(increasing 'collection upcast conversion' score by 1 @ locator@0x15781d600 [Call@Source.swift:12:1 → apply argument → comparing call argument #0 to parameter #0]) | |
(increasing 'empty-existential conversion' score by 1 @ locator@0x15781d600 [Call@Source.swift:12: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]) | |
) | |
) | |
(attempting disjunction choice $T0 bound to decl Source.(file).f@Source.swift:8:6 : (UnsafePointer<Cat>) -> () @ locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
(overload set choice binding $T0 := (UnsafePointer<Cat>) -> ()) | |
(considering: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x15781d500 [Call@Source.swift:12:1 → apply function] | |
(simplification result: | |
(increasing 'value-to-pointer conversion' score by 1 @ locator@0x15781d5d8 [Call@Source.swift:12:1 → apply argument] -> comparing call argument #0 to parameter #0) | |
(removed constraint: ([Cat]) -> $T2 applicable fn $T0 @ locator@0x15781d500 [Call@Source.swift:12:1 → apply function]) | |
) | |
(outcome: simplified) | |
) | |
(Changes: | |
(Newly Bound: | |
> $T0 := (UnsafePointer<Cat>) -> () | |
) | |
(Removed Constraint: | |
> ([Cat]) -> $T2 applicable fn $T0 @ locator@0x15781d500 [Call@Source.swift:12:1 → apply function] | |
) | |
) | |
(found solution: [component: value-to-pointer conversion(s), value: 1]) | |
) | |
---Solver statistics--- | |
Total number of scopes explored: 8 | |
Maximum depth reached while exploring solutions: 3 | |
Time: 9.840000e-01ms | |
Comparing 3 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@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
$T1 as [Cat] @ locator@0x15781d408 [DeclRef@Source.swift:12:3] | |
$T2 as () @ locator@0x15781d468 [Call@Source.swift:12:1 → function result] | |
Overload choices: | |
locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] with Source.(file).f@Source.swift:4:6 as f: ([Cat?]) -> () | |
locator@0x15781d408 [DeclRef@Source.swift:12:3] with Source.(file).a@Source.swift:10:5 as a: [Cat] | |
Constraint restrictions: | |
Cat to Optional<Cat> is [value-to-optional] | |
Array<Cat> to Array<Optional<Cat>> is [array-upcast] | |
Trailing closure matching: | |
locator@0x15781d5d8 [Call@Source.swift:12: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@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
$T1 as [Cat] @ locator@0x15781d408 [DeclRef@Source.swift:12:3] | |
$T2 as () @ locator@0x15781d468 [Call@Source.swift:12:1 → function result] | |
Overload choices: | |
locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] with Source.(file).f@Source.swift:6:6 as f: ([Any]) -> () | |
locator@0x15781d408 [DeclRef@Source.swift:12:3] with Source.(file).a@Source.swift:10:5 as a: [Cat] | |
Constraint restrictions: | |
Array<Cat> to Array<Any> is [array-upcast] | |
Cat to Any is [existential] | |
Trailing closure matching: | |
locator@0x15781d5d8 [Call@Source.swift:12:1 → apply argument]: forward | |
--- Solution #2 --- | |
Fixed score: [component: value-to-pointer conversion(s), value: 1] | |
Type variables: | |
$T0 as (UnsafePointer<Cat>) -> () @ locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
$T1 as [Cat] @ locator@0x15781d408 [DeclRef@Source.swift:12:3] | |
$T2 as () @ locator@0x15781d468 [Call@Source.swift:12:1 → function result] | |
Overload choices: | |
locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] with Source.(file).f@Source.swift:8:6 as f: (UnsafePointer<Cat>) -> () | |
locator@0x15781d408 [DeclRef@Source.swift:12:3] with Source.(file).a@Source.swift:10:5 as a: [Cat] | |
Constraint restrictions: | |
Array<Cat> to UnsafePointer<Cat> is [array-to-pointer] | |
Trailing closure matching: | |
locator@0x15781d5d8 [Call@Source.swift:12:1 → apply argument]: forward | |
comparing solutions 1 and 0 | |
comparing solutions 2 and 1 | |
comparing solutions 2 and 0 | |
comparing solutions 2 and 1 | |
---Solution--- | |
Fixed score: [component: value-to-pointer conversion(s), value: 1] | |
Type variables: | |
$T0 as (UnsafePointer<Cat>) -> () @ locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] | |
$T1 as [Cat] @ locator@0x15781d408 [DeclRef@Source.swift:12:3] | |
$T2 as () @ locator@0x15781d468 [Call@Source.swift:12:1 → function result] | |
Overload choices: | |
locator@0x15781d200 [OverloadedDeclRef@Source.swift:12:1] with Source.(file).f@Source.swift:8:6 as f: (UnsafePointer<Cat>) -> () | |
locator@0x15781d408 [DeclRef@Source.swift:12:3] with Source.(file).a@Source.swift:10:5 as a: [Cat] | |
Constraint restrictions: | |
Array<Cat> to UnsafePointer<Cat> is [array-to-pointer] | |
Trailing closure matching: | |
locator@0x15781d5d8 [Call@Source.swift:12:1 → apply argument]: forward | |
---Type-checked expression--- | |
(call_expr type='()' location=Source.swift:12:1 range=[Source.swift:12:1 - line:12:4] isolationCrossing=none | |
(declref_expr type='(UnsafePointer<Cat>) -> ()' location=Source.swift:12:1 range=[Source.swift:12:1 - line:12:1] decl=Source.(file).f@Source.swift:8:6 function_ref=single) | |
(argument_list | |
(argument | |
(array_to_pointer implicit type='UnsafePointer<Cat>' location=Source.swift:12:3 range=[Source.swift:12:3 - line:12:3] | |
(declref_expr type='[Cat]' location=Source.swift:12:3 range=[Source.swift:12:3 - line:12:3] decl=Source.(file).a@Source.swift:10:5 function_ref=unapplied))))) |
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]) { } | |
func f(_ a: UnsafePointer<Cat>) {} | |
let a: [Cat] = [Cat()] | |
f(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment