Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Foo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Meh

let bar (name:string) : 'a = failwith<'a> "todo"

#nowarn "40"

type Foo () =
member __.Bar (name : string) : unit -> 'a =
let rec prov : (unit -> 'a) ref = ref (fun () ->
let p : (unit -> 'a) = bar name
prov := p
p())
fun () -> (!prov)()
7 changes: 7 additions & 0 deletions Foo.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--nowarn:FS3370,FS0075
--warn:4
--warnaserror
--warnaserror:3239
--warnaserror-:44
-a
Foo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,8 @@ module Stuff =
/// References projects are expected to have been built.
let localResponseFiles =
[|
@"C:\Projects\fantomas\src\Fantomas.Core.Tests\Fantomas.Core.Tests.rsp"
// @"C:\Projects\fantomas\src\Fantomas.Core.Tests\Fantomas.Core.Tests.rsp"
Path.Combine(__SOURCE_DIRECTORY__, "..", "..", "..", "Foo.rsp")
|]
|> Array.collect (fun f ->
[|
Expand All @@ -816,7 +817,7 @@ let localResponseFiles =
)

// Uncomment this attribute if you want run this test against local response files.
// [<Theory>]
[<Theory>]
[<MemberData(nameof(localResponseFiles))>]
let ``TypeCheck last file in project with transparent compiler`` useTransparentCompiler responseFile =
let responseFile = FileInfo responseFile
Expand Down
46 changes: 30 additions & 16 deletions tests/FSharp.Test.Utilities/ProjectGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,33 @@ type SyntheticProject =
}
|> String.concat "\n"

let baseOptions, _ =
checker.GetProjectOptionsFromScript(
"file.fsx",
SourceText.ofString referenceScript,
assumeDotNetFramework = false
)
|> Async.RunSynchronously
let isRealProject = this.SourceFiles |> List.forall (fun sf -> sf.IsPhysicalFile)

let otherOptions =
if isRealProject then
List.toArray this.OtherOptions
else

let baseOptions =
if isRealProject then
Unchecked.defaultof<FSharpProjectOptions>
else

checker.GetProjectOptionsFromScript(
"file.fsx",
SourceText.ofString referenceScript,
assumeDotNetFramework = false
)
|> Async.RunSynchronously
|> fst

Set [
yield! baseOptions.OtherOptions
"--optimize+"
for p in this.DependsOn do
$"-r:{p.OutputFilename}"
yield! this.OtherOptions ]
|> Set.toArray

{
ProjectFileName = this.ProjectFileName
Expand All @@ -327,14 +347,7 @@ type SyntheticProject =
this.ProjectDir ++ f.SignatureFileName

this.ProjectDir ++ f.FileName |]
OtherOptions =
Set [
yield! baseOptions.OtherOptions
"--optimize+"
for p in this.DependsOn do
$"-r:{p.OutputFilename}"
yield! this.OtherOptions ]
|> Set.toArray
OtherOptions = otherOptions
ReferencedProjects =
[| for p in this.DependsOn do
FSharpReferencedProject.FSharpReference(p.OutputFilename, p.GetProjectOptions checker) |]
Expand All @@ -343,7 +356,8 @@ type SyntheticProject =
LoadTime = DateTime()
UnresolvedReferences = None
OriginalLoadReferences = []
Stamp = None }
Stamp = None
}

OptionsCache[cacheKey]

Expand Down