Skip to content

Commit 403f594

Browse files
authored
Merge pull request #9543 from dotnet/merges/master-to-release/dev16.7
Merge master to release/dev16.7
2 parents f578f4a + 3a067f4 commit 403f594

39 files changed

Lines changed: 413 additions & 404 deletions

src/fsharp/LanguageFeatures.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type LanguageVersion (specifiedVersionAsString) =
4646
static let latestMajorVersion = languageVersion47 // Language version when latestmajor specified
4747

4848
static let validOptions = [| "preview"; "default"; "latest"; "latestmajor" |]
49-
static let languageVersions = set [| languageVersion46; languageVersion47 (*; languageVersion50 *) |]
49+
static let languageVersions = set [| languageVersion46; languageVersion47 ; languageVersion50 |]
5050

5151
static let features =
5252
dict [
@@ -58,17 +58,17 @@ type LanguageVersion (specifiedVersionAsString) =
5858

5959
// F# 5.0
6060
LanguageFeature.FixedIndexSlice3d4d, languageVersion50
61-
LanguageFeature.FromEndSlicing, languageVersion50
6261
LanguageFeature.DotlessFloat32Literal, languageVersion50
62+
LanguageFeature.AndBang, languageVersion50
63+
LanguageFeature.NullableOptionalInterop, languageVersion50
64+
LanguageFeature.DefaultInterfaceMemberConsumption, languageVersion50
6365

6466
// F# preview
65-
LanguageFeature.NameOf, previewVersion
67+
LanguageFeature.FromEndSlicing, previewVersion
6668
LanguageFeature.OpenStaticClasses, previewVersion
6769
LanguageFeature.PackageManagement, previewVersion
68-
LanguageFeature.AndBang, previewVersion
69-
LanguageFeature.NullableOptionalInterop, previewVersion
70-
LanguageFeature.DefaultInterfaceMemberConsumption, previewVersion
7170
LanguageFeature.WitnessPassing, previewVersion
71+
LanguageFeature.NameOf, previewVersion
7272
]
7373

7474
let specified =
@@ -80,7 +80,7 @@ type LanguageVersion (specifiedVersionAsString) =
8080
| "latestmajor" -> latestMajorVersion
8181
| "4.6" -> languageVersion46
8282
| "4.7" -> languageVersion47
83-
(* | "5.0" -> languageVersion50 *)
83+
| "5.0" -> languageVersion50
8484
| _ -> 0m
8585

8686
let versionToString v =

tests/Directory.Build.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
44

55
<ItemGroup Condition="'$(UnitTestType)' == 'nunit'">
6-
<!-- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" /> -->
76
<PackageReference Include="NUnit" Version="$(NUnitVersion)" />
87
<PackageReference Include="NUnit3TestAdapter" Version="$(NUnit3TestAdapterVersion)" />
98
<PackageReference Include="NunitXml.TestLogger" Version="$(NunitXmlTestLoggerVersion)" />
109
</ItemGroup>
1110
<ItemGroup Condition="'$(UnitTestType)' == 'xunit'">
12-
<!-- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" /> -->
1311
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
1412
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
1513
<PackageReference Include="NunitXml.TestLogger" Version="$(NunitXmlTestLoggerVersion)" />
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace FSharp.Compiler.ErrorMessages.ComponentTests
4+
5+
open Xunit
6+
open FSharp.Test.Utilities
7+
open FSharp.Compiler.SourceCodeServices
8+
9+
module ``Access Of Type Abbreviation`` =
10+
11+
[<Fact>]
12+
let ``Private type produces warning when trying to export``() =
13+
CompilerAssert.TypeCheckSingleError
14+
"""
15+
module Library =
16+
type private Hidden = Hidden of unit
17+
type Exported = Hidden
18+
"""
19+
FSharpErrorSeverity.Warning
20+
44
21+
(4, 8, 4, 16)
22+
("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
23+
24+
[<Fact>]
25+
let ``Internal type passes when abbrev is internal``() =
26+
CompilerAssert.Pass
27+
"""
28+
module Library =
29+
type internal Hidden = Hidden of unit
30+
type internal Exported = Hidden
31+
"""
32+
33+
[<Fact>]
34+
let ``Internal type produces warning when trying to export``() =
35+
CompilerAssert.TypeCheckSingleError
36+
"""
37+
module Library =
38+
type internal Hidden = Hidden of unit
39+
type Exported = Hidden
40+
"""
41+
FSharpErrorSeverity.Warning
42+
44
43+
(4, 8, 4, 16)
44+
("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
45+
46+
[<Fact>]
47+
let ``Private type produces warning when abbrev is internal``() =
48+
CompilerAssert.TypeCheckSingleError
49+
"""
50+
module Library =
51+
type private Hidden = Hidden of unit
52+
type internal Exported = Hidden
53+
"""
54+
FSharpErrorSeverity.Warning
55+
44
56+
(4, 17, 4, 25)
57+
("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
58+
59+
[<Fact>]
60+
let ``Private type passes when abbrev is private``() =
61+
CompilerAssert.Pass
62+
"""
63+
module Library =
64+
type private Hidden = Hidden of unit
65+
type private Exported = Hidden
66+
"""
67+
68+
[<Fact>]
69+
let ``Default access type passes when abbrev is default``() =
70+
CompilerAssert.Pass
71+
"""
72+
module Library =
73+
type Hidden = Hidden of unit
74+
type Exported = Hidden
75+
"""

tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs renamed to tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
22

3-
namespace FSharp.Compiler.UnitTests
3+
namespace FSharp.Compiler.ErrorMessages.ComponentTests
44

5-
open NUnit.Framework
5+
open Xunit
66
open FSharp.Test.Utilities
77
open FSharp.Compiler.SourceCodeServices
88

9-
[<TestFixture>]
9+
1010
module ``Errors assigning to mutable objects`` =
1111

12-
[<Test>]
12+
[<Fact>]
1313
let ``Assign to immutable error``() =
1414
CompilerAssert.TypeCheckSingleError
1515
"""

tests/fsharp/Compiler/ErrorMessages/ClassesTests.fs renamed to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
22

3-
namespace FSharp.Compiler.UnitTests
3+
namespace FSharp.Compiler.ErrorMessages.ComponentTests
44

5-
open NUnit.Framework
5+
open Xunit
66
open FSharp.Test.Utilities
77
open FSharp.Compiler.SourceCodeServices
88

9-
[<TestFixture>]
109
module ``Classes`` =
1110

12-
[<Test>]
11+
[<Fact>]
1312
let ``Tuple In Abstract Method``() =
1413
CompilerAssert.TypeCheckWithErrors
1514
"""
@@ -27,7 +26,7 @@ let x =
2726
FSharpErrorSeverity.Error, 783, (6, 9, 6, 19), "At least one override did not correctly implement its corresponding abstract member"
2827
|]
2928

30-
[<Test>]
29+
[<Fact>]
3130
let ``Wrong Arity``() =
3231
CompilerAssert.TypeCheckSingleError
3332
"""
@@ -43,7 +42,7 @@ MyType.MyMember("", 0, 0)
4342
(7, 1, 7, 26)
4443
"A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments."
4544

46-
[<Test>]
45+
[<Fact>]
4746
let ``Method Is Not Static``() =
4847
CompilerAssert.TypeCheckSingleError
4948
"""
@@ -57,7 +56,7 @@ let x = Class1.X()
5756
(5, 9, 5, 17)
5857
"Method or object constructor 'X' is not static"
5958

60-
[<Test>]
59+
[<Fact>]
6160
let ``Matching Method With Same Name Is Not Abstract``() =
6261
CompilerAssert.TypeCheckWithErrors
6362
"""
@@ -75,7 +74,7 @@ let foo =
7574
FSharpErrorSeverity.Error, 783, (6, 11, 6, 14), "At least one override did not correctly implement its corresponding abstract member"
7675
|]
7776

78-
[<Test>]
77+
[<Fact>]
7978
let ``No Matching Abstract Method With Same Name``() =
8079
CompilerAssert.TypeCheckWithErrors
8180
"""
@@ -89,13 +88,13 @@ let x =
8988
}
9089
"""
9190
[|
92-
FSharpErrorSeverity.Error, 767, (8, 14, 8, 34), "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:\r\n MyFunction"
91+
FSharpErrorSeverity.Error, 767, (8, 14, 8, 34), "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction"
9392
FSharpErrorSeverity.Error, 17, (8, 19, 8, 27), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method"
94-
FSharpErrorSeverity.Error, 366, (7, 3, 9, 4), "No implementation was given for those members: \r\n\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'\r\n\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'\r\nNote that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
93+
FSharpErrorSeverity.Error, 366, (7, 3, 9, 4), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
9594
FSharpErrorSeverity.Error, 783, (7, 9, 7, 19), "At least one override did not correctly implement its corresponding abstract member"
9695
|]
9796

98-
[<Test>]
97+
[<Fact>]
9998
let ``Member Has Multiple Possible Dispatch Slots``() =
10099
CompilerAssert.TypeCheckWithErrors
101100
"""
@@ -108,11 +107,11 @@ type Overload =
108107
override __.Bar _ = 1
109108
"""
110109
[|
111-
FSharpErrorSeverity.Error, 366, (7, 15, 7, 24), "No implementation was given for those members: \r\n\t'abstract member IOverload.Bar : double -> int'\r\n\t'abstract member IOverload.Bar : int -> int'\r\nNote that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
112-
FSharpErrorSeverity.Error, 3213, (8, 21, 8, 24), "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:\r\n Bar : double -> int\r\n Bar : int -> int."
110+
FSharpErrorSeverity.Error, 366, (7, 15, 7, 24), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
111+
FSharpErrorSeverity.Error, 3213, (8, 21, 8, 24), "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int."
113112
|]
114113

115-
[<Test>]
114+
[<Fact>]
116115
let ``Do Cannot Have Visibility Declarations``() =
117116
CompilerAssert.ParseWithErrors
118117
"""
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace FSharp.Compiler.ErrorMessages.ComponentTests
4+
5+
open Xunit
6+
open FSharp.Test.Utilities
7+
open FSharp.Test.Utilities.Utilities
8+
open FSharp.Compiler.SourceCodeServices
9+
10+
module ``Confusing Type Name`` =
11+
12+
[<Fact>]
13+
let ``Checks expected types with multiple references``() =
14+
let csLibAB = """
15+
public class A { }
16+
public class B<T> { }
17+
"""
18+
let csLibACmpl =
19+
CompilationUtil.CreateCSharpCompilation(csLibAB, CSharpLanguageVersion.CSharp8, TargetFramework.NetCoreApp30, name = "libA")
20+
|> CompilationReference.Create
21+
22+
let csLibBCmpl =
23+
CompilationUtil.CreateCSharpCompilation(csLibAB, CSharpLanguageVersion.CSharp8, TargetFramework.NetCoreApp30, name = "libB")
24+
|> CompilationReference.Create
25+
26+
let fsLibC = """
27+
module AMaker
28+
let makeA () : A = A()
29+
let makeB () = B<_>()
30+
"""
31+
32+
let fsLibD = """
33+
module OtherAMaker
34+
let makeOtherA () : A = A()
35+
let makeOtherB () = B<_>()
36+
"""
37+
38+
let fsLibCCmpl =
39+
Compilation.Create(fsLibC, Fs, Library, cmplRefs = [csLibACmpl], name = "libC")
40+
|> CompilationReference.CreateFSharp
41+
42+
let fsLibDCmpl =
43+
Compilation.Create(fsLibD, Fs, Library, cmplRefs = [csLibBCmpl], name = "libD")
44+
|> CompilationReference.CreateFSharp
45+
46+
let app = """
47+
module ConfusingTypeName
48+
let a = AMaker.makeA()
49+
let otherA = OtherAMaker.makeOtherA()
50+
printfn "%A %A" (a.GetType().AssemblyQualifiedName) (otherA.GetType().AssemblyQualifiedName)
51+
printfn "%A" (a = otherA)
52+
53+
let b = AMaker.makeB<int>()
54+
let otherB = OtherAMaker.makeOtherB<int>()
55+
printfn "%A %A" (b.GetType().AssemblyQualifiedName) (otherB.GetType().AssemblyQualifiedName)
56+
printfn "%A" (b = otherB)
57+
"""
58+
59+
let appCmpl =
60+
Compilation.Create(app, Fs, Library, cmplRefs = [csLibACmpl; csLibBCmpl; fsLibCCmpl; fsLibDCmpl])
61+
62+
CompilerAssert.CompileWithErrors(
63+
appCmpl,
64+
[|
65+
(FSharpErrorSeverity.Error, 1, (6, 19, 6, 25), ("This expression was expected to have type\n 'A (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' \nbut here has type\n 'A (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' "))
66+
(FSharpErrorSeverity.Error, 1, (11, 19, 11, 25), ("This expression was expected to have type\n 'B<Microsoft.FSharp.Core.int> (libA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' \nbut here has type\n 'B<Microsoft.FSharp.Core.int> (libB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)' "))
67+
|], true)

tests/fsharp/Compiler/ErrorMessages/ConstructorTests.fs renamed to tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
22

3-
namespace FSharp.Compiler.UnitTests
3+
namespace FSharp.Compiler.ErrorMessages.ComponentTests
44

5-
open NUnit.Framework
5+
open Xunit
66
open FSharp.Test.Utilities
77
open FSharp.Compiler.SourceCodeServices
88

9-
[<TestFixture>]
109
module ``Constructor`` =
1110

12-
[<Test>]
11+
[<Fact>]
1312
let ``Invalid Record``() =
1413
CompilerAssert.TypeCheckWithErrors
1514
"""
1615
type Record = {field1:int; field2:int}
1716
let doSomething (xs) = List.map (fun {field1=x} -> x) xs
18-
1917
doSomething {Record.field1=0; field2=0}
2018
"""
2119
[|
22-
FSharpErrorSeverity.Error, 1, (5, 13, 5, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' "
23-
FSharpErrorSeverity.Warning, 20, (5, 1, 5, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'."
20+
FSharpErrorSeverity.Error, 1, (4, 13, 4, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' "
21+
FSharpErrorSeverity.Warning, 20, (4, 1, 4, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'."
2422
|]
2523

26-
[<Test>]
24+
[<Fact>]
2725
let ``Comma In Rec Ctor``() =
2826
CompilerAssert.TypeCheckWithErrors
2927
"""
3028
type Person = { Name : string; Age : int; City : string }
3129
let x = { Name = "Isaac", Age = 21, City = "London" }
3230
"""
3331
[|
34-
FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' \r\nA ';' is used to separate field values in records. Consider replacing ',' with ';'."
32+
FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'."
3533
FSharpErrorSeverity.Error, 764, (3, 9, 3, 54), "No assignment given for field 'Age' of type 'Test.Person'"
3634
|]
3735

38-
[<Test>]
36+
[<Fact>]
3937
let ``Missing Comma In Ctor``() =
4038
CompilerAssert.TypeCheckWithErrors
4139
"""
@@ -48,13 +46,13 @@ let p =
4846
Age = 18)
4947
"""
5048
[|
51-
FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined. Maybe you want one of the following:\r\n nan"
49+
FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan"
5250
FSharpErrorSeverity.Warning, 20, (7, 12, 7, 25), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'."
5351
FSharpErrorSeverity.Error, 39, (8, 12, 8, 15), "The value or constructor 'Age' is not defined."
5452
FSharpErrorSeverity.Error, 501, (7, 5, 8, 21), "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',')."
5553
|]
5654

57-
[<Test>]
55+
[<Fact>]
5856
let ``Missing Ctor Value``() =
5957
CompilerAssert.TypeCheckSingleError
6058
"""
@@ -71,7 +69,7 @@ let p =
7169
(7, 5, 8, 21)
7270
"The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'."
7371

74-
[<Test>]
72+
[<Fact>]
7573
let ``Extra Argument In Ctor``() =
7674
CompilerAssert.TypeCheckSingleError
7775
"""
@@ -87,7 +85,7 @@ let p =
8785
(7, 5, 7, 14)
8886
"The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'."
8987

90-
[<Test>]
88+
[<Fact>]
9189
let ``Extra Argument In Ctor2``() =
9290
CompilerAssert.TypeCheckSingleError
9391
"""
@@ -105,7 +103,7 @@ let p =
105103
(9, 5, 9, 16)
106104
"The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'."
107105

108-
[<Test>]
106+
[<Fact>]
109107
let ``Valid Comma In Rec Ctor``() =
110108
CompilerAssert.Pass
111109
"""

0 commit comments

Comments
 (0)