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

Commit529cc6f

Browse files
Vasily KirichenkoVasily Kirichenko
Vasily Kirichenko
authored and
Vasily Kirichenko
committed
Apply feedback
1 parent223d313 commit529cc6f

File tree

12 files changed

+30
-27
lines changed

12 files changed

+30
-27
lines changed

‎src/fsharp/Optimizer.fs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,8 +2304,17 @@ and DevirtualizeApplication cenv env (vref:ValRef) ty tyargs args m =
23042304
lettransformedExpr= wrap(MakeApplicationAndBetaReduce cenv.g(exprForValRef m vref,vref.Type,(if isNil tyargsthen[]else[tyargs]),args,m))
23052305
OptimizeExpr cenv env transformedExpr
23062306

2307-
2308-
2307+
2308+
andGetNameFromTypeName tcGlobals m typeName=
2309+
match stripTyEqns tcGlobals typeNamewith
2310+
| TType_app(tcref,_)-> tcref.CompiledRepresentationForNamedType.FullName
2311+
| TType_forall_-> errorR(Error(FSComp.SR.expressionHasNoName(), m));""
2312+
| TType_tuple_-> errorR(Error(FSComp.SR.expressionHasNoName(), m));""
2313+
| TType_fun_-> errorR(Error(FSComp.SR.expressionHasNoName(), m));""
2314+
| TType_ucase_-> errorR(Error(FSComp.SR.expressionHasNoName(), m));""
2315+
| TType_var tp-> tp.DisplayName
2316+
| TType_measure ms-> sprintf"%A" ms
2317+
23092318
andTryDevirtualizeApplication cenv env(f,tyargs,args,m)=
23102319
match f,tyargs,argswith
23112320

@@ -2514,17 +2523,8 @@ and TryDevirtualizeApplication cenv env (f,tyargs,args,m) =
25142523
// Analyze the name of the given type and rewrite AST to constant string expression with the name
25152524
| Expr.Val(vref,_,_),_,_when valRefEq cenv.g vref cenv.g.typenameof_vref->
25162525
match tyargswith
2517-
|(typeName:TType)::_->
2518-
letname=
2519-
match typeNamewith
2520-
| TType_forall(_tps,ty)-> ty.ToString()
2521-
| TType_app(tcref,_)-> tcref.CompiledRepresentationForNamedType.FullName
2522-
| TType_tuple tinst->"("+ String.concat","(List.map string tinst)+")"
2523-
| TType_fun(d,r)->"("+ string d+" ->"+ string r+")"
2524-
| TType_ucase(uc,_)-> uc.CaseName
2525-
| TType_var tp-> tp.DisplayName
2526-
| TType_measure ms-> sprintf"%A" ms
2527-
2526+
| typeName::_->
2527+
letname= GetNameFromTypeName cenv.g m typeName
25282528
Some(Expr.Const(Const.String name, m, cenv.g.string_ty),
25292529
{ TotalSize=1
25302530
FunctionSize=1

‎src/fsharp/PostInferenceChecks.fs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,13 @@ let rec CheckExprNoByrefs (cenv:cenv) (env:env) expr =
511511
lettryExtractNameOf args=
512512
match argswith
513513
|[Expr.App(Expr.Val(r,_,_),_,_,Expr.Const(constant,_,_)::_,_)]->
514-
if r.CompiledName.StartsWith("get_")&& constant= Const.Unitthen// TODO: We need a better way to find static property getters
515-
Some(r.CompiledName.Substring(4))
516-
else
517-
None// the function was applied
514+
match constantwith
515+
| Const.Unit->
516+
if r.CompiledName.StartsWith("get_")then// TODO: We need a better way to find static property getters
517+
Some(r.CompiledName.Substring(4))
518+
else
519+
None// the function was applied
520+
|_-> None
518521
|[Expr.App(Expr.Val(r,_,_),_,_,[],_)]-> Some(r.CompiledName)
519522
|[Expr.App(Expr.Val(r,_,_),_,_,_,_)]->
520523
if r.CompiledName.StartsWith("get_")then// TODO: We need a better way to find member property getters

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof doesn't work on const string
3-
//<Expectsx x-first x-last">FS3197" span="(5,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(5,9)" status="error">This expression does not have a name.</Expects>
44

55
letx= nameof(1+2)
66

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAppliedFunction.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof doesn't work on applied functions
3-
//<Expectsx x-first x-last">FS3197" span="(6,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(6,9)" status="error">This expression does not have a name.</Expects>
44

55
letf()=1
66
letx= nameof(f())

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAsAFunction.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof can't be used as a function.
3-
//<Expectsx x-first x-last">FS3197" span="(5,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(5,9)" status="error">This expression does not have a name.</Expects>
44

55
letf= nameof
66

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfDictLookup.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof doesn't work on dictionary lookup
3-
//<Expectsx x-first x-last">FS3197" span="(6,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(6,9)" status="error">This expression does not have a name.</Expects>
44

55
letdict=new System.Collections.Generic.Dictionary<int,string>()
66
letb= nameof(dict.[2])

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntConst.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof doesn't work on const int
3-
//<Expectsx x-first x-last">FS3197" span="(5,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(5,9)" status="error">This expression does not have a name.</Expects>
44

55
letx= nameof1
66

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntegerAppliedFunction.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof doesn't work on applied functions
3-
//<Expectsx x-first x-last">FS3197" span="(6,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(6,9)" status="error">This expression does not have a name.</Expects>
44

55
letf x=1* x
66
letx= nameof(f2)

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfParameterAppliedFunction.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof doesn't work on applied functions
3-
//<Expectsx x-first x-last">FS3197" span="(7,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(7,9)" status="error">This expression does not have a name.</Expects>
44

55
letf x y= x y
66
letz x=1* x

‎tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfPartiallyAppliedFunction.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #Conformance #DataExpressions
22
// Verify that nameof doesn't work on partially applied functions
3-
//<Expectsx x-first x-last">FS3197" span="(6,9)" status="error">This expression does not have a name.</Expects>
3+
//<Expectsx x-first x-last">FS3199" span="(6,9)" status="error">This expression does not have a name.</Expects>
44

55
letf x y= y* x
66
letx= nameof(f2)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp