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

Commitb7763a6

Browse files
Revert "remove nameof function form FSharp.Core"
This reverts commita732de0.
1 parentb29fe57 commitb7763a6

File tree

12 files changed

+53
-30
lines changed

12 files changed

+53
-30
lines changed

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,7 @@ Microsoft.FSharp.Core.Operators: System.Object Box[T](T)" +
26322632
Microsoft.FSharp.Core.Operators: System.RuntimeMethodHandle MethodHandleOf[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult])"+
26332633
#endif
26342634
@"
2635+
Microsoft.FSharp.Core.Operators: System.String NameOf[T](T)
26352636
Microsoft.FSharp.Core.Operators: System.String ToString()
26362637
Microsoft.FSharp.Core.Operators: System.String ToString[T](T)
26372638
Microsoft.FSharp.Core.Operators: System.String op_Concatenate(System.String, System.String)

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable259.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,6 +2604,7 @@ Microsoft.FSharp.Core.Operators: System.Object Box[T](T)" +
26042604
Microsoft.FSharp.Core.Operators: System.RuntimeMethodHandle MethodHandleOf[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult])"+
26052605
#endif
26062606
@"
2607+
Microsoft.FSharp.Core.Operators: System.String NameOf[T](T)
26072608
Microsoft.FSharp.Core.Operators: System.String ToString()
26082609
Microsoft.FSharp.Core.Operators: System.String ToString[T](T)
26092610
Microsoft.FSharp.Core.Operators: System.String op_Concatenate(System.String, System.String)

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable47.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,7 @@ Microsoft.FSharp.Core.Operators: System.Object Box[T](T)" +
26062606
Microsoft.FSharp.Core.Operators: System.RuntimeMethodHandle MethodHandleOf[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult])"+
26072607
#endif
26082608
@"
2609+
Microsoft.FSharp.Core.Operators: System.String NameOf[T](T)
26092610
Microsoft.FSharp.Core.Operators: System.String ToString()
26102611
Microsoft.FSharp.Core.Operators: System.String ToString[T](T)
26112612
Microsoft.FSharp.Core.Operators: System.String op_Concatenate(System.String, System.String)

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable7.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,7 @@ Microsoft.FSharp.Core.Operators: System.Object Box[T](T)" +
26172617
Microsoft.FSharp.Core.Operators: System.RuntimeMethodHandle MethodHandleOf[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult])"+
26182618
#endif
26192619
@"
2620+
Microsoft.FSharp.Core.Operators: System.String NameOf[T](T)
26202621
Microsoft.FSharp.Core.Operators: System.String ToString()
26212622
Microsoft.FSharp.Core.Operators: System.String ToString[T](T)
26222623
Microsoft.FSharp.Core.Operators: System.String op_Concatenate(System.String, System.String)

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable78.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,6 +2604,7 @@ Microsoft.FSharp.Core.Operators: System.Object Box[T](T)" +
26042604
Microsoft.FSharp.Core.Operators: System.RuntimeMethodHandle MethodHandleOf[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult])"+
26052605
#endif
26062606
@"
2607+
Microsoft.FSharp.Core.Operators: System.String NameOf[T](T)
26072608
Microsoft.FSharp.Core.Operators: System.String ToString()
26082609
Microsoft.FSharp.Core.Operators: System.String ToString[T](T)
26092610
Microsoft.FSharp.Core.Operators: System.String op_Concatenate(System.String, System.String)

‎src/fsharp/FSharp.Core/prim-types.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4748,6 +4748,9 @@ namespace Microsoft.FSharp.Core
47484748
[<CompiledName("TypeOf")>]
47494749
let inlinetypeof<'T>= BasicInlinedOperations.typeof<'T>
47504750

4751+
[<CompiledName("NameOf")>]
4752+
let inlinenameof(_:'T):string= raise(Exception"may not call directly, should always be optimized away")
4753+
47514754
[<CompiledName("MethodHandleOf")>]
47524755
letmethodhandleof(_call:('T-> 'TResult)):System.RuntimeMethodHandle= raise(Exception"may not call directly, should always be optimized away")
47534756

‎src/fsharp/FSharp.Core/prim-types.fsi‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,10 @@ namespace Microsoft.FSharp.Core
23202320
[<CompiledName("TypeOf")>]
23212321
val inline typeof<'T>:System.Type
23222322

2323+
///<summary>Returns the name of the given symbol.</summary>
2324+
[<CompiledName("NameOf")>]
2325+
val inline nameof: 'T->string
2326+
23232327
///<summary>An internal,library-only compiler intrinsic for compile-time
23242328
///generation of a RuntimeMethodHandle.</summary>
23252329
[<CompiledName("MethodHandleOf")>]

‎src/fsharp/PostInferenceChecks.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ and CheckVal (cenv:cenv) (env:env) v m context =
514514
if isSpliceOperator cenv.g vthen errorR(Error(FSComp.SR.chkNoFirstClassSplicing(), m))
515515
if valRefEq cenv.g v cenv.g.addrof_vrefthen errorR(Error(FSComp.SR.chkNoFirstClassAddressOf(), m))
516516
if valRefEq cenv.g v cenv.g.reraise_vrefthen errorR(Error(FSComp.SR.chkNoFirstClassRethrow(), m))
517+
if valRefEq cenv.g v cenv.g.nameof_vrefthen errorR(Error(FSComp.SR.chkNoFirstClassNameOf(), m))
517518
if noByrefs context&& isByrefLikeTy cenv.g v.Typethen
518519
// byref typed val can only occur in permitting contexts
519520
errorR(Error(FSComp.SR.chkNoByrefAtThisPoint(v.DisplayName), m))

‎src/fsharp/TastOps.fs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,11 @@ let isSizeOfValRef g vref =
28842884
// There is an internal version of typeof defined in prim-types.fs that needs to be detected
28852885
||(g.compilingFslib&& vref.LogicalName="sizeof")
28862886

2887+
letisNameOfValRef g vref=
2888+
valRefEq g vref g.nameof_vref
2889+
// There is an internal version of typeof defined in prim-types.fs that needs to be detected
2890+
||(g.compilingFslib&& vref.LogicalName="nameof")
2891+
28872892
letisTypeDefOfValRef g vref=
28882893
valRefEq g vref g.typedefof_vref
28892894
// There is an internal version of typedefof defined in prim-types.fs that needs to be detected
@@ -2909,6 +2914,11 @@ let (|TypeDefOfExpr|_|) g expr =
29092914
| Expr.App(Expr.Val(vref,_,_),_,[ty],[],_)when isTypeDefOfValRef g vref-> Some ty
29102915
|_-> None
29112916

2917+
let(|NameOfExpr|_|)g expr=
2918+
match exprwith
2919+
| Expr.App(Expr.Val(vref,_,_),_,[ty],[],_)when isNameOfValRef g vref-> Some ty
2920+
|_-> None
2921+
29122922
let(|SeqExpr|_|)g expr=
29132923
match exprwith
29142924
| Expr.App(Expr.Val(vref,_,_),_,_,_,_)when valRefEq g vref g.seq_vref-> Some()
@@ -7743,7 +7753,8 @@ let IsSimpleSyntacticConstantExpr g inputExpr =
77437753
| Expr.Op(TOp.UnionCase_,_,[],_)// Nullary union cases
77447754
| UncheckedDefaultOfExpr g_
77457755
| SizeOfExpr g_
7746-
| TypeOfExpr g_->true
7756+
| TypeOfExpr g_
7757+
| NameOfExpr g_->true
77477758
// All others are not simple constant expressions
77487759
|_->false
77497760

‎src/fsharp/TastOps.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,7 @@ val (|AttribBitwiseOrExpr|_|) : TcGlobals -> Expr -> (Expr * Expr) option
14091409
val(|EnumExpr|_|):TcGlobals->Expr->Expr option
14101410
val(|TypeOfExpr|_|):TcGlobals->Expr->TType option
14111411
val(|TypeDefOfExpr|_|):TcGlobals->Expr->TType option
1412+
val(|NameOfExpr|_|):TcGlobals->Expr->TType option
14121413
val(|SeqExpr|_|):TcGlobals->Expr->unit option
14131414

14141415
valEvalLiteralExprOrAttribArg:TcGlobals->Expr->Expr

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp