-
Notifications
You must be signed in to change notification settings - Fork 789
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
RFC FS-1124 - Interfaces with static abstract methods #13119
RFC FS-1124 - Interfaces with static abstract methods #13119
Conversation
* cleanup * split files * rename * split infos.fs and SymbolHelpres.fs * split infos.fs and SymbolHelpres.fs * fix code formating * rename autobox --> LowerLocalMutables * adjust names * block --> ImmutableArray * format * Error --> SRDiagnostic * Error --> SRDiagnostic * this -> _ * rename and cleanup * rename Diagnostic --> FormattedDiagnostic * format sigs * format sigs * fix build * fix build
This reverts commit ff0deda.
@vzarytovskii @0101 I pushed a fix to allow byref arguments in the new syntax for SRTP trait calls, e.g. see These should be turned into proper tests please :) There is a note about byref returns in member traits, which are not supported - they could be, but it is orthogonal to this PR |
let typeParams = Seq.replicate paramCount "'T" |> String.concat "," | ||
let genericType = $"{name}<{typeParams}>" | ||
let potatoParams = Seq.replicate paramCount "float<potato>" |> String.concat "," | ||
let potatoType = $"{name}<{potatoParams}>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests look good!
Probably add a test when the user defines an interface in System.Numerics too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also one where the user defines a new interface NOT in System.Numerics but derives from an interface in System.Numerics
This should avoid collisions of shared references
…arp into statics-in-interfaces-2
@@ -8,6 +8,9 @@ | |||
|
|||
<PropertyGroup> | |||
<DotnetFscCompilerPath>$(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net6.0/fsc.dll</DotnetFscCompilerPath> | |||
<Fsc_DotNET_DotnetFscCompilerPath>$(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net6.0/fsc.dll</Fsc_DotNET_DotnetFscCompilerPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably adjust the FSharp.Core.UnitTests and a few others to do this. I've noticed they use the Proto to build, perhaps it's better to just use the built compiler.
This looks good to me. |
Would be nice to include the switch to |
Yeah, we probably shouldn't wait for it, can be done in parallel/later. |
I can't find this info anywhere: When using Here is the old syntax: let inline oldSyntax< ^a, ^b when (^a or ^b): (static member create: ^a -> ^b)> (x: ^a) : ^b =
((^a or ^b): (static member create: ^a -> ^b) x) But in F# 7, this doesn't compile: let inline newSyntax<'a, 'b when ('a or 'b): (static member create: ^a -> 'b)> (x: 'a) : 'b =
('a or 'b).create x Neither does replacing the second line with What is the new syntax in this case? |
It also seems like let inline f (x: 'a) : 'b = (^a: (static member create: 'a -> 'b) x) fails compilation if replacing ^a with 'a. fails if replacing the |
Yeah, if the old syntax needs to be used, type ^ must be used, it's a known limitation. |
Ok! But what about |
how can I implement static abstract members in my derived classes |
Support interfaces with static abstract methods suggestion, RFC
Things included in this PR that are not yet documented in RFC:
C<^int>
to not need a space, including updating tests((^T or C) : (static member P: int) ())
SRTP call syntax (i.e. nominal types afteror
)TODO:
'T.
IWSAMs + tests'T.Name
IWSAM (should work)'T
- may be a larger issue since these are missing for any generic type parameters at the momentFix trait with expression warning(^T or C) : ...
call syntax for SRTPOther cleanup items currently in this PR (could be factored out):
ParamAttribs
type ininfos.fs
for large tupleg
parameter to Freshen routinesItem
type, completing some cases in the obvious wayAddUnsolvedMemberConstraint
,TraitsAreRelated
,EnforceConstraintConsistency
,CheckConstraintImplication
,EnforceConstraintSetConsistency
,EliminateRedundantConstraints
, cleanupSolveTypeChoice
in ConstraintSolverAssignedPropSetter
CrackParamAttribsInfo
in infos.fsList.iter2
in ilxgen.fsDecideStaticOptimizations
call to Optimizer.fsTType_app (tcref, _, _)
withAbbrevOrAppTy tcref
which looks through type inference equations.SemanticClassification.fs
to recude complexityTTypeConvOp
in Exprs.fs to use type equalityTraitWitnessInfo
ILMethSln
decideStaticOptimizationConstraint
HelpContextServiceTests.fs
activated and workingRenamings:
TcLongIdent
-->TcLongIdent
checkLanguageFeatureRuntimeErrorRecover -->
checkLanguageFeatureRuntimeAndRecover`mkILNonGenericVirtualMethod
-->mkILNonGenericVirtualInstanceMethod
GetBaseClassCandidates
-->IsInheritsCompletionCandidate
GetInterfaceCandidates
-->IsInterfaceCompletionCandidate
IsInterfaceFile
-->IsSignatureFile
MemberName
-->MemberLogicalName
ArgumentTypes
-->CompiledObjectAndArgumentTypes
ReturnType
-->CompiledReturnType
Microsoft.VisualStudio.FSharp.Editor.Tests.Roslyn
-->VisualFSharp.UnitTests.Editor
CreateDocument
-->CreateSingleDocumentSolution