Skip to content

Commit 27efc28

Browse files
dotnet-botedgarfgpT-Grobrianrourkebollpsfinaki
authored
Merge main to release/dev17.11 (#17064)
* Disallow calling abstract methods directly on interfaces (#17021) * Disallow calling abstract methods directly on interfaces * More tests * IWSAMs are not supported by NET472 * Update src/Compiler/Checking/ConstraintSolver.fs Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com> * fix typos * looking for the right check * Add comments * move release notes * Add a new error number and message * Update docs/release-notes/.FSharp.Compiler.Service/8.0.400.md Co-authored-by: Brian Rourke Boll <brianrourkeboll@users.noreply.github.com> * Update docs/release-notes/.FSharp.Compiler.Service/8.0.400.md Co-authored-by: Brian Rourke Boll <brianrourkeboll@users.noreply.github.com> * Improve error message --------- Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com> Co-authored-by: Brian Rourke Boll <brianrourkeboll@users.noreply.github.com> * Always use `typeEquivAux EraseMeasures` (for integral range optimizations) (#17048) * Always use `typeEquivAux EraseMeasures` * Update release notes * Update baselines --------- Co-authored-by: Petr <psfinaki@users.noreply.github.com> * Error message that explicitly disallowed static abstract members in classes. (#17055) * WIP * Error message that explicitly disallowed static abstract methods in abstract classes * release notes * SynTypeDefnKind.Class * Fix #16761 (#17047) * Fix #16761 * Fully async version + ignore cancellation on external navigation * Automated command ran: fantomas Co-authored-by: vzarytovskii <1260985+vzarytovskii@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Edgar Gonzalez <edgar.gonzalez@fundourselves.com> Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com> Co-authored-by: Brian Rourke Boll <brianrourkeboll@users.noreply.github.com> Co-authored-by: Petr <psfinaki@users.noreply.github.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
1 parent 6b6bbf0 commit 27efc28

File tree

19 files changed

+198
-25
lines changed

19 files changed

+198
-25
lines changed

docs/release-notes/.FSharp.Compiler.Service/8.0.400.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Fixed
22

3+
* Static abstract method on classes no longer yields internal error. ([Issue #17044](https://github.com/dotnet/fsharp/issues/17044), [PR #17055](https://github.com/dotnet/fsharp/pull/17055))
34
* Disallow calling abstract methods directly on interfaces. ([Issue #14012](https://github.com/dotnet/fsharp/issues/14012), [Issue #16299](https://github.com/dotnet/fsharp/issues/16299), [PR #17021](https://github.com/dotnet/fsharp/pull/17021))
45
* Various parenthesization API fixes. ([PR #16977](https://github.com/dotnet/fsharp/pull/16977))
56
* Fix bug in optimization of for-loops over integral ranges with steps and units of measure. ([Issue #17025](https://github.com/dotnet/fsharp/issues/17025), [PR #17040](https://github.com/dotnet/fsharp/pull/17040), [PR #17048](https://github.com/dotnet/fsharp/pull/17048))

src/Compiler/Checking/CheckDeclarations.fs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3608,6 +3608,20 @@ module EstablishTypeDefinitionCores =
36083608
elif not (isClassTy g ty) then
36093609
errorR(Error(FSComp.SR.tcCannotInheritFromInterfaceType(), m)))
36103610

3611+
let abstractSlots =
3612+
[ for synValSig, memberFlags in slotsigs do
3613+
3614+
let (SynValSig(range=m)) = synValSig
3615+
3616+
CheckMemberFlags None NewSlotsOK OverridesOK memberFlags m
3617+
3618+
let slots = fst (TcAndPublishValSpec (cenv, envinner, containerInfo, ModuleOrMemberBinding, Some memberFlags, tpenv, synValSig))
3619+
// Multiple slots may be returned, e.g. for
3620+
// abstract P: int with get, set
3621+
3622+
for slot in slots do
3623+
yield mkLocalValRef slot ]
3624+
36113625
let kind =
36123626
match kind with
36133627
| SynTypeDefnKind.Struct ->
@@ -3632,6 +3646,9 @@ module EstablishTypeDefinitionCores =
36323646
noCLIMutableAttributeCheck()
36333647
structLayoutAttributeCheck(not isIncrClass)
36343648
allowNullLiteralAttributeCheck()
3649+
for slot in abstractSlots do
3650+
if not slot.IsInstanceMember then
3651+
errorR(Error(FSComp.SR.chkStaticAbstractMembersOnClasses(), slot.Range))
36353652
TFSharpClass
36363653
| SynTypeDefnKind.Delegate (ty, arity) ->
36373654
noCLIMutableAttributeCheck()
@@ -3666,21 +3683,7 @@ module EstablishTypeDefinitionCores =
36663683
| (_, m, baseIdOpt) :: _ ->
36673684
match baseIdOpt with
36683685
| None -> Some(ident("base", m))
3669-
| Some id -> Some id
3670-
3671-
let abstractSlots =
3672-
[ for synValSig, memberFlags in slotsigs do
3673-
3674-
let (SynValSig(range=m)) = synValSig
3675-
3676-
CheckMemberFlags None NewSlotsOK OverridesOK memberFlags m
3677-
3678-
let slots = fst (TcAndPublishValSpec (cenv, envinner, containerInfo, ModuleOrMemberBinding, Some memberFlags, tpenv, synValSig))
3679-
// Multiple slots may be returned, e.g. for
3680-
// abstract P: int with get, set
3681-
3682-
for slot in slots do
3683-
yield mkLocalValRef slot ]
3686+
| Some id -> Some id
36843687

36853688
let baseValOpt = MakeAndPublishBaseVal cenv envinner baseIdOpt (superOfTycon g tycon)
36863689
let safeInitInfo = ComputeInstanceSafeInitInfo cenv envinner thisTyconRef.Range thisTy
@@ -4453,7 +4456,7 @@ module TcDeclarations =
44534456

44544457
let slotsigs = members |> List.choose (function SynMemberDefn.AbstractSlot (slotSig = x; flags = y) -> Some(x, y) | _ -> None)
44554458

4456-
let members,_vals_Inherits_Abstractslots = SplitAutoProps members
4459+
let members, _vals_Inherits_Abstractslots = SplitAutoProps members
44574460

44584461
let isConcrete =
44594462
members |> List.exists (function

src/Compiler/FSComp.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,4 +1746,5 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [<Struct>] di
17461746
3863,parsExpectingField,"Expecting record field"
17471747
3864,tooManyMethodsInDotNetTypeWritingAssembly,"The type '%s' has too many methods. Found: '%d', maximum: '%d'"
17481748
3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors"
1749-
3866,chkStaticAbstractInterfaceMembers,"A static abstract non-virtual interface member should only be called via type parameter (for example: 'T.%s)."
1749+
3866,chkStaticAbstractInterfaceMembers,"A static abstract non-virtual interface member should only be called via type parameter (for example: 'T.%s)."
1750+
3867,chkStaticAbstractMembersOnClasses,"Classes cannot contain static abstract members."

src/Compiler/xlf/FSComp.txt.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ja.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ko.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)