-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix langversion with multiple projects (#7293)
- Loading branch information
1 parent
d488458
commit 9c1a0d1
Showing
10 changed files
with
188 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
||
namespace FSharp.Compiler.UnitTests | ||
|
||
open FSharp.Compiler.SourceCodeServices | ||
open NUnit.Framework | ||
|
||
|
||
(* | ||
Tests in this file evaluate whether the language supports accessing functions on static classes using open | ||
The feature was added in FSharp4.7, the test cases ensure that the original errors are reproduced when the langversion:4.6 is specified | ||
*) | ||
|
||
[<TestFixture>] | ||
module OpenStaticClassesTests = | ||
|
||
let baseModule = """ | ||
module Core_OpenStaticClasses | ||
[<AbstractClass; Sealed>] | ||
type MyMath() = | ||
static member Min(a: double, b: double) = System.Math.Min(a, b) | ||
static member Min(a: int, b: int) = System.Math.Min(a, b) | ||
[<AbstractClass; Sealed; AutoOpen>] | ||
type AutoOpenMyMath() = | ||
static member AutoMin(a: double, b: double) = System.Math.Min(a, b) | ||
static member AutoMin(a: int, b: int) = System.Math.Min(a, b) | ||
[<AbstractClass; Sealed; RequireQualifiedAccess>] | ||
type NotAllowedToOpen() = | ||
static member QualifiedMin(a: double, b: double) = System.Math.Min(a, b) | ||
static member QualifiedMin(a: int, b: int) = System.Math.Min(a, b) | ||
""" | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenSystemMathOnce - langversion:v4.6`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.6" |] | ||
(baseModule + """ | ||
module OpenSystemMathOnce = | ||
open System.Math | ||
let x = Min(1.0, 2.0)""") | ||
[| | ||
(FSharpErrorSeverity.Error, 39, (22,28,22,32), "The namespace 'Math' is not defined."); | ||
(FSharpErrorSeverity.Error, 39, (23,24,23,27), "The value or constructor 'Min' is not defined.") | ||
|] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenSystemMathOnce - langversion:v4.7`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.7" |] | ||
(baseModule + """ | ||
module OpenSystemMathOnce = | ||
open System.Math | ||
let x = Min(1.0, 2.0)""") | ||
[| |] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenSystemMathTwice - langversion:v4.6`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.6" |] | ||
(baseModule + """ | ||
module OpenSystemMathTwice = | ||
open System.Math | ||
let x = Min(1.0, 2.0) | ||
open System.Math | ||
let x2 = Min(2.0, 1.0)""") | ||
[| | ||
(FSharpErrorSeverity.Error, 39, (22,17,22,21), "The namespace 'Math' is not defined."); | ||
(FSharpErrorSeverity.Error, 39, (23,13,23,16), "The value or constructor 'Min' is not defined.") | ||
(FSharpErrorSeverity.Error, 39, (25,17,25,21), "The namespace 'Math' is not defined."); | ||
(FSharpErrorSeverity.Error, 39, (26,14,26,17), "The value or constructor 'Min' is not defined.") | ||
|] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenSystemMathTwice - langversion:v4.7`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.7" |] | ||
(baseModule + """ | ||
module OpenSystemMathOnce = | ||
open System.Math | ||
let x = Min(1.0, 2.0)""") | ||
[| |] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenMyMathOnce - langversion:v4.6`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.6" |] | ||
(baseModule + """ | ||
module OpenMyMathOnce = | ||
open MyMath | ||
let x = Min(1.0, 2.0) | ||
let x2 = Min(1, 2)""") | ||
[| | ||
(FSharpErrorSeverity.Error, 39, (22,10,22,16), "The namespace or module 'MyMath' is not defined."); | ||
(FSharpErrorSeverity.Error, 39, (23,13,23,16), "The value or constructor 'Min' is not defined.") | ||
(FSharpErrorSeverity.Error, 39, (24,14,24,17), "The value or constructor 'Min' is not defined.") | ||
|] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenMyMathOnce - langversion:v4.7`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.7" |] | ||
(baseModule + """ | ||
module OpenMyMathOnce = | ||
open MyMath | ||
let x = Min(1.0, 2.0) | ||
let x2 = Min(1, 2)""") | ||
[| |] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - DontOpenAutoMath - langversion:v4.6`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.6" |] | ||
(baseModule + """ | ||
module DontOpenAutoMath = | ||
let x = AutoMin(1.0, 2.0) | ||
let x2 = AutoMin(1, 2)""") | ||
[| | ||
(FSharpErrorSeverity.Error, 39, (22,13,22,20), "The value or constructor 'AutoMin' is not defined."); | ||
(FSharpErrorSeverity.Error, 39, (23,14,23,21), "The value or constructor 'AutoMin' is not defined.") | ||
|] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - DontOpenAutoMath - langversion:v4.7`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.7" |] | ||
(baseModule + """ | ||
module DontOpenAutoMath = | ||
let x = AutoMin(1.0, 2.0) | ||
let x2 = AutoMin(1, 2)""") | ||
[| |] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenAutoMath - langversion:v4.6`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.6" |] | ||
(baseModule + """ | ||
module OpenAutoMath = | ||
open AutoOpenMyMath | ||
//open NotAllowedToOpen | ||
let x = AutoMin(1.0, 2.0) | ||
let x2 = AutoMin(1, 2)""") | ||
[| | ||
(FSharpErrorSeverity.Error, 39, (21,10,21,24), "The namespace or module 'AutoOpenMyMath' is not defined."); | ||
(FSharpErrorSeverity.Error, 39, (24,13,24,20), "The value or constructor 'AutoMin' is not defined.") | ||
(FSharpErrorSeverity.Error, 39, (25,14,25,21), "The value or constructor 'AutoMin' is not defined.") | ||
|] | ||
|
||
[<Test>] | ||
let ``OpenStaticClassesTests - OpenAutoMath - langversion:v4.7`` () = | ||
CompilerAssert.TypeCheckWithErrorsAndOptions | ||
[| "--langversion:4.7" |] | ||
(baseModule + """ | ||
module OpenAutoMath = | ||
open AutoOpenMyMath | ||
//open NotAllowedToOpen | ||
let x = AutoMin(1.0, 2.0) | ||
let x2 = AutoMin(1, 2)""") | ||
[| |] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.