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

Commit3bdd481

Browse files
dotnet-botKevinRansom
authored andcommitted
Merge master to dev15.7 (dotnet#4475)
* One lookup in nenv.eFieldLabels should be enough (dotnet#4469)* Shortcut NameResolution searches (dotnet#4444)* No need to decompile coreDisplayName all the time (dotnet#4443)
1 parent5276ece commit3bdd481

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

‎src/fsharp/NameResolution.fs‎

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv:NameResolver) fullyQualified war
26882688
letmoduleSearch ad=
26892689
ResolveLongIndentAsModuleOrNamespaceThen sink ResultCollectionSettings.AtMostOneResult ncenv.amap m fullyQualified nenv ad lidfalse
26902690
(ResolvePatternLongIdentInModuleOrNamespace ncenv nenv numTyArgsOpt ad)
2691+
26912692
lettyconSearch ad=
26922693
match lidwith
26932694
| tn:: restwhennot(isNil rest)->
@@ -2697,15 +2698,33 @@ let rec ResolvePatternLongIdentPrim sink (ncenv:NameResolver) fullyQualified war
26972698
ResolveLongIdentInTyconRefs ResultCollectionSettings.AtMostOneResult ncenv nenv LookupKind.Pattern1 tn.idRange ad rest numTyArgsOpt tn.idRange tcrefs
26982699
|_->
26992700
NoResultsOrUsefulErrors
2700-
letresInfo,res,rest=
2701-
match AtMostOneResult m(tyconSearch ad+++ moduleSearch ad)with
2701+
2702+
letresInfo,res,rest=
2703+
lettyconResult= tyconSearch ad
2704+
match tyconResultwith
2705+
| Result(res::_)-> res
2706+
|_->
2707+
2708+
letmoduleResult= moduleSearch ad
2709+
match moduleResultwith
2710+
| Result(res::_)-> res
2711+
|_->
2712+
2713+
match AtMostOneResult m(tyconResult+++ moduleResult)with
27022714
| Result_as res-> ForceRaise res
2703-
|_->
2704-
ForceRaise(AtMostOneResult m(tyconSearch AccessibleFromSomeFSharpCode+++ moduleSearch AccessibleFromSomeFSharpCode))
2715+
|_->
2716+
2717+
lettyconResult= tyconSearch AccessibleFromSomeFSharpCode
2718+
match tyconResultwith
2719+
| Result(res::_)-> res
2720+
|_->
2721+
ForceRaise(AtMostOneResult m(tyconResult+++ moduleSearch AccessibleFromSomeFSharpCode))
2722+
27052723
ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun()->true))
27062724

2707-
ifnot(isNil rest)then error(Error(FSComp.SR.nrIsNotConstructorOrLiteral(),(List.head rest).idRange))
2708-
res
2725+
match restwith
2726+
|[]-> res
2727+
| element::_-> error(Error(FSComp.SR.nrIsNotConstructorOrLiteral(),element.idRange))
27092728

27102729

27112730
/// Resolve a long identifier when used in a pattern.
@@ -3169,16 +3188,16 @@ let private ResolveExprDotLongIdent (ncenv:NameResolver) m ad nenv typ lid findF
31693188
if isAppTy ncenv.g typthen
31703189
NoResultsOrUsefulErrors
31713190
else
3172-
match lidwith
3191+
match lidwith
31733192
// A unique record label access, e.g expr.field
3174-
| id::restwhen nenv.eFieldLabels.ContainsKey(id.idText)->
3175-
match nenv.eFieldLabels.[id.idText]with
3176-
|[]-> NoResultsOrUsefulErrors
3177-
| rfref::_->
3193+
| id::rest->
3194+
match Map.tryFind id.idText nenv.eFieldLabelswith
3195+
| Some(rfref::_)->
31783196
// NOTE (instantiationGenerator cleanup): we need to freshen here because we don't know the type.
31793197
// But perhaps the caller should freshen??
31803198
letitem= FreshenRecdFieldRef ncenv m rfref
31813199
OneSuccess(ResolutionInfo.Empty,item,rest)
3200+
|_-> NoResultsOrUsefulErrors
31823201
|_-> NoResultsOrUsefulErrors
31833202

31843203
letsearch= dotFieldIdSearch

‎src/fsharp/TypeChecker.fs‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,32 +1405,34 @@ let ComputeAccessAndCompPath env declKindOpt m vis overrideVis actualParent =
14051405
let cpath = if accessModPermitted then Some env.eCompPath else None
14061406
vis, cpath
14071407

1408-
let CheckForAbnormalOperatorNames cenv (idRange:range)opName isMember =
1409-
if (idRange.EndColumn - idRange.StartColumn <= 5) &&
1410-
not cenv.g.compilingFslib
1408+
let CheckForAbnormalOperatorNames cenv (idRange:range)coreDisplayName (memberInfoOpt: ValMemberInfo option) =
1409+
if (idRange.EndColumn - idRange.StartColumn <= 5) &&
1410+
not cenv.g.compilingFslib
14111411
then
1412-
match opName with
1412+
let opName = DecompileOpName coreDisplayName
1413+
let isMember = memberInfoOpt.IsSome
1414+
match opName with
14131415
| PrettyNaming.Relational ->
14141416
if isMember then
1415-
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMethodNameForRelationalOperator(opName,(CompileOpName opName)), idRange))
1417+
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMethodNameForRelationalOperator(opName,coreDisplayName), idRange))
14161418
else
1417-
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidOperatorDefinitionRelational(opName), idRange))
1419+
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidOperatorDefinitionRelationalopName, idRange))
14181420
| PrettyNaming.Equality ->
14191421
if isMember then
1420-
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMethodNameForEquality(opName,(CompileOpName opName)), idRange))
1422+
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMethodNameForEquality(opName,coreDisplayName), idRange))
14211423
else
1422-
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidOperatorDefinitionEquality(opName), idRange))
1424+
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidOperatorDefinitionEqualityopName, idRange))
14231425
| PrettyNaming.Control ->
14241426
if isMember then
1425-
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMemberName(opName,(CompileOpName opName)), idRange))
1427+
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMemberName(opName,coreDisplayName), idRange))
14261428
else
1427-
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidOperatorDefinition(opName), idRange))
1429+
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidOperatorDefinitionopName, idRange))
14281430
| PrettyNaming.Indexer ->
14291431
if not isMember then
1430-
error(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidIndexOperatorDefinition(opName), idRange))
1432+
error(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidIndexOperatorDefinitionopName, idRange))
14311433
| PrettyNaming.FixedTypes ->
14321434
if isMember then
1433-
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMemberNameFixedTypes(opName), idRange))
1435+
warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMemberNameFixedTypesopName, idRange))
14341436
| PrettyNaming.Other -> ()
14351437

14361438
let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValScheme(id, typeScheme, topValData, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, compgen, isIncrClass, isTyFunc, hasDeclaredTypars)), attrs, doc, konst, isGeneratedEventVal) =
@@ -1537,7 +1539,7 @@ let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValSche
15371539
(hasDeclaredTypars || inSig), isGeneratedEventVal, konst, actualParent)
15381540

15391541

1540-
CheckForAbnormalOperatorNames cenv id.idRange(DecompileOpNamevspec.CoreDisplayName) (Option.isSomememberInfoOpt)
1542+
CheckForAbnormalOperatorNames cenv id.idRange vspec.CoreDisplayNamememberInfoOpt
15411543

15421544
PublishValueDefn cenv env declKind vspec
15431545

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp