summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-gadts/pr7391.ml
blob: f16654c5a030a20f8473e0d40d52e7f47e785523 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
(* TEST
   * expect
*)

class virtual child1 parent =
  object
    method private parent = parent
  end

class virtual child2 =
  object(_ : 'self)
    constraint 'parent = < previous: 'self option; .. >
    method private virtual parent: 'parent
  end

(* Worked in 4.03 *)
let _ =
  object(self)
    method previous = None
    method child =
      object
        inherit child1 self
        inherit child2
      end
  end;;
[%%expect{|
class virtual child1 : 'a -> object method private parent : 'a end
class virtual child2 :
  object ('a)
    method private virtual parent : < previous : 'a option; .. >
  end
- : < child : child1; previous : child1 option > = <obj>
|}]

(* Worked in 4.03 *)
let _ =
  object(self)
    method previous = None
    method child (_ : unit) =
      object
        inherit child1 self
        inherit child2
      end
  end;;
[%%expect{|
- : < child : unit -> child1; previous : child1 option > = <obj>
|}]

(* Worked in 4.03 *)
let _ =
  object(self)
    method previous = None
    method child () =
      object
        inherit child1 self
        inherit child2
      end
  end;;
[%%expect{|
- : < child : unit -> child1; previous : child1 option > = <obj>
|}]

(* Didn't work in 4.03, but works in 4.07 *)
let _ =
  object(self)
    method previous = None
    method child =
      let o =
      object
        inherit child1 self
        inherit child2
      end
      in o
  end;;
[%%expect{|
- : < child : child1; previous : child1 option > = <obj>
|}]

(* Also didn't work in 4.03 *)

type gadt = Not_really_though : gadt

let _ =
  object(self)
    method previous = None
    method child Not_really_though =
      object
        inherit child1 self
        inherit child2
      end
  end;;
[%%expect{|
type gadt = Not_really_though : gadt
- : < child : gadt -> child1; previous : child1 option > = <obj>
|}]