Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc47b9b0

Browse files
authored
Merge pull requestdotnet#4181 from brettfo/merge-master-to-dev15.6
Merge master to dev15.6
2 parentse03bc82 +94671b9 commitc47b9b0

File tree

25 files changed

+186
-39
lines changed

25 files changed

+186
-39
lines changed

‎src/fsharp/ConstraintSolver.fs‎

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ let ShowAccessDomain ad =
370370
// Solve
371371

372372
exception NonRigidTyparofDisplayEnv*stringoption*range*TType*TType*range
373-
exception LocallyAbortOperationThatFailsToResolveOverload
374373
exception LocallyAbortOperationThatLosesAbbrevs
375374
letlocalAbortD= ErrorD LocallyAbortOperationThatLosesAbbrevs
376375

@@ -739,19 +738,19 @@ and solveTypMeetsTyparConstraints (csenv:ConstraintSolverEnv) ndeep m2 trace ty
739738
| Some destTypar->
740739
AddConstraint csenv ndeep m2 trace destTypar(TyparConstraint.DefaultsTo(priority, dty, m))
741740

742-
| TyparConstraint.SupportsNull m2-> SolveTypSupportsNull csenv ndeep m2 trace ty
743-
| TyparConstraint.IsEnum(underlying, m2)-> SolveTypIsEnum csenv ndeep m2 trace ty underlying
744-
| TyparConstraint.SupportsComparison(m2)-> SolveTypeSupportsComparison csenv ndeep m2 trace ty
745-
| TyparConstraint.SupportsEquality(m2)-> SolveTypSupportsEquality csenv ndeep m2 trace ty
741+
| TyparConstraint.SupportsNull m2-> SolveTypSupportsNull csenv ndeep m2 trace ty
742+
| TyparConstraint.IsEnum(underlying, m2)-> SolveTypIsEnum csenv ndeep m2 trace ty underlying
743+
| TyparConstraint.SupportsComparison(m2)-> SolveTypeSupportsComparison csenv ndeep m2 trace ty
744+
| TyparConstraint.SupportsEquality(m2)-> SolveTypSupportsEquality csenv ndeep m2 trace ty
746745
| TyparConstraint.IsDelegate(aty, bty, m2)-> SolveTypIsDelegate csenv ndeep m2 trace ty aty bty
747-
| TyparConstraint.IsNonNullableStruct m2-> SolveTypIsNonNullableValueType csenv ndeep m2 trace ty
748-
| TyparConstraint.IsUnmanaged m2-> SolveTypIsUnmanaged csenv ndeep m2 trace ty
749-
| TyparConstraint.IsReferenceType m2-> SolveTypIsReferenceType csenv ndeep m2 trace ty
750-
| TyparConstraint.RequiresDefaultConstructor m2-> SolveTypRequiresDefaultConstructor csenv ndeep m2 trace ty
746+
| TyparConstraint.IsNonNullableStruct m2-> SolveTypIsNonNullableValueType csenv ndeep m2 trace ty
747+
| TyparConstraint.IsUnmanaged m2-> SolveTypIsUnmanaged csenv ndeep m2 trace ty
748+
| TyparConstraint.IsReferenceType m2-> SolveTypIsReferenceType csenv ndeep m2 trace ty
749+
| TyparConstraint.RequiresDefaultConstructor m2-> SolveTypRequiresDefaultConstructor csenv ndeep m2 trace ty
751750
| TyparConstraint.SimpleChoice(tys, m2)-> SolveTypChoice csenv ndeep m2 trace ty tys
752751
| TyparConstraint.CoercesTo(ty2, m2)-> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m2 trace None ty2 ty
753-
| TyparConstraint.MayResolveMember(traitInfo, m2)->
754-
SolveMemberConstraint csenvfalsefalsendeep m2 trace traitInfo++(fun _-> CompleteD)
752+
| TyparConstraint.MayResolveMember(traitInfo, m2)->
753+
SolveMemberConstraint csenvfalse ndeep m2 trace traitInfo++(fun _-> CompleteD)
755754
)))
756755

757756

@@ -761,15 +760,14 @@ and SolveTypEqualsTyp (csenv:ConstraintSolverEnv) ndeep m2 (trace: OptionalTrace
761760
letndeep= ndeep+1
762761
letaenv= csenv.EquivEnv
763762
letg= csenv.g
763+
if ty1=== ty2then CompleteDelse
764764

765765
match cxslnwith
766766
| Some(traitInfo, traitSln)when traitInfo.Solution.IsNone->
767767
// If this is an overload resolution at this point it's safe to assume the candidate member being evaluated solves this member constraint.
768768
TransactMemberConstraintSolution traitInfo trace traitSln
769769
|_->()
770770

771-
if ty1=== ty2then CompleteDelse
772-
773771
letcanShortcut=not trace.HasTrace
774772
letsty1= stripTyEqnsA csenv.g canShortcut ty1
775773
letsty2= stripTyEqnsA csenv.g canShortcut ty2
@@ -943,7 +941,7 @@ and SolveDimensionlessNumericType (csenv:ConstraintSolverEnv) ndeep m2 trace ty
943941
/// We pretend int and other types support a number of operators. In the actual IL for mscorlib they
944942
/// don't, however the type-directed static optimization rules in the library code that makes use of this
945943
/// will deal with the problem.
946-
andSolveMemberConstraint(csenv:ConstraintSolverEnv)ignoreUnresolvedOverloadpermitWeakResolution ndeep m2 trace(TTrait(tys,nm,memFlags,argtys,rty,sln)):OperationResult<bool>=
944+
andSolveMemberConstraint(csenv:ConstraintSolverEnv)permitWeakResolution ndeep m2 trace(TTrait(tys,nm,memFlags,argtys,rty,sln)):OperationResult<bool>=
947945
// Do not re-solve if already solved
948946
if sln.Value.IsSomethen ResultDtrueelse
949947
letg= csenv.g
@@ -1300,12 +1298,9 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) ignoreUnresolvedOverload p
13001298
letfrees= GetFreeTyparsOfMemberConstraint csenv traitInfo
13011299

13021300
// If there's nothing left to learn then raise the errors
1303-
(if(permitWeakResolution&& isNil support)|| isNil freesthen errors
1304-
// Otherwise re-record the trait waiting for canonicalization
1305-
else AddMemberConstraint csenv ndeep m2 trace traitInfo support frees)++(fun()->
1306-
match errorswith
1307-
| ErrorResult(_, UnresolvedOverloading_)whennot ignoreUnresolvedOverload&&(not(nm="op_Explicit"|| nm="op_Implicit"))-> ErrorD LocallyAbortOperationThatFailsToResolveOverload
1308-
|_-> ResultD TTraitUnsolved)
1301+
(if(permitWeakResolution&& isNil support)|| isNil freesthen errors
1302+
// Otherwise re-record the trait waiting for canonicalization
1303+
else AddMemberConstraint csenv ndeep m2 trace traitInfo support frees)++(fun()-> ResultD TTraitUnsolved)
13091304
)
13101305
++
13111306
(fun res-> RecordMemberConstraintSolution csenv.SolverState m trace traitInfo res))
@@ -1447,7 +1442,7 @@ and SolveRelevantMemberConstraintsForTypar (csenv:ConstraintSolverEnv) ndeep per
14471442
cxs
14481443
|> AtLeastOneD(fun(traitInfo,m2)->
14491444
letcsenv={ csenvwith m= m2}
1450-
SolveMemberConstraint csenvtruepermitWeakResolution(ndeep+1) m2 trace traitInfo)
1445+
SolveMemberConstraint csenv permitWeakResolution(ndeep+1) m2 trace traitInfo)
14511446

14521447
andCanonicalizeRelevantMemberConstraints(csenv:ConstraintSolverEnv)ndeep trace tps=
14531448
SolveRelevantMemberConstraints csenv ndeeptrue trace tps
@@ -1962,22 +1957,18 @@ and CanMemberSigsMatchUpToCheck
19621957
// to allow us to report the outer types involved in the constraint
19631958
andprivateSolveTypSubsumesTypWithReport(csenv:ConstraintSolverEnv)ndeep m trace cxsln ty1 ty2=
19641959
TryD(fun()-> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m trace cxsln ty1 ty2)
1965-
(function
1966-
| LocallyAbortOperationThatFailsToResolveOverload-> CompleteD
1967-
| res->
1968-
match csenv.eContextInfowith
1969-
| ContextInfo.RuntimeTypeTest isOperator->
1970-
// test if we can cast other way around
1960+
(fun res->
1961+
match csenv.eContextInfowith
1962+
| ContextInfo.RuntimeTypeTest isOperator->
1963+
// test if we can cast other way around
19711964
match CollectThenUndo(fun newTrace-> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m(OptionalTrace.WithTrace newTrace) cxsln ty2 ty1)with
19721965
| OkResult_-> ErrorD(ErrorsFromAddingSubsumptionConstraint(csenv.g, csenv.DisplayEnv, ty1, ty2, res, ContextInfo.DowncastUsedInsteadOfUpcast isOperator, m))
19731966
|_-> ErrorD(ErrorsFromAddingSubsumptionConstraint(csenv.g, csenv.DisplayEnv, ty1, ty2, res, ContextInfo.NoContext, m))
19741967
|_-> ErrorD(ErrorsFromAddingSubsumptionConstraint(csenv.g, csenv.DisplayEnv, ty1, ty2, res, csenv.eContextInfo, m)))
19751968

19761969
andprivateSolveTypEqualsTypWithReport(csenv:ConstraintSolverEnv)ndeep m trace cxsln ty1 ty2=
19771970
TryD(fun()-> SolveTypEqualsTypKeepAbbrevsWithCxsln csenv ndeep m trace cxsln ty1 ty2)
1978-
(function
1979-
| LocallyAbortOperationThatFailsToResolveOverload-> CompleteD
1980-
| res-> ErrorD(ErrorFromAddingTypeEquation(csenv.g, csenv.DisplayEnv, ty1, ty2, res, m)))
1971+
(fun res-> ErrorD(ErrorFromAddingTypeEquation(csenv.g, csenv.DisplayEnv, ty1, ty2, res, m)))
19811972

19821973
andArgsMustSubsumeOrConvert
19831974
(csenv:ConstraintSolverEnv)
@@ -2543,7 +2534,7 @@ let AddCxTypeMustSubsumeType contextInfo denv css m trace ty1 ty2 =
25432534
|> RaiseOperationResult
25442535

25452536
letAddCxMethodConstraint denv css m trace traitInfo=
2546-
TryD(fun()-> SolveMemberConstraint(MakeConstraintSolverEnv ContextInfo.NoContext css m denv)truefalse0 m trace traitInfo++(fun _-> CompleteD))
2537+
TryD(fun()-> SolveMemberConstraint(MakeConstraintSolverEnv ContextInfo.NoContext css m denv)false0 m trace traitInfo++(fun _-> CompleteD))
25472538
(fun res-> ErrorD(ErrorFromAddingConstraint(denv, res, m)))
25482539
|> RaiseOperationResult
25492540

@@ -2601,7 +2592,7 @@ let CodegenWitnessThatTypSupportsTraitConstraint tcVal g amap m (traitInfo:Trait
26012592
InfoReader=new InfoReader(g, amap)}
26022593

26032594
letcsenv= MakeConstraintSolverEnv ContextInfo.NoContext css m(DisplayEnv.Empty g)
2604-
SolveMemberConstraint csenvtruetrue0 m NoTrace traitInfo++(fun _res->
2595+
SolveMemberConstraint csenvtrue0 m NoTrace traitInfo++(fun _res->
26052596
letsln=
26062597
match traitInfo.Solutionwith
26072598
| None-> Choice4Of4()
@@ -2725,5 +2716,4 @@ let IsApplicableMethApprox g amap m (minfo:MethInfo) availObjTy =
27252716
|> CommitOperationResult
27262717
|_->true
27272718
else
2728-
true
2729-
2719+
true
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// #Conformance #DeclarationElements #MemberDefinitions #Overloading
2+
// Exotic case from F#+ https://github.com/gusty/FSharpPlus
3+
4+
moduleApplicatives=
5+
openSystem
6+
7+
typeAp= Apwith
8+
static member inlineInvoke(x:'T):'``Applicative<'T>``=
9+
let inlinecall(mthd:^M,output:^R)=((^Mor^R):(static memberReturn:_*_->_) output, mthd)
10+
call(Ap, Unchecked.defaultof<'``Applicative<'T>``>) x
11+
static member inlineInvokeOnInstance(x:'T)=(^``Applicative<'T>``:(static memberReturn:^T->^``Applicative<'T>``) x)
12+
static member inlineReturn(r:'R,_:obj)= Ap.InvokeOnInstance:_-> 'R
13+
static memberReturn(_:seq<'a>,Ap)=fun x-> Seq.singleton x: seq<'a>
14+
static memberReturn(_:Tuple<'a>,Ap)=fun x-> Tuple x: Tuple<'a>
15+
static memberReturn(_:'r->'a,Ap)=fun k _-> k: 'a-> 'r->_
16+
17+
let inlineresult(x:'T)= Ap.Invoke x
18+
19+
let inline(<*>)(f:'``Applicative<'T->'U>``)(x:'``Applicative<'T>``):'``Applicative<'U>``=
20+
((^``Applicative<'T->'U>``or^``Applicative<'T>``or^``Applicative<'U>``):(static member(<*>):_*_-> _)f,x)
21+
22+
let inline(+)(a:'Num)(b:'Num):'Num= a+ b
23+
24+
type ZipList<'s>= ZipListof 's seqwith
25+
static memberReturn(x:'a)= ZipList(Seq.initInfinite(fun _-> x))
26+
static member(<*>)(ZipList(f:seq<'a->'b>),ZipList x)= ZipList(Seq.zip f x|> Seq.map(fun(f,x)-> f x)):ZipList<'b>
27+
28+
type Ii= Ii
29+
type Idiomatic= Idiomaticwith
30+
static member inline($)(Idiomatic,si)=fun sfi x->(Idiomatic $ x)(sfi<*> si)
31+
static member($)(Idiomatic,Ii)= id
32+
let inlineidiomatic a b=(Idiomatic $ b) a
33+
let inlineiI x=(idiomatic<< result) x
34+
35+
letres1n2n3= iI(+)(result0M)(ZipList[1M;2M;3M]) Ii
36+
letres2n3n4= iI(+)(result LanguagePrimitives.GenericOne)(ZipList[1;2;3]) Ii
37+
38+
exit0
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// #Conformance #DeclarationElements #MemberDefinitions #Overloading
2+
// Originally from https://gist.github.com/gusty/b6fac370bff36a665d75
3+
typeFoldArgs<'t>= FoldArgsof('t->'t->'t)
4+
5+
let inlinefoldArgs f(x:'t)(y:'t):'rest=(FoldArgs f $ Unchecked.defaultof<'rest>) x y
6+
7+
typeFoldArgs<'t>with
8+
static member inline($)(FoldArgs f,_:'t->'rest)=fun(a:'t)-> f a>> foldArgs f
9+
static member($)(FoldArgs f,_:'t)= f
10+
11+
lettest1()=
12+
letx:int= foldArgs(+)23
13+
lety:int= foldArgs(+)234
14+
letz:int= foldArgs(+)2345
15+
letd:decimal= foldArgs(+)2M3M4M
16+
lete:string= foldArgs(+)"h""e""l""l""o"
17+
letf:float= foldArgs(+)2.3.4.
18+
19+
letmult3Numbers a b c= a* b* c
20+
letres2= mult3Numbers3(foldArgs(+)34)(foldArgs(+)2233)
21+
()
22+
23+
// Run the test
24+
test1()
25+
26+
exit0

‎tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/OverloadingMembers/SlowOverloadResolution.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Conformance #DeclarationElements #MemberDefinitions #Overloading
22
// https://github.com/Microsoft/visualfsharp/issues/351 - slow overlaod resolution
3-
//<Expectsx x-first x-last">FS0003" status="error">This value is not a function and cannot be applied</Expects>
3+
//<Expectsx x-first x-last">FS0001" status="error">No overloads match</Expects>
44
typeSwitcher= Switcher
55

66
let inlinechecker<^s,^rwhen(^s or ^r):(static member pass:^r->unit)>(s:^s)(r:^r)=()
@@ -22,4 +22,4 @@ let main argv =
2222
letres:unit= format()"text"5"more text"()
2323
printfn"%A" res
2424
System.Console.ReadKey()
25-
0// return an integer exit code
25+
0// return an integer exit code

‎tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/OverloadingMembers/env.lst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ NOMONO,NoMTSOURCE=ConsumeOverloadGenericMethods.fs SCFLAGS="-r:lib.dll" PRECMD=
2727
SOURCE=InferenceForLambdaArgs.fs# InferenceForLambdaArgs.fs
2828

2929
SOURCE=SlowOverloadResolution.fs# SlowOverloadResolution.fs
30+
SOURCE=RecursiveOverload01.fs# RecursiveOverload01.fs
31+
SOURCE=OverloadsAndSRTPs01.fs# OverloadsAndSRTPs01.fs
3032

3133
SOURCE=E_OverloadCurriedFunc.fs# E_OverloadCurriedFunc.fs
3234
SOURCE=NoWarningWhenOverloadingInSubClass01.fs SCFLAGS="--warnaserror"# NoWarningWhenOverloadingInSubClass01.fs

‎vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ type internal FSharpRenameUnusedValueCodeFixProvider
4747

4848
override__.RegisterCodeFixesAsync context:Task=
4949
asyncMaybe{
50+
// Don't show code fixes for unused values, even if they are compiler-generated.
51+
do! Option.guard Settings.CodeFixes.UnusedDeclarations
52+
5053
letdocument= context.Document
5154
let!sourceText= document.GetTextAsync()
5255
letident= sourceText.ToString(context.Span)

‎vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ type internal UnusedDeclarationsAnalyzer() =
100100

101101
override__.AnalyzeSemanticsAsync(document,cancellationToken)=
102102
asyncMaybe{
103+
do! Option.guard Settings.CodeFixes.UnusedDeclarations
104+
103105
do Trace.TraceInformation("{0:n3} (start) UnusedDeclarationsAnalyzer", DateTime.Now.TimeOfDay.TotalSeconds)
104106
do! Async.Sleep DefaultTuning.UnusedDeclarationsAnalyzerInitialDelay|> liftAsync// be less intrusive, give other work priority most of the time
105107
match getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document)with

‎vsintegration/src/FSharp.Editor/Options/EditorOptions.fs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ type QuickInfoOptions =
3434
typeCodeFixesOptions=
3535
{ SimplifyName:bool
3636
AlwaysPlaceOpensAtTopLevel:bool
37-
UnusedOpens:bool}
37+
UnusedOpens:bool
38+
UnusedDeclarations:bool}
3839

3940
[<CLIMutable>]
4041
typeLanguageServicePerformanceOptions=
@@ -59,7 +60,8 @@ type internal Settings [<ImportingConstructor>](store: SettingsStore) =
5960
// See https://github.com/Microsoft/visualfsharp/pull/3238#issue-237699595
6061
SimplifyName=false
6162
AlwaysPlaceOpensAtTopLevel=false
62-
UnusedOpens=true}
63+
UnusedOpens=true
64+
UnusedDeclarations=true}
6365

6466
store.RegisterDefault
6567
{ EnableInMemoryCrossProjectReferences=true

‎vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<StackPanelMargin="15 0 0 0"/>
2727
<CheckBoxx:Name="unusedOpens"IsChecked="{Binding UnusedOpens}"
2828
Content="{x:Static local:Strings.Unused_opens_code_fix}"/>
29+
<CheckBoxx:Name="unusedDeclaration"IsChecked="{Binding UnusedDeclarations}"
30+
Content="{x:Static local:Strings.Unused_declaration_code_fix}"/>
2931
</StackPanel>
3032
</GroupBox>
3133
</StackPanel>

‎vsintegration/src/FSharp.UIResources/Strings.Designer.cs‎

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp