@@ -38,7 +38,8 @@ class Derived(y: Int) extends Base(y + 1)
38
38
//│ class Base(x: Int)
39
39
//│ class Derived(y: Int) extends Base
40
40
41
- :ducs:postprocess.result,coverage
41
+ // Notice that Derived is not in the inferred type.
42
+ :ducs:postprocess.result
42
43
fun example3(t) =
43
44
if t is
44
45
Base(x) and p1(x) then x
@@ -60,42 +61,13 @@ fun example3(t) =
60
61
//│ y
61
62
//│ _ -> 42
62
63
//│ _ -> 42
63
- //│ | | | | | | | STEP 4
64
- //│ | | | | | | | collected match registry:
65
- //│ | | | | | | | >>> t => [class `Base`, class `Derived`]
66
- //│ | | | | | | | >>> x => []
67
- //│ | | | | | | | >>> y => []
68
- //│ | | | | | | | checkCoverage <== 0 pending, 3 working, 0 seen
69
- //│ | | | | | | | | CASE t
70
- //│ | | | | | | | | SEEN: empty
71
- //│ | | | | | | | | class symbol: `Base`
72
- //│ | | | | | | | | REMOVE `Base` from working
73
- //│ | | | | | | | | unseen: [class `Base`, class `Derived`]
74
- //│ | | | | | | | | remaining: []
75
- //│ | | | | | | | | checkCoverage <== LET `ucs$args_t$Base`
76
- //│ | | | | | | | | checkCoverage <== LET `x`
77
- //│ | | | | | | | | checkCoverage <== LET `ucs$test$0`
78
- //│ | | | | | | | | checkCoverage <== TEST `ucs$test$0`
79
- //│ | | | | | | | | checkCoverage <== TERM x
80
- //│ | | | | | | | | checkCoverage <== 0 pending, 2 working, 1 seen
81
- //│ | | | | | | | | | CASE t
82
- //│ | | | | | | | | | SEEN: t is Base
83
- //│ | | | | | | | | | class symbol: `Derived`
84
- //│ | | | | | | | | | REMOVE `Derived` from working
85
- //│ | | | | | | | | | unseen: [class `Derived`]
86
- //│ | | | | | | | | | remaining: []
87
- //│ | | | | | | | | | checkCoverage <== LET `ucs$args_t$Derived`
88
- //│ | | | | | | | | | checkCoverage <== LET `y`
89
- //│ | | | | | | | | | checkCoverage <== TERM y
90
- //│ | | | | | | | | | remaining cases should be covered by the wildcard
91
- //│ | | | | | | | | | checkCoverage <== TERM 42
92
- //│ | | | | | | | | checkCoverage ==> 0 diagnostics
93
- //│ | | | | | | | | remaining cases should be covered by the wildcard
94
- //│ | | | | | | | | checkCoverage <== TERM 42
95
- //│ | | | | | | | checkCoverage ==> 0 diagnostics
96
- //│ | | | | | | | Coverage checking result: 0 errors
97
64
//│ fun example3: forall 'a. (Base & {#x: Num & 'a} | Object & ~#Base) -> (Int | 'a)
98
65
66
+ example3(Derived(1))
67
+ //│ Int
68
+ //│ res
69
+ //│ = 1
70
+
99
71
fun example4(t, x) =
100
72
if t is
101
73
Base(x) and p1(x) then x
@@ -119,3 +91,16 @@ example4(Derived(1), 4) ~~> 5
119
91
//│ "passed"
120
92
//│ res
121
93
//│ = 'passed'
94
+
95
+ class Base(x: Int)
96
+ class Derived[A](y: A) extends Base(1)
97
+ //│ class Base(x: Int)
98
+ //│ class Derived[A](y: A) extends Base
99
+
100
+ // Notice that now Derived is generic, so it's appear in the inferred type.
101
+ fun example5(t) =
102
+ if t is
103
+ Base(x) and p1(x) then x
104
+ Derived(y) then y
105
+ else 42
106
+ //│ fun example5: forall 'a 'b. (Base & {#x: Num & 'a} & ~#Derived | Derived['b] & {#x: Num & 'a} | Object & ~#Base) -> (42 | 'a | 'b)
0 commit comments