Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.
@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.
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.
Also one where the user defines a new interface NOT in System.Numerics but derives from an interface in System.Numerics
Uh oh!
There was an error while loading. Please reload this page.
This should avoid collisions of shared references
…arp into statics-in-interfaces-2
| <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.
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.
vzarytovskii
commented
Aug 8, 2022
This looks good to me. |
0101
commented
Aug 8, 2022
Would be nice to include the switch to |
vzarytovskii
commented
Aug 8, 2022
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 inlineoldSyntax<^a,^bwhen(^a or ^b):(static member create:^a->^b)>(x:^a):^b =((^aor^b):(static membercreate:^a->^b) x)But in F# 7, this doesn't compile: let inlinenewSyntax<'a,'bwhen('a or 'b):(static member create:^a->'b)>(x:'a):'b =('a or 'b).create xNeither does replacing the second line with What is the new syntax in this case? |
It also seems like let inlinef(x:'a):'b =(^a:(static membercreate: 'a -> 'b) x) fails compilation if replacing ^a with 'a.fails if replacing the |
vzarytovskii
commented
Nov 9, 2022
Yeah, if the old syntax needs to be used, type ^ must be used, it's a known limitation. |
cmeeren
commented
Nov 9, 2022
Ok! But what about |
Xyncgas
commented
Feb 27, 2024
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.NameIWSAM (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):
ParamAttribstype ininfos.fsfor large tuplegparameter to Freshen routinesItemtype, completing some cases in the obvious wayAddUnsolvedMemberConstraint,TraitsAreRelated,EnforceConstraintConsistency,CheckConstraintImplication,EnforceConstraintSetConsistency,EliminateRedundantConstraints, cleanupSolveTypeChoicein ConstraintSolverAssignedPropSetterCrackParamAttribsInfoin infos.fsList.iter2in ilxgen.fsDecideStaticOptimizationscall to Optimizer.fsTType_app (tcref, _, _)withAbbrevOrAppTy tcrefwhich looks through type inference equations.SemanticClassification.fsto recude complexityTTypeConvOpin Exprs.fs to use type equalityTraitWitnessInfoILMethSlndecideStaticOptimizationConstraintHelpContextServiceTests.fsactivated and workingRenamings:
TcLongIdent-->TcLongIdentcheckLanguageFeatureRuntimeErrorRecover -->checkLanguageFeatureRuntimeAndRecover`mkILNonGenericVirtualMethod-->mkILNonGenericVirtualInstanceMethodGetBaseClassCandidates-->IsInheritsCompletionCandidateGetInterfaceCandidates-->IsInterfaceCompletionCandidateIsInterfaceFile-->IsSignatureFileMemberName-->MemberLogicalNameArgumentTypes-->CompiledObjectAndArgumentTypesReturnType-->CompiledReturnTypeMicrosoft.VisualStudio.FSharp.Editor.Tests.Roslyn-->VisualFSharp.UnitTests.EditorCreateDocument-->CreateSingleDocumentSolution