Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to feature/nullness #17175

Merged
merged 4 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.400.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Error for partial implementation of interface with static and non-static abstract members. ([Issue #17138](https://github.com/dotnet/fsharp/issues/17138), [PR #17160](https://github.com/dotnet/fsharp/pull/17160))
* Optimize simple mappings with preludes in computed collections. ([PR #17067](https://github.com/dotnet/fsharp/pull/17067))
* Improve error reporting for abstract members when used in classes. ([PR #17063](https://github.com/dotnet/fsharp/pull/17063))
* Improve error reporting when property has same name as DU case. ([Issue #16646](https://github.com/dotnet/fsharp/issues/16646), [PR #17088](https://github.com/dotnet/fsharp/pull/17088))
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24264.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24266.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>1814df258a66473d388b8884ac95bd1c8a2585a9</Sha>
<Sha>e6f70c7dd528f05cd28cec2a179d58c22e91d9ac</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23475.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"perl": "5.38.2.2"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24264.1",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24266.3",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
4 changes: 3 additions & 1 deletion src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7251,7 +7251,9 @@ and TcObjectExpr (cenv: cenv) env tpenv (objTy, realObjTy, argopt, binds, extraI

DispatchSlotChecking.CheckOverridesAreAllUsedOnce (env.DisplayEnv, g, cenv.infoReader, true, implTy, dispatchSlotsKeyed, availPriorOverrides, overrideSpecs)

DispatchSlotChecking.CheckDispatchSlotsAreImplemented (env.DisplayEnv, cenv.infoReader, m, env.NameEnv, cenv.tcSink, false, true, implTy, dispatchSlots, availPriorOverrides, overrideSpecs) |> ignore)
if not hasStaticMembers then
DispatchSlotChecking.CheckDispatchSlotsAreImplemented (env.DisplayEnv, cenv.infoReader, m, env.NameEnv, cenv.tcSink, false, implTy, dispatchSlots, availPriorOverrides, overrideSpecs) |> ignore
)

// 3. create the specs of overrides
let allTypeImpls =
Expand Down
12 changes: 4 additions & 8 deletions src/Compiler/Checking/MethodOverrides.fs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ module DispatchSlotChecking =
let CheckDispatchSlotsAreImplemented (denv, infoReader: InfoReader, m,
nenv, sink: TcResultsSink,
isOverallTyAbstract,
isObjExpr: bool,
reqdTy,
dispatchSlots: RequiredSlot list,
availPriorOverrides: OverrideInfo list,
Expand Down Expand Up @@ -380,8 +379,7 @@ module DispatchSlotChecking =
let compiledSig = CompiledSigOfMeth g amap m dispatchSlot

let noimpl() =
if dispatchSlot.IsInstance then
missingOverloadImplementation.Add((isReqdTyInterface, lazy NicePrint.stringOfMethInfo infoReader m denv dispatchSlot))
missingOverloadImplementation.Add((isReqdTyInterface, lazy NicePrint.stringOfMethInfo infoReader m denv dispatchSlot))

match overrides |> List.filter (IsPartialMatch g dispatchSlot compiledSig) with
| [] ->
Expand All @@ -404,10 +402,8 @@ module DispatchSlotChecking =

let (CompiledSig (vargTys, _, fvmethTypars, _)) = compiledSig

// Object expressions can only implement instance members
let isObjExprWithInstanceMembers = (isObjExpr && isInstance)
if isObjExprWithInstanceMembers || isInstance then
if moreThanOnePossibleDispatchSlot then
if isInstance then
if moreThanOnePossibleDispatchSlot then
noimpl()

elif (argTys.Length <> vargTys.Length) then
Expand Down Expand Up @@ -828,7 +824,7 @@ module DispatchSlotChecking =

if isImplementation && not (isInterfaceTy g overallTy) then
let overrides = allImmediateMembersThatMightImplementDispatchSlots |> List.map snd
let allCorrect = CheckDispatchSlotsAreImplemented (denv, infoReader, m, nenv, sink, tcaug.tcaug_abstract, false, reqdTy, dispatchSlots, availPriorOverrides, overrides)
let allCorrect = CheckDispatchSlotsAreImplemented (denv, infoReader, m, nenv, sink, tcaug.tcaug_abstract, reqdTy, dispatchSlots, availPriorOverrides, overrides)

// Tell the user to mark the thing abstract if it was missing implementations
if not allCorrect && not tcaug.tcaug_abstract && (isClassTy g reqdTy) then
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/Checking/MethodOverrides.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ module DispatchSlotChecking =
nenv: NameResolutionEnv *
sink: TcResultsSink *
isOverallTyAbstract: bool *
isObjExpr: bool *
reqdTy: TType *
dispatchSlots: RequiredSlot list *
availPriorOverrides: OverrideInfo list *
Expand Down
3 changes: 1 addition & 2 deletions tests/AheadOfTime/Trimming/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len) {
CheckTrim -root "SelfContained_Trimming_Test" -tfm "net8.0" -outputfile "FSharp.Core.dll" -expected_len 286208

# Check net8.0 trimmed assemblies
CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net8.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8821760

CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net8.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8819200
Original file line number Diff line number Diff line change
Expand Up @@ -1269,3 +1269,133 @@ type A () =
|> withDiagnostics [
(Error 3867, Line 3, Col 21, Line 3, Col 22, "Classes cannot contain static abstract members.")
]

[<FactForNETCOREAPP>]
let ``Error for partial implementation of interface with static abstract members`` () =
Fsx """
type IFace =
static abstract P1 : int
static abstract P2 : int

type T =
interface IFace with
static member P1 = 1

"""
|> withOptions [ "--nowarn:3536" ; "--nowarn:3535" ]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 366, Line 7, Col 15, Line 7, Col 20, "No implementation was given for 'static abstract IFace.P2: int'. Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
]

[<FactForNETCOREAPP>]
let ``Error for no implementation of interface with static abstract members`` () =
Fsx """
type IFace =
static abstract P1 : int
static abstract P2 : int

type T =
interface IFace with
"""
|> withOptions [ "--nowarn:3536" ; "--nowarn:3535" ]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 366, Line 7, Col 15, Line 7, Col 20, "No implementation was given for those members:
'static abstract IFace.P1: int'
'static abstract IFace.P2: int'
Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
]

[<FactForNETCOREAPP>]
let ``Error for partial implementation of interface with static and non static abstract members`` () =
Fsx """
type IFace =
static abstract P1 : int
static abstract P2 : int
abstract member P3 : int
abstract member P4 : int

type T =
interface IFace with
static member P1 = 1
member this.P3 = 3

"""
|> withOptions [ "--nowarn:3536" ; "--nowarn:3535" ]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 366, Line 9, Col 15, Line 9, Col 20, "No implementation was given for those members:
'static abstract IFace.P2: int'
'abstract IFace.P4: int'
Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
]

[<FactForNETCOREAPP>]
let ``Error for no implementation of interface with static and non static abstract members`` () =
Fsx """
type IFace =
static abstract P1 : int
static abstract P2 : int
abstract member P3 : int
abstract member P4 : int

type T =
interface IFace with

"""
|> withOptions [ "--nowarn:3536" ; "--nowarn:3535" ]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 366, Line 9, Col 15, Line 9, Col 20, "No implementation was given for those members:
'static abstract IFace.P1: int'
'static abstract IFace.P2: int'
'abstract IFace.P3: int'
'abstract IFace.P4: int'
Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
]

[<FactForNETCOREAPP>]
let ``Error for partial implementation of interface with non static abstract members`` () =
Fsx """
type IFace =
abstract member P3 : int
abstract member P4 : int

type T =
interface IFace with
member this.P3 = 3

"""
|> withOptions [ "--nowarn:3536" ; "--nowarn:3535" ]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 366, Line 7, Col 15, Line 7, Col 20, "No implementation was given for 'abstract IFace.P4: int'. Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
]

[<FactForNETCOREAPP>]
let ``Error for no implementation of interface with non static abstract members`` () =
Fsx """
type IFace =
abstract member P3 : int
abstract member P4 : int

type T =
interface IFace with

"""
|> withOptions [ "--nowarn:3536" ; "--nowarn:3535" ]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 366, Line 7, Col 15, Line 7, Col 20, "No implementation was given for those members:
'abstract IFace.P3: int'
'abstract IFace.P4: int'
Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
]

Loading