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

Commitd7cd5ab

Browse files
authored
Merge pull requestdotnet#5105 from Microsoft/merges/master-to-dev15.8
Merge master to dev15.8
2 parents8e9b551 +b99f487 commitd7cd5ab

File tree

8 files changed

+53
-23
lines changed

8 files changed

+53
-23
lines changed

‎src/fsharp/PostInferenceChecks.fs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,10 +1543,12 @@ let CheckRecdField isUnion cenv env (tycon:Tycon) (rfield:RecdField) =
15431543
(not isUnion&& IsHiddenRecdField env.sigToImplRemapInfo(tcref.MakeNestedRecdFieldRef rfield))
15441544
letaccess= AdjustAccess isHidden(fun()-> tycon.CompilationPath) rfield.Accessibility
15451545
CheckTypeForAccess cenv env(fun()-> rfield.Name) access m rfield.FormalType
1546-
1546+
15471547
if TyconRefHasAttribute g m g.attrib_IsByRefLikeAttribute tcrefthen
15481548
// Permit Span fields in IsByRefLike types
15491549
CheckTypePermitOuterSpanLike cenv env m rfield.FormalType
1550+
if cenv.reportErrorsthen
1551+
CheckForByrefType cenv env rfield.FormalType(fun()-> errorR(Error(FSComp.SR.chkCantStoreByrefValue(), tycon.Range)))
15501552
else
15511553
CheckTypeNoByrefs cenv env m rfield.FormalType
15521554
if cenv.reportErrorsthen

‎tests/fsharp/typecheck/sigs/neg107.bsl‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ neg107.fsx(53,34,53,38): typecheck error FS3234: Struct members cannot return th
6464
neg107.fsx(67,34,67,40): typecheck error FS3234: Struct members cannotreturn the address of fields of the struct by reference
6565

6666
neg107.fsx(67,34,67,38): typecheck error FS3234: Struct members cannotreturn the address of fields of the struct by reference
67+
68+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This isnot permitted by the rules of Common IL.
69+
70+
neg107.fsx(71,14,71,18): typecheck error FS0437: A type would store a byref typed value. This isnot permitted by Common IL.
71+
72+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This isnot permitted by the rules of Common IL.
73+
74+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This isnot permitted by the rules of Common IL.
75+
76+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This isnot permitted by the rules of Common IL.

‎tests/fsharp/typecheck/sigs/neg107.fsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ namespace Test
6565
val mutablex:TestMut1
6666

6767
memberthis.XAddr=&this.x.x// not allowed, Struct members cannot return the address of fields of the struct by reference", not entirely clear why C# disallowed this
68+
69+
moduleDisallowIsByRefLikeWithByRefField=
70+
[<IsByRefLike;Struct>]
71+
typeBeef(x:byref<int>)=
72+
73+
member__.X=&x
74+

‎tests/fsharp/typecheck/sigs/neg107.vsbsl‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ neg107.fsx(53,34,53,38): typecheck error FS3234: Struct members cannot return th
6464
neg107.fsx(67,34,67,40): typecheck error FS3234: Struct members cannot return the address of fields of the struct by reference
6565

6666
neg107.fsx(67,34,67,38): typecheck error FS3234: Struct members cannot return the address of fields of the struct by reference
67+
68+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This is not permitted by the rules of Common IL.
69+
70+
neg107.fsx(71,14,71,18): typecheck error FS0437: A type would store a byref typed value. This is not permitted by Common IL.
71+
72+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This is not permitted by the rules of Common IL.
73+
74+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This is not permitted by the rules of Common IL.
75+
76+
neg107.fsx(71,19,71,20): typecheck error FS0412: A type instantiation involves a byref type. This is not permitted by the rules of Common IL.

‎vsintegration/src/FSharp.Editor/Formatting/BraceMatchingService.fs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespaceMicrosoft.VisualStudio.FSharp.Editor
44

5-
openSystem
65
openSystem.ComponentModel.Composition
76
openMicrosoft.CodeAnalysis.Editor
87
openMicrosoft.FSharp.Compiler.SourceCodeServices
8+
openSystem.Runtime.InteropServices
99

1010
[<ExportBraceMatcher(FSharpConstants.FSharpLanguageName)>]
1111
typeinternalFSharpBraceMatchingService
@@ -14,19 +14,21 @@ type internal FSharpBraceMatchingService
1414
checkerProvider: FSharpCheckerProvider,
1515
projectInfoManager: FSharpProjectOptionsManager
1616
)=
17-
1817

1918
static letdefaultUserOpName="BraceMatching"
2019

21-
static memberGetBraceMatchingResult(checker:FSharpChecker,sourceText,fileName,parsingOptions:FSharpParsingOptions,position:int,userOpName:string)=
20+
static memberGetBraceMatchingResult(checker:FSharpChecker,sourceText,fileName,parsingOptions:FSharpParsingOptions,position:int,userOpName:string,[<Optional; DefaultParameterValue(false)>]forFormatting:bool)=
2221
async{
2322
let!matchedBraces= checker.MatchBraces(fileName, sourceText.ToString(), parsingOptions, userOpName)
2423
letisPositionInRange range=
2524
match RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, range)with
2625
| None->false
27-
| Some range->
28-
letlength= position- range.Start
29-
length>=0&& length<= range.Length
26+
| Some span->
27+
if forFormattingthen
28+
letlength= position- span.Start
29+
length>=0&& length<= span.Length
30+
else
31+
span.Contains position
3032
return matchedBraces|> Array.tryFind(fun(left,right)-> isPositionInRange left|| isPositionInRange right)
3133
}
3234

‎vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type internal FSharpEditorFormattingService
5050
x.Tag<> FSharpTokenTag.LINE_COMMENT)
5151

5252
let!(left,right)=
53-
FSharpBraceMatchingService.GetBraceMatchingResult(checker, sourceText, filePath, parsingOptions, position,"FormattingService")
53+
FSharpBraceMatchingService.GetBraceMatchingResult(checker, sourceText, filePath, parsingOptions, position,"FormattingService", forFormatting=true)
5454

5555
if right.StartColumn= firstMeaningfulToken.LeftColumnthen
5656
// Replace the indentation on this line with the indentation of the left bracket

‎vsintegration/tests/UnitTests/BraceMatchingServiceTests.fs‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,23 @@ let main argv =
161161
0 // return an integer exit code"""
162162
this.VerifyBraceMatch(code,"(printfn",")endBrace")
163163

164-
[<TestCase("let a1 = [ 0 .. 100 ]",[|9;10;20;21|])>]
165-
[<TestCase("let a2 = [| 0 .. 100 |]",[|9;10;11;21;22;23|])>]
166-
[<TestCase("let a3 = <@ 0 @>",[|9;10;11;14;15;16|])>]
167-
[<TestCase("let a4 = <@@ 0 @@>",[|9;10;11;12;15;15;16;17|])>]
168-
[<TestCase("let a6 = ( () )",[|9;10;16;17|])>]
169-
[<TestCase("[<ReflectedDefinition>]\nlet a7 = 70",[|0;1;2;21;22;23|])>]
170-
[<TestCase("let a8 = seq { yield() }",[|13;14;23;24|])>]
171-
memberthis.BraceMatchingBothSides_Bug2092(fileContents:string,matchingPositions:int[])=
172-
// https://github.com/Microsoft/visualfsharp/issues/2092
164+
[<TestCase("let a1 = [ 0 .. 100 ]",[|9;20|])>]
165+
[<TestCase("let a2 = [| 0 .. 100 |]",[|9;10;22|])>]
166+
[<TestCase("let a3 = <@ 0 @>",[|9;10;15|])>]
167+
[<TestCase("let a4 = <@@ 0 @@>",[|9;10;11;15;16|])>]
168+
[<TestCase("let a6 = ( () )",[|9;16|])>]
169+
[<TestCase("[<ReflectedDefinition>]\nlet a7 = 70",[|0;1;22|])>]
170+
[<TestCase("let a8 = seq { yield() }",[|13;23|])>]
171+
memberthis.DoNotMatchOnInnerSide(fileContents:string,matchingPositions:int[])=
173172
letsourceText= SourceText.From(fileContents)
174-
175173
letparsingOptions,_= checker.GetParsingOptionsFromProjectOptions projectOptions
176-
matchingPositions
177-
|> Array.iter(fun position->
174+
175+
for positionin matchingPositionsdo
178176
match FSharpBraceMatchingService.GetBraceMatchingResult(checker, sourceText, fileName, parsingOptions, position,"UnitTest")|> Async.RunSynchronouslywith
179177
| Some_->()
180178
| None->
181179
match positionwith
182180
|0->""
183181
|_-> fileContents.[position-1]|> sprintf" (previous character '%c')"
184-
|> sprintf"Didn't find a matching brace at position '%d', character '%c'%s" position fileContents.[position]
182+
|> sprintf"Didn't find a matching brace at position '%d'%s" position
185183
|> Assert.Fail
186-
)

‎vsintegration/tests/UnitTests/IndentationServiceTests.fs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ while true do
170170
|> Array.map(fun(lineNumber,expectedIndentation)->
171171
( Some(expectedIndentation), lineNumber, autoIndentTemplate))
172172

173+
[<Test>]
173174
memberthis.TestIndentation()=
174175
for(expectedIndentation, lineNumber, template)in testCasesdo
175176
letsourceText= SourceText.From(template)
@@ -179,7 +180,8 @@ while true do
179180
match expectedIndentationwith
180181
| None-> Assert.IsTrue(actualIndentation.IsNone,"No indentation was expected at line {0}", lineNumber)
181182
| Some indentation-> Assert.AreEqual(expectedIndentation.Value, actualIndentation.Value,"Indentation on line {0} doesn't match", lineNumber)
182-
183+
184+
[<Test>]
183185
memberthis.TestAutoIndentation()=
184186
for(expectedIndentation, lineNumber, template)in autoIndentTestCasesdo
185187

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp