You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix object-expr untested case
* Update condition to cover new found cases
* Better test names
* one more test
---------
Co-authored-by: Kevin Ransom (msft) <[email protected]>
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/ObjectExpressions/ObjectExpressions.fs
+87Lines changed: 87 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,93 @@ let implementer() ={ new IFirst }
33
33
|> withLangVersion80
34
34
|> typecheck
35
35
|> shouldSucceed
36
+
37
+
[<Fact>]
38
+
let``Object expression can construct an abstract class and also implement interfaces with and without abstract members.`` ()=
39
+
Fsx """
40
+
type IFirst = interface end
41
+
42
+
type ISecond =
43
+
abstract member M : unit -> unit
44
+
45
+
[<AbstractClass>]
46
+
type MyClass() = class end
47
+
48
+
{ new MyClass() with
49
+
member x.ToString() = "OK"
50
+
51
+
interface IFirst
52
+
53
+
interface ISecond with
54
+
member this.M() = () } |> ignore
55
+
"""
56
+
|> withLangVersion80
57
+
|> typecheck
58
+
|> shouldSucceed
59
+
60
+
[<Fact>]
61
+
let``Object expression can construct an abstract class(missing with...)andalso implement interfaces with and without abstract members.`` ()=
62
+
Fsx """
63
+
type IFirst = interface end
64
+
65
+
type ISecond =
66
+
abstract member M : unit -> unit
67
+
68
+
[<AbstractClass>]
69
+
type MyClass() = class end
70
+
71
+
{ new MyClass() interface IFirst
72
+
73
+
interface ISecond with
74
+
member this.M() = () } |> ignore
75
+
"""
76
+
|> withLangVersion80
77
+
|> typecheck
78
+
|> shouldSucceed
79
+
80
+
[<Fact>]
81
+
let``Object expression can construct an abstract class(missing with... and interface in the next line)andalso implement interfaces with and without abstract members.`` ()=
82
+
Fsx """
83
+
type IFirst = interface end
84
+
85
+
type ISecond =
86
+
abstract member M : unit -> unit
87
+
88
+
[<AbstractClass>]
89
+
type MyClass() = class end
90
+
91
+
{ new MyClass()
92
+
interface IFirst
93
+
94
+
interface ISecond with
95
+
member this.M() = () } |> ignore
96
+
"""
97
+
|> withLangVersion80
98
+
|> typecheck
99
+
|> shouldSucceed
100
+
101
+
[<Fact>]
102
+
let``Verifies that the object expression built type has the interface.`` ()=
103
+
Fsx """
104
+
type IFirst = interface end
105
+
106
+
type ISecond =
107
+
abstract member M : unit -> unit
108
+
109
+
[<AbstractClass>]
110
+
type MyClass() =
111
+
interface ISecond with
112
+
member this.M() = printfn "It works"
113
+
114
+
let expr = { new MyClass() interface IFirst }
115
+
(expr:> ISecond).M()
116
+
"""
117
+
|> withLangVersion80
118
+
|> compileExeAndRun
119
+
|> shouldSucceed
120
+
|> withStdOutContainsAllInOrder [
121
+
"It works"
122
+
]
36
123
37
124
[<Fact>]
38
125
let``Parameterized object expression implementing an interface with members`` ()=
0 commit comments