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

Commit10a15ab

Browse files
committed
Merge remote-tracking branch 'upstream/dev15.9' into merges/dev15.9-to-dev16.0
2 parents87640b9 +04f3a36 commit10a15ab

File tree

52 files changed

+989
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+989
-147
lines changed

‎src/buildfromsource/FSharp.Compiler.Private/FSComp.fs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4360,6 +4360,18 @@ type internal SR private() =
43604360
/// Byref types are not allowed to have optional type extensions.
43614361
/// (Originally from ..\FSComp.txt:1444)
43624362
static membertcByrefsMayNotHaveTypeExtensions()=(3239, GetStringFunc("tcByrefsMayNotHaveTypeExtensions",",,,"))
4363+
/// Cannot call the byref extension method '%s. The first parameter requires the value to be mutable or a non-readonly byref type.
4364+
/// (Originally from ..\FSComp.txt:1445)
4365+
static membertcCannotCallExtensionMethodInrefToByref(a0:System.String)=(3240, GetStringFunc("tcCannotCallExtensionMethodInrefToByref",",,,%s,,,") a0)
4366+
/// Cannot partially apply the extension method '%s' because the first parameter is a byref type.
4367+
/// (Originally from ..\FSComp.txt:1446)
4368+
static membertcCannotPartiallyApplyExtensionMethodForByref(a0:System.String)=(3241, GetStringFunc("tcCannotPartiallyApplyExtensionMethodForByref",",,,%s,,,") a0)
4369+
/// The parameter '%s' has an invalid type '%s'. This is not permitted by the rules of Common IL.
4370+
/// (Originally from ..\FSComp.txt:1447)
4371+
static memberchkInvalidFunctionParameterType(a0:System.String,a1:System.String)=(3300, GetStringFunc("chkInvalidFunctionParameterType",",,,%s,,,%s,,,") a0 a1)
4372+
/// The function or method has an invalid return type '%s'. This is not permitted by the rules of Common IL.
4373+
/// (Originally from ..\FSComp.txt:1448)
4374+
static memberchkInvalidFunctionReturnType(a0:System.String)=(3301, GetStringFunc("chkInvalidFunctionReturnType",",,,%s,,,") a0)
43634375

43644376
/// Call this method once to validate that all known resources are valid; throws if not
43654377
static memberRunStartupValidation()=
@@ -5778,4 +5790,8 @@ type internal SR private() =
57785790
ignore(GetString("tastCantTakeAddressOfExpression"))
57795791
ignore(GetString("tcCannotCallExtensionMemberInrefToByref"))
57805792
ignore(GetString("tcByrefsMayNotHaveTypeExtensions"))
5793+
ignore(GetString("tcCannotCallExtensionMethodInrefToByref"))
5794+
ignore(GetString("tcCannotPartiallyApplyExtensionMethodForByref"))
5795+
ignore(GetString("chkInvalidFunctionParameterType"))
5796+
ignore(GetString("chkInvalidFunctionReturnType"))
57815797
()

‎src/buildfromsource/FSharp.Compiler.Private/FSComp.resx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,4 +4363,16 @@
43634363
<dataname="tcByrefsMayNotHaveTypeExtensions"xml:space="preserve">
43644364
<value>Byref types are not allowed to have optional type extensions.</value>
43654365
</data>
4366+
<dataname="tcCannotCallExtensionMethodInrefToByref"xml:space="preserve">
4367+
<value>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</value>
4368+
</data>
4369+
<dataname="tcCannotPartiallyApplyExtensionMethodForByref"xml:space="preserve">
4370+
<value>Cannot partially apply the extension method '{0}' because the first parameter is a byref type.</value>
4371+
</data>
4372+
<dataname="chkInvalidFunctionParameterType"xml:space="preserve">
4373+
<value>The parameter '{0}' has an invalid type '{1}'. This is not permitted by the rules of Common IL.</value>
4374+
</data>
4375+
<dataname="chkInvalidFunctionReturnType"xml:space="preserve">
4376+
<value>The function or method has an invalid return type '{0}'. This is not permitted by the rules of Common IL.</value>
4377+
</data>
43664378
</root>

‎src/fsharp/ConstraintSolver.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,7 @@ let IsApplicableMethApprox g amap m (minfo:MethInfo) availObjTy =
27692769
letminst= FreshenMethInfo m minfo
27702770
match minfo.GetObjArgTypes(amap, m, minst)with
27712771
|[reqdObjTy]->
2772+
letreqdObjTy=if isByrefTy g reqdObjTythen destByrefTy g reqdObjTyelse reqdObjTy// This is to support byref extension methods.
27722773
TryD(fun()-> SolveTypeSubsumesType csenv0 m NoTrace None reqdObjTy availObjTy++(fun()-> ResultDtrue))
27732774
(fun _err-> ResultDfalse)
27742775
|> CommitOperationResult

‎src/fsharp/FSComp.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,3 +1442,7 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
14421442
3237,tastCantTakeAddressOfExpression,"Cannot take the address of the value returned from the expression. Assign the returned value to a let-bound value before taking the address."
14431443
3238,tcCannotCallExtensionMemberInrefToByref,"Cannot call the extension member as it requires the value to be mutable or a byref type due to the extending type being used as a byref."
14441444
3239,tcByrefsMayNotHaveTypeExtensions,"Byref types are not allowed to have optional type extensions."
1445+
3240,tcCannotCallExtensionMethodInrefToByref,"Cannot call the byref extension method '%s. The first parameter requires the value to be mutable or a non-readonly byref type."
1446+
3241,tcCannotPartiallyApplyExtensionMethodForByref,"Cannot partially apply the extension method '%s' because the first parameter is a byref type."
1447+
3300,chkInvalidFunctionParameterType,"The parameter '%s' has an invalid type '%s'. This is not permitted by the rules of Common IL."
1448+
3301,chkInvalidFunctionReturnType,"The function or method has an invalid return type '%s'. This is not permitted by the rules of Common IL."

‎src/fsharp/MethodCalls.fs‎

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -598,28 +598,12 @@ let TakeObjAddrForMethodCall g amap (minfo:MethInfo) isMutable m objArgs f =
598598
// Check to see if the extension member uses the extending type as a byref.
599599
// If so, make sure we don't allow readonly/immutable values to be passed byref from an extension member.
600600
// An inref will work though.
601-
if mustTakeAddress&& isReadOnly&& minfo.IsExtensionMemberthen
602-
lettyOpt=
603-
match minfowith
604-
// For F# defined methods.
605-
| FSMeth(_,_, vref,_)->
606-
letty,_= destFunTy g vref.Type
607-
Some(ty)
608-
609-
// For IL methods, defined outside of F#.
610-
| ILMeth(_, info,_)->
611-
letparamTypes= info.GetRawArgTypes(amap, m, minfo.FormalMethodInst)
612-
match paramTypeswith
613-
|[]-> failwith"impossible"
614-
| ty::_-> Some(ty)
615-
616-
|_-> None
617-
618-
match tyOptwith
619-
| Some(ty)->
620-
if isByrefTy g ty&&not(isInByrefTy g ty)then
621-
errorR(Error(FSComp.SR.tcCannotCallExtensionMemberInrefToByref(), m))
622-
|_->()
601+
if isReadOnly&& mustTakeAddress&& minfo.IsExtensionMemberthen
602+
minfo.TryObjArgByrefType(amap, m, minfo.FormalMethodInst)
603+
|> Option.iter(fun ty->
604+
ifnot(isInByrefTy g ty)then
605+
errorR(Error(FSComp.SR.tcCannotCallExtensionMethodInrefToByref(minfo.DisplayName), m)))
606+
623607

624608
wrap,[objArgExpr']
625609

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp