Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7b958fd
add a failing test exhibiting issue #8351
smoothdeveloper Jan 24, 2020
827e5b8
updating VB and F# code to have private getter as well, VB has same i…
smoothdeveloper Jan 24, 2020
b5e59d5
Furthering the test, all languages exhibit the same issue.
smoothdeveloper Jan 25, 2020
cccb3da
F# setter on Prop1 works, despite the getter is internal
smoothdeveloper Jan 25, 2020
5986427
fix for 8351 (/!\ may break other things)
smoothdeveloper Jan 25, 2020
b799113
reshuffle ILMemberAccess so plain comparison works
smoothdeveloper Jan 25, 2020
8f94aff
testConfig has a new version
smoothdeveloper Jun 10, 2020
b5f5f6a
adding basic test around ILMemberAccess items being comparable to eac…
smoothdeveloper Jun 12, 2020
1ccb4b1
ceci n'est pas une fonction factorielle
smoothdeveloper Jun 12, 2020
b024d51
codereview: redefine order of ILMemberAccess to match roslyn codebase
smoothdeveloper Jun 12, 2020
b88ba3c
Update for fix8351
KevinRansom Jun 15, 2020
49d99be
feedback
KevinRansom Jun 16, 2020
fb3c52b
Update src/fsharp/AccessibilityLogic.fs
KevinRansom Jun 20, 2020
16deb23
resolve conflicts
KevinRansom Jun 20, 2020
37be39e
merge
KevinRansom Jun 20, 2020
24b4d28
Update
smoothdeveloper Jun 22, 2020
26d7cc5
Update language version status of some features (#9507)
KevinRansom Jun 23, 2020
3a067f4
Consolidate Compiler ErrorMessage tests under one suite. (#9525)
vzarytovskii Jun 23, 2020
403f594
Merge pull request #9543 from dotnet/merges/master-to-release/dev16.7
KevinRansom Jun 23, 2020
8bfcdd6
Merge branch 'master' into fix-for-issue-8351
KevinRansom Jun 23, 2020
4456e0a
Better classification: such colors, much wow (#9511)
cartermp Jun 23, 2020
1ecc201
Merge pull request #8354 from smoothdeveloper/fix-for-issue-8351
KevinRansom Jun 23, 2020
6e50f75
Merge pull request #9550 from dotnet/merges/master-to-release/dev16.7
KevinRansom Jun 24, 2020
c479cde
Update FSComp.txt (#9556)
cartermp Jun 24, 2020
2f202ef
Merge pull request #9559 from dotnet/merges/master-to-release/dev16.7
KevinRansom Jun 24, 2020
5f8a77b
Syntax tree: include modifiers to binding ranges (#9541)
auduchinok Jun 24, 2020
cff1922
Merge pull request #9562 from dotnet/merges/master-to-release/dev16.7
KevinRansom Jun 25, 2020
79c9702
Update xlf (#9567)
KevinRansom Jun 25, 2020
d34dab9
Merge pull request #9568 from dotnet/merges/master-to-release/dev16.7
KevinRansom Jun 26, 2020
70f3758
Moved fsharpqa/Libraries/Core/Operators test cases to NUnit (#9570)
ThorstenReichert Jun 26, 2020
42f26f2
Merge pull request #9572 from dotnet/merges/master-to-release/dev16.7
KevinRansom Jun 26, 2020
b74c9de
Merge master to release/dev16.7 (#9578)
dotnet-bot Jun 27, 2020
7d2b1e6
Merge branch 'release/dev16.8' into merges/release/dev16.7-to-release…
KevinRansom Jun 28, 2020
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
61 changes: 52 additions & 9 deletions src/fsharp/AccessibilityLogic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,53 @@ let private IsILMethInfoAccessible g amap m adType ad ilminfo =
let GetILAccessOfILPropInfo (ILPropInfo(tinfo, pdef)) =
let tdef = tinfo.RawMetadata
let ilAccess =
match pdef.GetMethod with
| Some mref -> (resolveILMethodRef tdef mref).Access
| None ->
match pdef.SetMethod with
| None -> ILMemberAccess.Public
| Some mref -> (resolveILMethodRef tdef mref).Access
match pdef.GetMethod, pdef.SetMethod with
| Some mref, None
| None, Some mref -> (resolveILMethodRef tdef mref).Access

| Some mrefGet, Some mrefSet ->
//
// Dotnet properties have a getter and a setter method, each of which can have a separate visibility public, protected, private etc ...
// This code computes the visibility for the property by choosing the most visible method. This approximation is usefull for cases
// where the compiler needs to know the visibility of the property.
// The specific ordering for choosing the most visible is:
// ILMemberAccess.Public,
// ILMemberAccess.FamilyOrAssembly
// ILMemberAccess.Assembly
// ILMemberAccess.Family
// ILMemberAccess.FamilyAndAssembly
// ILMemberAccess.Private
// ILMemberAccess.CompilerControlled
//
let getA = (resolveILMethodRef tdef mrefGet).Access
let setA = (resolveILMethodRef tdef mrefSet).Access

// Use the accessors to determine the visibility of the property.
// N.B. It is critical to keep the ordering in decreasing visibility order in the following match expression
match getA, setA with
| ILMemberAccess.Public, _
| _, ILMemberAccess.Public -> ILMemberAccess.Public

| ILMemberAccess.FamilyOrAssembly, _
| _, ILMemberAccess.FamilyOrAssembly -> ILMemberAccess.FamilyOrAssembly

| ILMemberAccess.Assembly, _
| _, ILMemberAccess.Assembly -> ILMemberAccess.Assembly

| ILMemberAccess.Family, _
| _, ILMemberAccess.Family -> ILMemberAccess.Family

| ILMemberAccess.FamilyAndAssembly, _
| _, ILMemberAccess.FamilyAndAssembly -> ILMemberAccess.FamilyAndAssembly

| ILMemberAccess.Private, _
| _, ILMemberAccess.Private -> ILMemberAccess.Private

| ILMemberAccess.CompilerControlled, _
| _, ILMemberAccess.CompilerControlled -> ILMemberAccess.CompilerControlled

| None, None -> ILMemberAccess.Public

ilAccess

let IsILPropInfoAccessible g amap m ad pinfo =
Expand Down Expand Up @@ -323,8 +364,11 @@ let IsMethInfoAccessible amap m ad minfo = IsTypeAndMethInfoAccessible amap m ad

let IsPropInfoAccessible g amap m ad = function
| ILProp ilpinfo -> IsILPropInfoAccessible g amap m ad ilpinfo
| FSProp (_, _, Some vref, _)
| FSProp (_, _, _, Some vref) -> IsValAccessible ad vref
| FSProp (_, _, Some vref, None)
| FSProp (_, _, None, Some vref) -> IsValAccessible ad vref
| FSProp (_, _, Some vrefGet, Some vrefSet) ->
// pick most accessible
IsValAccessible ad vrefGet || IsValAccessible ad vrefSet
#if !NO_EXTENSIONTYPING
| ProvidedProp (amap, tppi, m) as pp->
let access =
Expand All @@ -343,4 +387,3 @@ let IsPropInfoAccessible g amap m ad = function

let IsFieldInfoAccessible ad (rfref:RecdFieldInfo) =
IsAccessible ad rfref.RecdField.Accessibility

2 changes: 1 addition & 1 deletion src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1512,4 +1512,4 @@ featureFixedIndexSlice3d4d,"fixed-index slice 3d/4d"
featureAndBang,"applicative computation expressions"
featureNullableOptionalInterop,"nullable optional interop"
featureDefaultInterfaceMemberConsumption,"default interface member consumption"
featureWitnessPassing,"witness passing"
featureWitnessPassing,"witness passing for trait constraints in F# quotations"
73 changes: 62 additions & 11 deletions src/fsharp/FSharp.Core/string.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace Microsoft.FSharp.Core
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
[<RequireQualifiedAccess>]
module String =
[<Literal>]
/// LOH threshold is calculated from FSharp.Compiler.AbstractIL.Internal.Library.LOH_SIZE_THRESHOLD_BYTES,
/// and is equal to 80_000 / sizeof<char>
let LOH_CHAR_THRESHOLD = 40_000

[<CompiledName("Length")>]
let length (str:string) = if isNull str then 0 else str.Length

Expand All @@ -37,9 +42,13 @@ namespace Microsoft.FSharp.Core
if String.IsNullOrEmpty str then
String.Empty
else
let res = StringBuilder str.Length
str |> iter (fun c -> res.Append(mapping c) |> ignore)
res.ToString()
let result = str.ToCharArray()
let mutable i = 0
for c in result do
result.[i] <- mapping c
i <- i + 1

new String(result)

[<CompiledName("MapIndexed")>]
let mapi (mapping: int -> char -> char) (str:string) =
Expand All @@ -53,13 +62,30 @@ namespace Microsoft.FSharp.Core

[<CompiledName("Filter")>]
let filter (predicate: char -> bool) (str:string) =
if String.IsNullOrEmpty str then
let len = length str

if len = 0 then
String.Empty
else
let res = StringBuilder str.Length

elif len > LOH_CHAR_THRESHOLD then
// By using SB here, which is twice slower than the optimized path, we prevent LOH allocations
// and 'stop the world' collections if the filtering results in smaller strings.
// We also don't pre-allocate SB here, to allow for less mem pressure when filter result is small.
let res = StringBuilder()
str |> iter (fun c -> if predicate c then res.Append c |> ignore)
res.ToString()

else
// Must do it this way, since array.fs is not yet in scope, but this is safe
let target = Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked len
let mutable i = 0
for c in str do
if predicate c then
target.[i] <- c
i <- i + 1

String(target, 0, i)

[<CompiledName("Collect")>]
let collect (mapping: char -> string) (str:string) =
if String.IsNullOrEmpty str then
Expand All @@ -81,13 +107,38 @@ namespace Microsoft.FSharp.Core
let replicate (count:int) (str:string) =
if count < 0 then invalidArgInputMustBeNonNegative "count" count

if String.IsNullOrEmpty str then
let len = length str
if len = 0 || count = 0 then
String.Empty

elif len = 1 then
new String(str.[0], count)

elif count <= 4 then
match count with
| 1 -> str
| 2 -> String.Concat(str, str)
| 3 -> String.Concat(str, str, str)
| _ -> String.Concat(str, str, str, str)

else
let res = StringBuilder(count * str.Length)
for i = 0 to count - 1 do
res.Append str |> ignore
res.ToString()
// Using the primitive, because array.fs is not yet in scope. It's safe: both len and count are positive.
let target = Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked (len * count)
let source = str.ToCharArray()

// O(log(n)) performance loop:
// Copy first string, then keep copying what we already copied
// (i.e., doubling it) until we reach or pass the halfway point
Array.Copy(source, 0, target, 0, len)
let mutable i = len
while i * 2 < target.Length do
Array.Copy(target, 0, target, i, i)
i <- i * 2

// finally, copy the remain half, or less-then half
Array.Copy(target, 0, target, i, target.Length - i)
new String(target)


[<CompiledName("ForAll")>]
let forall predicate (str:string) =
Expand Down
12 changes: 6 additions & 6 deletions src/fsharp/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ type LanguageVersion (specifiedVersionAsString) =

// F# 5.0
LanguageFeature.FixedIndexSlice3d4d, languageVersion50
LanguageFeature.FromEndSlicing, languageVersion50
LanguageFeature.DotlessFloat32Literal, languageVersion50
LanguageFeature.AndBang, languageVersion50
LanguageFeature.NullableOptionalInterop, languageVersion50
LanguageFeature.DefaultInterfaceMemberConsumption, languageVersion50

// F# preview
LanguageFeature.NameOf, previewVersion
LanguageFeature.FromEndSlicing, previewVersion
LanguageFeature.OpenStaticClasses, previewVersion
LanguageFeature.PackageManagement, previewVersion
LanguageFeature.AndBang, previewVersion
LanguageFeature.NullableOptionalInterop, previewVersion
LanguageFeature.DefaultInterfaceMemberConsumption, previewVersion
LanguageFeature.WitnessPassing, previewVersion
LanguageFeature.NameOf, previewVersion
]

let specified =
Expand All @@ -80,7 +80,7 @@ type LanguageVersion (specifiedVersionAsString) =
| "latestmajor" -> latestMajorVersion
| "4.6" -> languageVersion46
| "4.7" -> languageVersion47
(* | "5.0" -> languageVersion50 *)
| "5.0" -> languageVersion50
| _ -> 0m

let versionToString v =
Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -2702,7 +2702,7 @@ localBinding:
let mRhs = expr.Range
let optReturnType = $4
let bindingBuilder, mBindLhs = $3
let localBindingRange = unionRanges (rhs2 parseState 3 5) mRhs
let localBindingRange = unionRanges (rhs2 parseState 1 5) mRhs
let localBindingBuilder =
(fun attrs vis mLetKwd ->
let mWhole = unionRanges mLetKwd mRhs
Expand All @@ -2711,7 +2711,7 @@ localBinding:
localBindingRange, localBindingBuilder }

| opt_inline opt_mutable bindingPattern opt_topReturnTypeWithTypeConstraints EQUALS error
{ let mWhole = rhs2 parseState 3 5
{ let mWhole = rhs2 parseState 1 5
let mRhs = rhs parseState 5
let optReturnType = $4
let bindingBuilder, mBindLhs = $3
Expand All @@ -2726,7 +2726,7 @@ localBinding:
| opt_inline opt_mutable bindingPattern opt_topReturnTypeWithTypeConstraints recover
{ if not $5 then reportParseErrorAt (rhs parseState 5) (FSComp.SR.parsUnexpectedEndOfFileDefinition())
let optReturnType = $4
let mWhole = match optReturnType with None -> rhs parseState 3 | Some _ -> rhs2 parseState 3 4
let mWhole = rhs2 parseState 1 (match optReturnType with None -> 3 | _ -> 4)
let mRhs = mWhole.EndRange // zero-width range at end of last good token
let bindingBuilder, mBindLhs = $3
let localBindingBuilder =
Expand Down
Loading