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

Commit5e7517b

Browse files
committed
update code and add more tests
1 parent7cf60a1 commit5e7517b

File tree

9 files changed

+216
-107
lines changed

9 files changed

+216
-107
lines changed

‎src/fsharp/check.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ let CheckEntityDefn cenv env (tycon:Entity) =
12521252
if minfo.NumArgs.Length>1&&
12531253
(minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
12541254
|> List.existsSquared(fun(ParamData(isParamArrayArg,isOutArg,optArgInfo,_,reflArgInfo,ty))->
1255-
isParamArrayArg|| isOutArg|| reflArgInfo.IsSome|| optArgInfo.IsOptional|| isByrefTy cenv.g ty))then
1255+
isParamArrayArg|| isOutArg|| reflArgInfo.AutoQuote|| optArgInfo.IsOptional|| isByrefTy cenv.g ty))then
12561256
errorR(Error(FSComp.SR.chkCurriedMethodsCantHaveOutParams(), m))
12571257

12581258
for pinfoin immediatePropsdo

‎src/fsharp/csolve.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ and CanMemberSigsMatchUpToCheck
18601860
letcalledArgTy= rfinfo.FieldType
18611861
rfinfo.Name, calledArgTy
18621862

1863-
subsumeArg(CalledArg((-1,0),false, NotOptional,false, Some name, None, calledArgTy)) caller)))++(fun()->
1863+
subsumeArg(CalledArg((-1,0),false, NotOptional,false, Some name,ReflectedArgInfo.None, calledArgTy)) caller)))++(fun()->
18641864

18651865
// - Always take the return type into account for
18661866
// -- op_Explicit, op_Implicit

‎src/fsharp/infos.fs‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,11 @@ type OptionalArgInfo =
474474
else
475475
NotOptional
476476

477-
typeReflectedArgInfo= bool option// None, Some(includeValue)
477+
[<RequireQualifiedAccess>]
478+
typeReflectedArgInfo=
479+
| None
480+
| QuoteofevaluateArg:bool
481+
memberx.AutoQuote=match xwith None->false| Quote_->true
478482

479483
//-------------------------------------------------------------------------
480484
// ParamNameAndType, ParamData
@@ -493,7 +497,7 @@ type ParamNameAndType =
493497
/// Full information about a parameter returned for use by the type checker and language service.
494498
typeParamData=
495499
/// ParamData(isParamArray, isOut, optArgInfo, nameOpt, reflArgInfo, ttype)
496-
ParamDataofbool*bool*OptionalArgInfo*stringoption*booloption*TType
500+
ParamDataofbool*bool*OptionalArgInfo*stringoption*ReflectedArgInfo*TType
497501

498502

499503
//-------------------------------------------------------------------------
@@ -1194,13 +1198,16 @@ type MethInfo =
11941198
letisOutArg=(p.IsOut&&not p.IsIn)
11951199
// Note: we get default argument values from VB and other .NET language metadata
11961200
letoptArgInfo= OptionalArgInfo.FromILParameter g amap m ilMethInfo.MetadataScope ilMethInfo.DeclaringTypeInst p
1197-
yield(isParamArrayArg, isOutArg, optArgInfo, None)]]
1201+
yield(isParamArrayArg, isOutArg, optArgInfo,ReflectedArgInfo.None)]]
11981202

11991203
| FSMeth(g,_,vref,_)->
12001204
GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref
12011205
|> List.mapSquared(fun(ty,argInfo)->
12021206
letisParamArrayArg= HasFSharpAttribute g g.attrib_ParamArrayAttribute argInfo.Attribs
1203-
letreflArgInfo= TryFindFSharpBoolAttributeAssumeFalse g g.attrib_ReflectedDefinitionAttribute argInfo.Attribs
1207+
letreflArgInfo=
1208+
match TryFindFSharpBoolAttributeAssumeFalse g g.attrib_ReflectedDefinitionAttribute argInfo.Attribswith
1209+
| Some b-> ReflectedArgInfo.Quote b
1210+
| None-> ReflectedArgInfo.None
12041211
letisOutArg= HasFSharpAttribute g g.attrib_OutAttribute argInfo.Attribs&& isByrefTy g ty
12051212
letisOptArg= HasFSharpAttribute g g.attrib_OptionalArgumentAttribute argInfo.Attribs
12061213
// Note: can't specify caller-side default arguments in F#, by design (default is specified on the callee-side)
@@ -1216,7 +1223,7 @@ type MethInfo =
12161223
[[for pin mi.PApplyArray((fun mi-> mi.GetParameters()),"GetParameters", m)do
12171224
letisParamArrayArg= p.PUntaint((fun px->(px:> IProvidedCustomAttributeProvider).GetAttributeConstructorArgs(p.TypeProvider.PUntaintNoFailure(id), typeof<System.ParamArrayAttribute>.FullName).IsSome),m)
12181225
letoptArgInfo= OptionalArgInfoOfProvidedParameter amap m p
1219-
yield(isParamArrayArg, p.PUntaint((fun p-> p.IsOut), m), optArgInfo, None)]]
1226+
yield(isParamArrayArg, p.PUntaint((fun p-> p.IsOut), m), optArgInfo,ReflectedArgInfo.None)]]
12201227
#endif
12211228

12221229

@@ -1824,7 +1831,7 @@ type PropInfo =
18241831
/// Get the details of the indexer parameters associated with the property
18251832
memberx.GetParamDatas(amap,m)=
18261833
x.GetParamNamesAndTypes(amap,m)
1827-
|> List.map(fun(ParamNameAndType(nmOpt,pty))-> ParamData(false,false, NotOptional, nmOpt, None, pty))
1834+
|> List.map(fun(ParamNameAndType(nmOpt,pty))-> ParamData(false,false, NotOptional, nmOpt,ReflectedArgInfo.None, pty))
18281835

18291836
/// Get the types of the indexer parameters associated with the property
18301837
memberx.GetParamTypes(amap,m)=

‎src/fsharp/tc.fs‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8469,8 +8469,8 @@ and TcMethodApplication
84698469

84708470
let denv = env.DisplayEnv
84718471

8472-
let isSimpleFormalArg (isParamArrayArg, isOutArg, optArgInfo: OptionalArgInfo, reflArgInfo) =
8473-
not isParamArrayArg && not isOutArg && not optArgInfo.IsOptional &&isNone reflArgInfo
8472+
let isSimpleFormalArg (isParamArrayArg, isOutArg, optArgInfo: OptionalArgInfo, reflArgInfo: ReflectedArgInfo) =
8473+
not isParamArrayArg && not isOutArg && not optArgInfo.IsOptional &&not reflArgInfo.AutoQuote
84748474

84758475
let callerObjArgTys = objArgs |> List.map (tyOfExpr cenv.g)
84768476

@@ -8877,17 +8877,21 @@ and TcMethodApplication
88778877
mkCallQuoteToLinqLambdaExpression cenv.g m delegateTy (Expr.Quote(expr, ref None, false, m, mkQuotedExprTy cenv.g delegateTy))
88788878

88798879
// auto conversions to quotations (to match auto conversions to LINQ expressions)
8880-
elif reflArgInfo.IsSome && isQuotedExprTy cenv.g calledArgTy && not (isQuotedExprTy cenv.g callerArgTy) then
8881-
if reflArgInfo.Value then
8880+
elif reflArgInfo.AutoQuote && isQuotedExprTy cenv.g calledArgTy && not (isQuotedExprTy cenv.g callerArgTy) then
8881+
match reflArgInfo with
8882+
| ReflectedArgInfo.Quote true ->
88828883
mkCallLiftValueWithDefn cenv.g m calledArgTy callerArgExpr
8883-
else
8884+
| ReflectedArgInfo.Quote false ->
88848885
Expr.Quote(callerArgExpr, ref None, false, m, calledArgTy)
8886+
| ReflectedArgInfo.None -> failwith "unreachable" // unreachable due to reflArgInfo.AutoQuote condition
88858887

8886-
elif reflArgInfo.IsSome && isRawQuotedExprTy cenv.g calledArgTy && not (isRawQuotedExprTy cenv.g callerArgTy) then
8887-
if reflArgInfo.Value then
8888+
elif reflArgInfo.AutoQuote && isRawQuotedExprTy cenv.g calledArgTy && not (isRawQuotedExprTy cenv.g callerArgTy) then
8889+
match reflArgInfo with
8890+
| ReflectedArgInfo.Quote true ->
88888891
mkCallLiftValueWithDefnRaw cenv.g m calledArgTy callerArgExpr
8889-
else
8892+
| ReflectedArgInfo.Quote false ->
88908893
Expr.Quote(callerArgExpr, ref None, false, m, calledArgTy)
8894+
| ReflectedArgInfo.None -> failwith "unreachable" // unreachable due to reflArgInfo.AutoQuote condition
88918895

88928896

88938897
// Note: out args do not need to be coerced
@@ -9103,7 +9107,7 @@ and TcMethodApplication
91039107
| AssignedPropSetter (pinfo,pminfo,pminst) ->
91049108
MethInfoChecks cenv.g cenv.amap true None [objExpr] ad m pminfo
91059109
let calledArgTy = List.head (List.head (pminfo.GetParamTypes(cenv.amap, m, pminst)))
9106-
let argExpr = coerceExpr false calledArgTy None callerArgTy m argExpr
9110+
let argExpr = coerceExpr false calledArgTyReflectedArgInfo.None callerArgTy m argExpr
91079111
let mut = (if isStructTy cenv.g (tyOfExpr cenv.g objExpr) then DefinitelyMutates else PossiblyMutates)
91089112
let action = BuildPossiblyConditionalMethodCall cenv env mut m true pminfo NormalValUse pminst [objExpr] [argExpr] |> fst
91099113
action, Item.Property (pinfo.PropertyName, [pinfo])
@@ -9112,15 +9116,15 @@ and TcMethodApplication
91129116
// Get or set instance IL field
91139117
ILFieldInstanceChecks cenv.g cenv.amap ad m finfo
91149118
let calledArgTy = finfo.FieldType (cenv.amap, m)
9115-
let argExpr = coerceExpr false calledArgTy None callerArgTy m argExpr
9119+
let argExpr = coerceExpr false calledArgTyReflectedArgInfo.None callerArgTy m argExpr
91169120
let action = BuildILFieldSet cenv.g m objExpr finfo argExpr
91179121
action, Item.ILField finfo
91189122

91199123
| AssignedRecdFieldSetter rfinfo ->
91209124
RecdFieldInstanceChecks cenv.g cenv.amap ad m rfinfo
91219125
let calledArgTy = rfinfo.FieldType
91229126
CheckRecdFieldMutation m denv rfinfo
9123-
let argExpr = coerceExpr false calledArgTy None callerArgTy m argExpr
9127+
let argExpr = coerceExpr false calledArgTyReflectedArgInfo.None callerArgTy m argExpr
91249128
let action = BuildRecdFieldSet cenv.g m objExpr rfinfo argExpr
91259129
action, Item.RecdField rfinfo
91269130

‎src/fsharp/typrelns.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ type CalledArg =
14981498
IsParamArray:bool
14991499
OptArgInfo:OptionalArgInfo
15001500
IsOutArg:bool
1501-
ReflArgInfo:bool option
1501+
ReflArgInfo:ReflectedArgInfo
15021502
NameOpt:string option
15031503
CalledArgumentType:TType}
15041504

@@ -1595,10 +1595,10 @@ let AdjustCalledArgType (infoReader:InfoReader) isConstraint (calledArg: CalledA
15951595
// BUG 435170: called arg is Expr<'t> where 't is not delegate - such conversion is not legal -> return original type
15961596
origArgTy
15971597

1598-
elif calledArg.ReflArgInfo.IsSome&& isQuotedExprTy g calledArgTy&&not(isQuotedExprTy g callerArgTy)then
1598+
elif calledArg.ReflArgInfo.AutoQuote&& isQuotedExprTy g calledArgTy&&not(isQuotedExprTy g callerArgTy)then
15991599
destQuotedExprTy g calledArgTy
16001600

1601-
elif calledArg.ReflArgInfo.IsSome&& isRawQuotedExprTy g calledArgTy&&not(isQuotedExprTy g callerArgTy)&&not(isRawQuotedExprTy g callerArgTy)then
1601+
elif calledArg.ReflArgInfo.AutoQuote&& isRawQuotedExprTy g calledArgTy&&not(isQuotedExprTy g callerArgTy)&&not(isRawQuotedExprTy g callerArgTy)then
16021602
g.obj_ty
16031603

16041604
else calledArgTy

‎src/fsharp/vs/service.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module internal Params =
8585
letinitial= ParamOfRecdField g denv f
8686
if isGenerated i fthen initial
8787
else
88-
{ initialwith Display= NicePrint.stringOfParamData denv(ParamData(false,false, NotOptional, Some initial.Name, None, f.rfield_type))}
88+
{ initialwith Display= NicePrint.stringOfParamData denv(ParamData(false,false, NotOptional, Some initial.Name,ReflectedArgInfo.None, f.rfield_type))}
8989

9090
letParamOfParamData g denv(ParamData(_isParamArrayArg,_isOutArg,_optArgInfo,nmOpt,_reflArgInfo,pty)as paramData)=
9191
{ Name=match nmOptwith None->""| Some pn-> pn
@@ -178,7 +178,7 @@ module internal Params =
178178
letparamDatas=
179179
argInfo
180180
|> List.map ParamNameAndType.FromArgInfo
181-
|> List.map(fun(ParamNameAndType(nmOpt,pty))-> ParamData(false,false, NotOptional, nmOpt, None, pty))
181+
|> List.map(fun(ParamNameAndType(nmOpt,pty))-> ParamData(false,false, NotOptional, nmOpt,ReflectedArgInfo.None, pty))
182182
ParamsOfParamDatas g denv paramDatas returnTy
183183
| Item.UnionCase(ucr)->
184184
match ucr.UnionCase.RecdFieldswith
@@ -208,7 +208,7 @@ module internal Params =
208208
| None->
209209
letargNamesAndTys= ItemDescriptionsImpl.ParamNameAndTypesOfUnaryCustomOperation g minfo
210210
let_,argTys,_= PrettyTypes.PrettifyTypesN g(argNamesAndTys|> List.map(fun(ParamNameAndType(_,ty))-> ty))
211-
letparamDatas=(argNamesAndTys, argTys)||> List.map2(fun(ParamNameAndType(nmOpt,_))argTy-> ParamData(false,false, NotOptional, nmOpt, None,argTy))
211+
letparamDatas=(argNamesAndTys, argTys)||> List.map2(fun(ParamNameAndType(nmOpt,_))argTy-> ParamData(false,false, NotOptional, nmOpt,ReflectedArgInfo.None,argTy))
212212
letrty= minfo.GetFSharpReturnTy(amap, m, minfo.FormalMethodInst)
213213
ParamsOfParamDatas g denv paramDatas rty
214214
| Some_->
@@ -217,7 +217,7 @@ module internal Params =
217217
| Item.FakeInterfaceCtor_->[]
218218
| Item.DelegateCtor delty->
219219
let(SigOfFunctionForDelegate(_,_,_,fty))= GetSigOfFunctionForDelegate infoReader delty m AccessibleFromSomeFSharpCode
220-
ParamsOfParamDatas g denv[ParamData(false,false, NotOptional, None, None, fty)] delty
220+
ParamsOfParamDatas g denv[ParamData(false,false, NotOptional, None,ReflectedArgInfo.None, fty)] delty
221221
#if EXTENSIONTYPING
222222
| ItemIsTypeWithStaticArguments g tyconRef->
223223
// similar code to TcProvidedTypeAppToStaticConstantArgs

‎tests/fsharp/core/quotes/build.bat‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ rem fsc.exe building
2222
"%PEVERIFY%" test.exe
2323
@if ERRORLEVEL1goto Error
2424

25+
"%FSC%"%fsc_flags% -o:test-with-debug-data.exe --quotations-debug+ -r cslib.dll -g test.fsx
26+
@if ERRORLEVEL1goto Error
27+
28+
"%PEVERIFY%" test-with-debug-data.exe
29+
@if ERRORLEVEL1goto Error
30+
31+
2532
"%FSC%"%fsc_flags% --optimize -o:test--optimize.exe -r cslib.dll -g test.fsx
2633
@if ERRORLEVEL1goto Error
2734

‎tests/fsharp/core/quotes/run.bat‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ echo TestD
2525
@if ERRORLEVEL1goto Error
2626
ifNOTEXIST test.okgoto SetError
2727

28+
ifexist test.ok (del /f /q test.ok)
29+
%CLIX% test-with-debug-data.exe
30+
@if ERRORLEVEL1goto Error
31+
ifNOTEXIST test.okgoto SetError
32+
2833
ifexist test.ok (del /f /q test.ok)
2934
%CLIX% test--optimize.exe
3035
@if ERRORLEVEL1goto Error

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp