Skip to content

Commit e3d1871

Browse files
committed
add test
1 parent 9670f60 commit e3d1871

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
<Compile Include="Interop\Literals.fs" />
278278
<Compile Include="Scripting\Interactive.fs" />
279279
<Compile Include="Scripting\TypeCheckOnlyTests.fs" />
280+
<Compile Include="TypeChecks\TypeRelations.fs" />
280281
<Compile Include="TypeChecks\SeqTypeCheckTests.fs" />
281282
<Compile Include="TypeChecks\CheckDeclarationsTests.fs" />
282283
<Compile Include="TypeChecks\Graph\Utils.fs" />
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module MyModule
2+
3+
type IFoo<'T when 'T :> IFoo<'T>> =
4+
abstract member Bar: other:'T -> unit
5+
6+
[<AbstractClass>]
7+
type FooBase() =
8+
9+
interface IFoo<FooBase> with
10+
member this.Bar (other: FooBase) = ()
11+
12+
[<Sealed>]
13+
type FooDerived<'T>() =
14+
inherit FooBase()
15+
16+
interface IFoo<FooDerived<'T>> with
17+
member this.Bar other = ()
18+
19+
type IFooContainer<'T> =
20+
abstract member Foo: FooDerived<'T>
21+
22+
let inline bar<'a when 'a :> IFoo<'a>> (x: 'a) (y: 'a) = x.Bar y
23+
let inline takeSame<'a> (x: 'a) (y: 'a) = ()
24+
25+
// Successfully compiles under .NET 9 + F# 9
26+
// Error under .NET 10 + F# 10: Program.fs(26,13): Error FS0193 : The type 'FooDerived<'TId>' does not match the type 'FooBase'
27+
let callBar_NewlyBroken (foo1: IFooContainer<'TId>) (foo2: IFooContainer<'TId>) =
28+
bar foo1.Foo foo2.Foo
29+
30+
// Successfully compiles under both versions
31+
let callBar (foo1: IFooContainer<'TId>) (foo2: IFooContainer<'TId>) =
32+
let id1 = foo1.Foo
33+
let id2 = foo2.Foo
34+
bar id1 id2
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module TypeChecks.TypeRelations
2+
3+
open Xunit
4+
open FSharp.Test.Compiler
5+
open FSharp.Test
6+
7+
[<Theory; FileInlineData("CrgpLibrary.fs")>]
8+
let ``Unsolved type variables are not cached`` compilation =
9+
compilation
10+
|> getCompilation
11+
|> typecheck
12+
|> shouldSucceed

0 commit comments

Comments
 (0)