Skip to content

Commit a313643

Browse files
authored
Merge pull request #16108 from dotnet/merges/main-to-release/dev17.9
2 parents 09559b0 + 70d93b9 commit a313643

File tree

8 files changed

+137
-20
lines changed

8 files changed

+137
-20
lines changed

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
33
<ProductDependencies>
4-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.23502.1">
4+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.23509.2">
55
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
6-
<Sha>05ffbf9df6c1dc621665ee1864874c4fe6de874c</Sha>
6+
<Sha>8a2f652b1f23d493fcce31b73e829de56df38d5f</Sha>
77
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
88
</Dependency>
99
<Dependency Name="Microsoft.SourceBuild.Intermediate.msbuild" Version="17.7.0-preview-23217-02">

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"sdk": {
3-
"version": "8.0.100-rc.1.23455.8",
3+
"version": "8.0.100-rc.1.23463.5",
44
"allowPrerelease": true
55
},
66
"tools": {
7-
"dotnet": "8.0.100-rc.1.23455.8",
7+
"dotnet": "8.0.100-rc.1.23463.5",
88
"vs": {
99
"version": "17.6",
1010
"components": [

src/Compiler/Checking/CheckComputationExpressions.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ let TcComputationExpression (cenv: cenv) env (overallTy: OverallTy) tpenv (mWhol
229229
// Give bespoke error messages for the FSharp.Core "query" builder
230230
let isQuery =
231231
match stripDebugPoints interpExpr with
232-
| Expr.Val (vref, _, m) ->
232+
// An unparameterized custom builder, e.g., `query`, `async`.
233+
| Expr.Val (vref, _, m)
234+
// A parameterized custom builder, e.g., `builder<…>`, `builder ()`.
235+
| Expr.App (funcExpr = Expr.Val (vref, _, m)) ->
233236
let item = Item.CustomBuilder (vref.DisplayName, vref)
234237
CallNameResolutionSink cenv.tcSink (m, env.NameEnv, item, emptyTyparInst, ItemOccurence.Use, env.eAccessRights)
235238
valRefEq cenv.g vref cenv.g.query_value_vref

src/Compiler/Checking/CheckExpressions.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10788,6 +10788,7 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn
1078810788
let mAttr = synAttr.Range
1078910789
let typath, tyid = List.frontAndBack tycon
1079010790
let tpenv = emptyUnscopedTyparEnv
10791+
let ad = env.eAccessRights
1079110792

1079210793
// if we're checking an attribute that was applied directly to a getter or a setter, then
1079310794
// what we're really checking against is a method, not a property
@@ -10796,13 +10797,12 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn
1079610797
let try1 n =
1079710798
let tyid = mkSynId tyid.idRange n
1079810799
let tycon = (typath @ [tyid])
10799-
let ad = env.eAccessRights
10800+
1080010801
match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInAttribute OpenQualified env.eNameResEnv ad tycon TypeNameResolutionStaticArgsInfo.DefiniteEmpty PermitDirectReferenceToGeneratedType.No with
1080110802
| Exception err -> raze err
10802-
| _ -> success(TcTypeAndRecover cenv NoNewTypars CheckCxs ItemOccurence.UseInAttribute WarnOnIWSAM.Yes env tpenv (SynType.App(SynType.LongIdent(SynLongIdent(tycon, [], List.replicate tycon.Length None)), None, [], [], None, false, mAttr)) )
10803-
ForceRaise ((try1 (tyid.idText + "Attribute")) |> otherwise (fun () -> (try1 tyid.idText)))
10803+
| Result(tinstEnclosing, tcref) -> success(TcTypeApp cenv NoNewTypars CheckCxs ItemOccurence.UseInAttribute env tpenv mAttr tcref tinstEnclosing [])
1080410804

10805-
let ad = env.eAccessRights
10805+
ForceRaise ((try1 (tyid.idText + "Attribute")) |> otherwise (fun () -> (try1 tyid.idText)))
1080610806

1080710807
if not (IsTypeAccessible g cenv.amap mAttr ad ty) then errorR(Error(FSComp.SR.tcTypeIsInaccessible(), mAttr))
1080810808

tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,4 @@ let GetAllUsesOfAllSymbols() =
165165
traceProvider.ForceFlush() |> ignore
166166
traceProvider.Dispose()
167167

168-
Assert.Equal(80, result.Length)
168+
Assert.Equal(79, result.Length)

tests/service/EditorTests.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,6 @@ type Class1() =
781781
su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn))
782782
|> shouldEqual
783783
[|("LiteralAttribute", (3, 10, 3, 17))
784-
("LiteralAttribute", (3, 10, 3, 17))
785784
("member .ctor", (3, 10, 3, 17))
786785
("val ModuleValue", (3, 20, 3, 31))
787786
("val op_Addition", (6, 26, 6, 27))
@@ -793,11 +792,9 @@ type Class1() =
793792
("Class1", (10, 5, 10, 11))
794793
("member .ctor", (10, 5, 10, 11))
795794
("LiteralAttribute", (11, 10, 11, 17))
796-
("LiteralAttribute", (11, 10, 11, 17))
797795
("member .ctor", (11, 10, 11, 17))
798796
("val ClassValue", (11, 20, 11, 30))
799797
("LiteralAttribute", (12, 17, 12, 24))
800-
("LiteralAttribute", (12, 17, 12, 24))
801798
("member .ctor", (12, 17, 12, 24))
802799
("val StaticClassValue", (12, 27, 12, 43))
803800
("val ClassValue", (14, 12, 14, 22))

tests/service/ProjectAnalysisTests.fs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,7 +2349,6 @@ let ``Test Project14 all symbols`` () =
23492349
allUsesOfAllSymbols |> shouldEqual
23502350
[|("StructAttribute", "StructAttribute", "file1", ((4, 2), (4, 8)),
23512351
["attribute"]);
2352-
("StructAttribute", "StructAttribute", "file1", ((4, 2), (4, 8)), ["type"]);
23532352
("member .ctor", "StructAttribute", "file1", ((4, 2), (4, 8)), []);
23542353
("int", "int", "file1", ((5, 9), (5, 12)), ["type"]);
23552354
("int", "int", "file1", ((5, 9), (5, 12)), ["type"]);
@@ -2504,14 +2503,10 @@ let ``Test Project16 all symbols`` () =
25042503
allUsesOfAllSymbols |> shouldEqual
25052504
[|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)),
25062505
["attribute"], ["class"]);
2507-
("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), ["type"],
2508-
["class"]);
25092506
("member .ctor", "ClassAttribute", "sig1", ((8, 6), (8, 11)), [],
25102507
["member"]);
25112508
("ClassAttribute", "ClassAttribute", "sig1", ((12, 6), (12, 11)),
25122509
["attribute"], ["class"]);
2513-
("ClassAttribute", "ClassAttribute", "sig1", ((12, 6), (12, 11)), ["type"],
2514-
["class"]);
25152510
("member .ctor", "ClassAttribute", "sig1", ((12, 6), (12, 11)), [],
25162511
["member"]);
25172512
("int", "int", "sig1", ((16, 19), (16, 22)), ["type"], ["abbrev"]);
@@ -5085,7 +5080,6 @@ let ``Test Project40 all symbols`` () =
50855080
("IsNone", ((4, 33), (4, 41)), ["member"; "prop"; "funky"]);
50865081
("f", ((4, 4), (4, 5)), ["val"]);
50875082
("CompilationRepresentationAttribute", ((6, 2), (6, 27)), ["class"]);
5088-
("CompilationRepresentationAttribute", ((6, 2), (6, 27)), ["class"]);
50895083
("CompilationRepresentationAttribute", ((6, 2), (6, 27)), ["member"]);
50905084
("CompilationRepresentationFlags", ((6, 28), (6, 58)),
50915085
["enum"; "valuetype"]);

tests/service/Symbols.fs

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,4 +951,127 @@ let nestedFunc (a: RecordA<int>) = { a with Zoo.Foo = 1; Zoo.Zoo.Bar = 2; Zoo.Ba
951951
Assert.AreEqual ("RecordA`1", field.DeclaringEntity.Value.CompiledName)
952952
assertRange (4, 87) (4, 90) fieldSymbolUse.Range
953953

954-
| _ -> Assert.Fail "Symbol was not FSharpField"
954+
| _ -> Assert.Fail "Symbol was not FSharpField"
955+
956+
module ComputationExpressions =
957+
[<Test>]
958+
let ``IsFromComputationExpression only returns true for 'builder' in 'builder {}'`` () =
959+
let _, checkResults = getParseAndCheckResults """
960+
type Builder () =
961+
member _.Return x = x
962+
member _.Run x = x
963+
964+
let builder = Builder ()
965+
966+
let x = builder { return 3 }
967+
let y = builder
968+
let z = Builder () { return 3 }
969+
"""
970+
971+
shouldEqual
972+
[
973+
// type Builder () =
974+
(2, 5), false
975+
976+
// … = Builder ()
977+
(6, 14), false
978+
979+
// let builder = …
980+
(6, 4), false
981+
982+
// let x = builder { return 3 }
983+
(8, 8), false // Item.Value _
984+
(8, 8), true // Item.CustomBuilder _
985+
986+
// let y = builder
987+
(9, 8), false
988+
989+
// let z = Builder () { return 3 }
990+
(10, 8), false
991+
]
992+
[
993+
for symbolUse in checkResults.GetAllUsesOfAllSymbolsInFile() do
994+
match symbolUse.Symbol.DisplayName with
995+
| "Builder" | "builder" -> (symbolUse.Range.StartLine, symbolUse.Range.StartColumn), symbolUse.IsFromComputationExpression
996+
| _ -> ()
997+
]
998+
999+
[<Test>]
1000+
let ``IsFromComputationExpression only returns true for 'builder' in 'builder<> {}'`` () =
1001+
let _, checkResults = getParseAndCheckResults """
1002+
type Builder<'T> () =
1003+
member _.Return x = x
1004+
member _.Run x = x
1005+
1006+
let builder<'T> = Builder<'T> ()
1007+
1008+
let x = builder { return 3 }
1009+
let y = builder<int> { return 3 }
1010+
let z = builder<_> { return 3 }
1011+
let p = builder<int>
1012+
let q<'T> = builder<'T>
1013+
"""
1014+
1015+
shouldEqual
1016+
[
1017+
// let builder<'T> = Builder<'T> ()
1018+
(6, 4), false
1019+
1020+
// let x = builder { return 3 }
1021+
(8, 8), false // Item.Value _
1022+
(8, 8), true // Item.CustomBuilder _
1023+
1024+
// let y = builder<int> { return 3 }
1025+
(9, 8), false // Item.Value _
1026+
(9, 8), true // Item.CustomBuilder _
1027+
1028+
// let z = builder<_> { return 3 }
1029+
(10, 8), false // Item.Value _
1030+
(10, 8), true // Item.CustomBuilder _
1031+
1032+
// let p = builder<int>
1033+
(11, 8), false
1034+
1035+
// let q<'T> = builder<'T>
1036+
(12, 12), false
1037+
]
1038+
[
1039+
for symbolUse in checkResults.GetAllUsesOfAllSymbolsInFile() do
1040+
if symbolUse.Symbol.DisplayName = "builder" then
1041+
(symbolUse.Range.StartLine, symbolUse.Range.StartColumn), symbolUse.IsFromComputationExpression
1042+
]
1043+
1044+
[<Test>]
1045+
let ``IsFromComputationExpression only returns true for 'builder' in 'builder () {}'`` () =
1046+
let _, checkResults = getParseAndCheckResults """
1047+
type Builder () =
1048+
member _.Return x = x
1049+
member _.Run x = x
1050+
1051+
let builder () = Builder ()
1052+
1053+
let x = builder () { return 3 }
1054+
let y = builder ()
1055+
let z = builder
1056+
"""
1057+
1058+
shouldEqual
1059+
[
1060+
// let builder () = Builder ()
1061+
(6, 4), false
1062+
1063+
// let x = builder () { return 3 }
1064+
(8, 8), false // Item.Value _
1065+
(8, 8), true // Item.CustomBuilder _
1066+
1067+
// let y = builder ()
1068+
(9, 8), false
1069+
1070+
// let z = builder
1071+
(10, 8), false
1072+
]
1073+
[
1074+
for symbolUse in checkResults.GetAllUsesOfAllSymbolsInFile() do
1075+
if symbolUse.Symbol.DisplayName = "builder" then
1076+
(symbolUse.Range.StartLine, symbolUse.Range.StartColumn), symbolUse.IsFromComputationExpression
1077+
]

0 commit comments

Comments
 (0)