blob: 287e3c6770c3929e78a42b7f7af3ce763ea51e4c (
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
|
(* TEST
* expect
*)
type _ t = Int : int t;;
[%%expect{|
type _ t = Int : int t
|}]
let o =
object (self)
method private x = 3
method m : type a. a t -> a = fun Int -> (self#x : int)
end;;
[%%expect{|
val o : < m : 'a. 'a t -> 'a > = <obj>
|}]
let o' =
object (self : 's)
method private x = 3
method m : type a. a t -> 's -> a = fun Int other -> (other#x : int)
end;;
let aargh = assert (o'#m Int o' = 3);;
[%%expect{|
Lines 2-5, characters 2-5:
2 | ..object (self : 's)
3 | method private x = 3
4 | method m : type a. a t -> 's -> a = fun Int other -> (other#x : int)
5 | end..
Warning 15 [implicit-public-methods]: the following private methods were made public implicitly:
x.
val o' : < m : 'a. 'a t -> 'b -> 'a; x : int > as 'b = <obj>
val aargh : unit = ()
|}]
let o2 =
object (self : 's)
method private x = 3
method m : 's -> int = fun other -> (other#x : int)
end;;
[%%expect{|
Lines 2-5, characters 2-5:
2 | ..object (self : 's)
3 | method private x = 3
4 | method m : 's -> int = fun other -> (other#x : int)
5 | end..
Warning 15 [implicit-public-methods]: the following private methods were made public implicitly:
x.
val o2 : < m : 'a -> int; x : int > as 'a = <obj>
|}]
let o3 =
object (self : 's)
method private x = 3
method m : 's -> int = fun other ->
let module M = struct let other = other end in (M.other#x : int)
end;;
let aargh = assert (o3#m o3 = 3);;
[%%expect{|
Lines 2-6, characters 2-5:
2 | ..object (self : 's)
3 | method private x = 3
4 | method m : 's -> int = fun other ->
5 | let module M = struct let other = other end in (M.other#x : int)
6 | end..
Warning 15 [implicit-public-methods]: the following private methods were made public implicitly:
x.
val o3 : < m : 'a -> int; x : int > as 'a = <obj>
val aargh : unit = ()
|}]
|