Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/fsharp/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -2643,7 +2643,7 @@ cPrototype:
SynExpr.Ident (ident("failwith", rhs parseState 6)),
SynExpr.Const (SynConst.String("extern was not given a DllImport attribute", rhs parseState 8), rhs parseState 8),
mRhs)
(fun attrs vis ->
(fun attrs _ ->
let bindingId = SynPat.LongIdent (LongIdentWithDots([nm], []), None, Some noInferredTypars, SynArgPats.Pats [SynPat.Tuple(false, args, argsm)], vis, nmm)
let binding = mkSynBinding
(xmlDoc, bindingId)
Expand Down
2 changes: 1 addition & 1 deletion tests/fsharp/typeProviders/helloWorld/provided.fs
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,5 @@ module TheOuterType =

module DllImportSmokeTest =
[<System.Runtime.InteropServices.DllImport("kernel32.dll")>]
extern System.UInt32 private GetLastError()
extern System.UInt32 GetLastError()

11 changes: 8 additions & 3 deletions tests/service/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,15 @@ let matchBraces (name: string, code: string) =
let braces = checker.MatchBraces(filePath, FSharp.Compiler.Text.SourceText.ofString code, options) |> Async.RunSynchronously
braces

let parseSourceCodeAndGetModule (source: string) =
match parseSourceCode ("test", source) with
| Some (ParsedInput.ImplFile (ParsedImplFileInput (_, _, _, _, _, [ moduleOrNamespace ], _))) -> moduleOrNamespace

let getSingleModuleLikeDecl (input: ParsedInput option) =
match input with
| Some (ParsedInput.ImplFile (ParsedImplFileInput (modules = [ decl ]))) -> decl
| _ -> failwith "Could not get module decls"

let parseSourceCodeAndGetModule (source: string) =
parseSourceCode ("test", source) |> getSingleModuleLikeDecl


/// Extract range info
let tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn)
Expand Down
34 changes: 33 additions & 1 deletion tests/service/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ module Tests.Service.Symbols
#endif

open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.SyntaxTree
open FsUnit
open NUnit.Framework
open FSharp.Compiler.SourceCodeServices

module ActivePatterns =

Expand Down Expand Up @@ -57,6 +58,37 @@ match "foo" with
getCaseUsages partialPatternInput 7 |> Array.head |> getGroupName |> shouldEqual "|String|_|"


module ExternDeclarations =
[<Test>]
let ``Access modifier`` () =
let parseResults, checkResults = getParseAndCheckResults """
extern int a()
extern int public b()
extern int private c()
"""
let (SynModuleOrNamespace (decls = decls)) = getSingleModuleLikeDecl parseResults.ParseTree

[ None
Some SynAccess.Public
Some SynAccess.Private ]
|> List.zip decls
|> List.iter (fun (actual, expected) ->
match actual with
| SynModuleDecl.Let (_, [Binding (accessibility = access)], _) -> access |> should equal expected
| decl -> failwithf "unexpected decl: %O" decl)

[ "a", (true, false, false, false)
"b", (true, false, false, false)
"c", (false, false, false, true) ]
|> List.iter (fun (name, expected) ->
match findSymbolByName name checkResults with
| :? FSharpMemberOrFunctionOrValue as mfv ->
let access = mfv.Accessibility
(access.IsPublic, access.IsProtected, access.IsInternal, access.IsPrivate)
|> should equal expected
| _ -> failwithf "Couldn't get mfv: %s" name)


module XmlDocSig =

[<Test>]
Expand Down