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

Commitad40975

Browse files
committed
tryDestFunTy
1 parent59fa5df commitad40975

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

‎src/fsharp/TastOps.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ let isAppTy g ty = ty |> stripTyEqns g |> (function TType_app _ -> true | _ ->
716716
letdestAppTy g ty= ty|> stripTyEqns g|>(function TType_app(tcref,tinst)-> tcref,tinst|_-> failwith"destAppTy")
717717
lettcrefOfAppTy g ty= ty|> stripTyEqns g|>(function TType_app(tcref,_)-> tcref|_-> failwith"tcrefOfAppTy")
718718
lettryDestTyparTy g ty= ty|> stripTyEqns g|>(function TType_var v-> Some v|_-> None)
719+
lettryDestFunTy g ty= ty|> stripTyEqns g|>(function TType_fun(tyv,tau)-> Some(tyv,tau)|_-> None)
719720
lettryDestAppTy g ty= ty|> stripTyEqns g|>(function TType_app(tcref,_)-> Some tcref|_-> None)
720721
lettryAnyParTy g ty= ty|> stripTyEqns g|>(function TType_var v-> Some v| TType_measure untwhen isUnitParMeasure g unt-> Some(destUnitParMeasure g unt)|_-> None)
721722
let(|AppTy|_|)g ty= ty|> stripTyEqns g|>(function TType_app(tcref,tinst)-> Some(tcref,tinst)|_-> None)

‎src/fsharp/TastOps.fsi‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,20 +395,20 @@ val recdFieldTysOfExnDefRef : TyconRef -> TType list
395395
// inference equations, i.e. are"stripped"
396396
//-------------------------------------------------------------------------
397397

398-
val destForallTy: TcGlobals-> TType-> Typars* TType
399-
val destFunTy: TcGlobals-> TType-> TType* TType
398+
val destForallTy: TcGlobals-> TType-> Typars* TType
399+
val destFunTy: TcGlobals-> TType-> TType* TType
400400
val destAnyTupleTy: TcGlobals-> TType-> TupInfo* TTypes
401401
val destRefTupleTy: TcGlobals-> TType-> TTypes
402-
val destStructTupleTy: TcGlobals-> TType-> TTypes
403-
val destTyparTy: TcGlobals-> TType-> Typar
404-
val destAnyParTy: TcGlobals-> TType-> Typar
405-
val destMeasureTy: TcGlobals-> TType-> Measure
406-
val tryDestForallTy: TcGlobals-> TType-> Typars* TType
402+
val destStructTupleTy: TcGlobals-> TType-> TTypes
403+
val destTyparTy: TcGlobals-> TType-> Typar
404+
val destAnyParTy: TcGlobals-> TType-> Typar
405+
val destMeasureTy: TcGlobals-> TType-> Measure
406+
val tryDestForallTy: TcGlobals-> TType-> Typars* TType
407407

408408
val isFunTy: TcGlobals-> TType-> bool
409409
val isForallTy: TcGlobals-> TType-> bool
410-
val isAnyTupleTy: TcGlobals-> TType-> bool
411-
val isRefTupleTy: TcGlobals-> TType-> bool
410+
val isAnyTupleTy: TcGlobals-> TType-> bool
411+
val isRefTupleTy: TcGlobals-> TType-> bool
412412
val isStructTupleTy: TcGlobals-> TType-> bool
413413
val isUnionTy: TcGlobals-> TType-> bool
414414
val isReprHiddenTy: TcGlobals-> TType-> bool
@@ -430,6 +430,7 @@ val tcrefOfAppTy : TcGlobals -> TType -> TyconRef
430430
val tyconOfAppTy: TcGlobals-> TType-> Tycon
431431
val tryDestAppTy: TcGlobals-> TType-> TyconRef option
432432
val tryDestTyparTy: TcGlobals-> TType-> Typar option
433+
val tryDestFunTy: TcGlobals-> TType->(TType* TType) option
433434
val argsOfAppTy: TcGlobals-> TType-> TypeInst
434435
val mkInstForAppTy: TcGlobals-> TType-> TyparInst
435436

‎src/fsharp/TypeChecker.fs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -729,13 +729,15 @@ let UnifyStructTupleType contextInfo cenv denv m ty ps =
729729
/// Optimized unification routine that avoids creating new inference
730730
/// variables unnecessarily
731731
let UnifyFunctionTypeUndoIfFailed cenv denv m ty =
732-
if isFunTy cenv.g ty then Some(destFunTy cenv.g ty) else
733-
let domainTy = NewInferenceType ()
734-
let resultTy = NewInferenceType ()
735-
if AddCxTypeEqualsTypeUndoIfFailed denv cenv.css m ty (domainTy --> resultTy) then
736-
Some(domainTy,resultTy)
737-
else
738-
None
732+
match tryDestFunTy cenv.g ty with
733+
| None ->
734+
let domainTy = NewInferenceType ()
735+
let resultTy = NewInferenceType ()
736+
if AddCxTypeEqualsTypeUndoIfFailed denv cenv.css m ty (domainTy --> resultTy) then
737+
Some(domainTy,resultTy)
738+
else
739+
None
740+
| r -> r
739741

740742
/// Optimized unification routine that avoids creating new inference
741743
/// variables unnecessarily

‎src/fsharp/vs/service.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ module internal Params =
248248
| Item.Value vref->
249249
letgetParamsOfTypes()=
250250
let_,tau= vref.TypeScheme
251-
if isFunTy denv.g tauthen
252-
letarg,rtau= destFunTy denv.g tau
251+
match tryDestFunTy denv.g tauwith
252+
| Some(arg,rtau)->
253253
letargs= tryDestRefTupleTy denv.g arg
254254
ParamsOfTypes g denv args rtau
255-
else[]
255+
| None->[]
256256
match vref.ValReprInfowith
257257
| None->
258258
// ValReprInfo = None i.e. in let bindings defined in types or in local functions

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp