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 release/dev17.11 #17089

Merged
merged 2 commits into from
Apr 25, 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
25 changes: 0 additions & 25 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -920,11 +920,6 @@ module MutRecBindingChecking =
/// A 'member' definition in a class
| Phase2AMember of PreCheckingRecursiveBinding

#if OPEN_IN_TYPE_DECLARATIONS
/// A dummy declaration, should we ever support 'open' in type definitions
| Phase2AOpen of SynOpenDeclTarget * range
#endif

/// Indicates the super init has just been called, 'this' may now be published
| Phase2AIncrClassCtorJustAfterSuperInit

Expand Down Expand Up @@ -1142,13 +1137,6 @@ module MutRecBindingChecking =

let innerState = (incrCtorInfoOpt, envForTycon, tpenv, recBindIdx, List.rev binds @ uncheckedBindsRev)
cbinds, innerState

#if OPEN_IN_TYPE_DECLARATIONS
| Some (SynMemberDefn.Open (target, m)), _ ->
let innerState = (incrCtorInfoOpt, env, tpenv, recBindIdx, prelimRecValuesRev, uncheckedBindsRev)
[ Phase2AOpen (target, m) ], innerState
#endif

| definition ->
error(InternalError(sprintf "Unexpected definition %A" definition, m)))

Expand Down Expand Up @@ -1196,9 +1184,6 @@ module MutRecBindingChecking =
let rest =
let isAfter b =
match b with
#if OPEN_IN_TYPE_DECLARATIONS
| Phase2AOpen _
#endif
| Phase2AIncrClassCtor _ | Phase2AInherit _ | Phase2AIncrClassCtorJustAfterSuperInit -> false
| Phase2AIncrClassBindings (_, binds, _, _, _) -> binds |> List.exists (function SynBinding (kind=SynBindingKind.Do) -> true | _ -> false)
| Phase2AIncrClassCtorJustAfterLastLet
Expand Down Expand Up @@ -1417,16 +1402,6 @@ module MutRecBindingChecking =
| Phase2AIncrClassCtorJustAfterLastLet ->
let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable)
Phase2BIncrClassCtorJustAfterLastLet, innerState


#if OPEN_IN_TYPE_DECLARATIONS
| Phase2AOpen(target, m) ->
let envInstance = TcOpenDecl cenv m scopem envInstance target
let envStatic = TcOpenDecl cenv m scopem envStatic target
let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable)
Phase2BOpen, innerState
#endif


// Note: this path doesn't add anything the environment, because the member is already available off via its type

Expand Down
9 changes: 0 additions & 9 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2614,13 +2614,8 @@ module EventDeclarationNormalization =
let FreshenObjectArgType (cenv: cenv) m rigid tcref isExtrinsic declaredTyconTypars =
let g = cenv.g

#if EXTENDED_EXTENSION_MEMBERS // indicates if extension members can add additional constraints to type parameters
let tcrefObjTy, enclosingDeclaredTypars, renaming, objTy =
FreshenTyconRef g m (if isExtrinsic then TyparRigidity.Flexible else rigid) tcref declaredTyconTypars
#else
let tcrefObjTy, enclosingDeclaredTypars, renaming, objTy =
FreshenTyconRef g m rigid tcref declaredTyconTypars
#endif

// Struct members have a byref 'this' type (unless they are extrinsic extension members)
let thisTy =
Expand Down Expand Up @@ -12386,11 +12381,7 @@ and FixupLetrecBind (cenv: cenv) denv generalizedTyparsForRecursiveBlock (bind:

// Check coherence of generalization of variables for memberInfo members in generic classes
match vspec.MemberInfo with
#if EXTENDED_EXTENSION_MEMBERS // indicates if extension members can add additional constraints to type parameters
| Some _ when not vspec.IsExtensionMember ->
#else
| Some _ ->
#endif
match PartitionValTyparsForApparentEnclosingType g vspec with
| Some(parentTypars, memberParentTypars, _, _, _) ->
ignore(SignatureConformance.Checker(g, cenv.amap, denv, SignatureRepackageInfo.Empty, false).CheckTypars vspec.Range TypeEquivEnv.Empty memberParentTypars parentTypars)
Expand Down
21 changes: 1 addition & 20 deletions src/Compiler/Checking/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,10 +1058,6 @@ and SolveTypeEqualsType (csenv: ConstraintSolverEnv) ndeep m2 (trace: OptionalTr
let aenv = csenv.EquivEnv
let g = csenv.g

// Pre F# 6.0 we asssert the trait solution here
#if TRAIT_CONSTRAINT_CORRECTIONS
if not (csenv.g.langVersion.SupportsFeature LanguageFeature.TraitConstraintCorrections) then
#endif
match cxsln with
| Some (traitInfo, traitSln) when traitInfo.Solution.IsNone ->
// If this is an overload resolution at this point it's safe to assume the candidate member being evaluated solves this member constraint.
Expand Down Expand Up @@ -2895,22 +2891,11 @@ and ReportNoCandidatesErrorSynExpr csenv callerArgCounts methodName ad calledMet
///
/// In F# 5.0 and 6.0 we assert this late by passing the cxsln parameter around. However this
/// relies on not checking return types for SRTP constraints eagerly
///
/// Post F# 6.0 (TraitConstraintCorrections) we will assert this early and add a proper check that return types match for SRTP constraint solving
/// (see alwaysCheckReturn)
and AssumeMethodSolvesTrait (csenv: ConstraintSolverEnv) (cx: TraitConstraintInfo option) m trace (calledMeth: CalledMeth<_>) =
and AssumeMethodSolvesTrait (csenv: ConstraintSolverEnv) (cx: TraitConstraintInfo option) m _trace (calledMeth: CalledMeth<_>) =
match cx with
| Some traitInfo when traitInfo.Solution.IsNone ->
let staticTyOpt = if calledMeth.Method.IsInstance then None else calledMeth.OptionalStaticType
let traitSln = MemberConstraintSolutionOfMethInfo csenv.SolverState m calledMeth.Method calledMeth.CalledTyArgs staticTyOpt
#if TRAIT_CONSTRAINT_CORRECTIONS
if csenv.g.langVersion.SupportsFeature LanguageFeature.TraitConstraintCorrections then
TransactMemberConstraintSolution traitInfo trace traitSln
None
else
#else
ignore trace
#endif
Some (traitInfo, traitSln)
| _ ->
None
Expand Down Expand Up @@ -2971,13 +2956,9 @@ and ResolveOverloading
// Always take the return type into account for
// -- op_Explicit, op_Implicit
// -- candidate method sets that potentially use tupling of unfilled out args
/// -- if TraitConstraintCorrections is enabled, also check return types for SRTP constraints
let alwaysCheckReturn =
isOpConversion ||
candidates |> List.exists (fun cmeth -> cmeth.HasOutArgs)
#if TRAIT_CONSTRAINT_CORRECTIONS
|| (csenv.g.langVersion.SupportsFeature LanguageFeature.TraitConstraintCorrections && cx.IsSome)
#endif

// Exact match rule.
//
Expand Down
20 changes: 0 additions & 20 deletions src/Compiler/Checking/MethodCalls.fs
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,7 @@ let AdjustCalledArgType (infoReader: InfoReader) ad isConstraint enforceNullable

// If the called method argument is an inref type, then the caller may provide a byref or value
if isInByrefTy g calledArgTy then
#if IMPLICIT_ADDRESS_OF
if isByrefTy g callerArgTy then
calledArgTy
else
destByrefTy g calledArgTy
#else
calledArgTy, TypeDirectedConversionUsed.No, None
#endif

// If the called method argument is a (non inref) byref type, then the caller may provide a byref or ref.
elif isByrefTy g calledArgTy then
Expand Down Expand Up @@ -1371,12 +1364,6 @@ let AdjustCallerArgExpr tcVal (g: TcGlobals) amap infoReader ad isOutArg calledA
if isByrefTy g calledArgTy && isRefCellTy g callerArgTy then
None, Expr.Op (TOp.RefAddrGet false, [destRefCellTy g callerArgTy], [callerArgExpr], m)

#if IMPLICIT_ADDRESS_OF
elif isInByrefTy g calledArgTy && not (isByrefTy g callerArgTy) then
let wrap, callerArgExprAddress, _readonly, _writeonly = mkExprAddrOfExpr g true false NeverMutates callerArgExpr None m
Some wrap, callerArgExprAddress
#endif

// auto conversions to quotations (to match auto conversions to LINQ expressions)
elif reflArgInfo.AutoQuote && isQuotedExprTy g calledArgTy && not (isQuotedExprTy g callerArgTy) then
match reflArgInfo with
Expand Down Expand Up @@ -1943,13 +1930,6 @@ module ProvidedMethodCalls =
let infoReader = InfoReader(g, amap)
let exprR = CoerceFromFSharpFuncToDelegate g amap infoReader AccessorDomain.AccessibleFromSomewhere lambdaExprTy m lambdaExpr delegateTyR
None, (exprR, tyOfExpr g exprR)
#if PROVIDED_ADDRESS_OF
| ProvidedAddressOfExpr e ->
let eR = exprToExpr (exprType.PApply((fun _ -> e), m))
let wrap,exprR, _readonly, _writeonly = mkExprAddrOfExpr g true false DefinitelyMutates eR None m
let exprR = wrap exprR
None, (exprR, tyOfExpr g exprR)
#endif
| ProvidedDefaultExpr pty ->
let ty = Import.ImportProvidedType amap m (exprType.PApply((fun _ -> pty), m))
let exprR = mkDefault (m, ty)
Expand Down
53 changes: 0 additions & 53 deletions src/Compiler/Checking/PatternMatchCompilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -735,26 +735,6 @@ let ChooseInvestigationPointLeftToRight frontiers =
| [] -> failwith "ChooseInvestigationPointLeftToRight: no frontiers!"



#if OPTIMIZE_LIST_MATCHING
// This is an initial attempt to remove extra typetests/castclass for simple list pattern matching "match x with h :: t -> ... | [] -> ..."
// The problem with this technique is that it creates extra locals which inhibit the process of converting pattern matches into linear let bindings.

[<return: Struct>]
let (|ListConsDiscrim|_|) g = function
| (DecisionTreeTest.UnionCase (ucref, tinst))
(* check we can use a simple 'isinst' instruction *)
when tyconRefEq g ucref.TyconRef g.list_tcr_canon & ucref.CaseName = "op_ColonColon" -> ValueSome tinst
| _ -> ValueNone

[<return: Struct>]
let (|ListEmptyDiscrim|_|) g = function
| (DecisionTreeTest.UnionCase (ucref, tinst))
(* check we can use a simple 'isinst' instruction *)
when tyconRefEq g ucref.TyconRef g.list_tcr_canon & ucref.CaseName = "op_Nil" -> ValueSome tinst
| _ -> ValueNone
#endif

[<return: Struct>]
let (|ConstNeedsDefaultCase|_|) c =
match c with
Expand Down Expand Up @@ -806,17 +786,6 @@ let rec BuildSwitch inpExprOpt g expr edges dflt m =
| TCase((DecisionTreeTest.IsNull | DecisionTreeTest.IsInst _), _) as edge :: edges, dflt ->
TDSwitch(expr, [edge], Some (BuildSwitch None g expr edges dflt m), m)

#if OPTIMIZE_LIST_MATCHING
// 'cons/nil' tests where we have stored the result of the cons test in an 'isinst' in a variable
// In this case the 'expr' already holds the result of the 'isinst' test.
| [TCase(ListConsDiscrim g tinst, consCase)], Some emptyCase
| [TCase(ListEmptyDiscrim g tinst, emptyCase)], Some consCase
| [TCase(ListEmptyDiscrim g _, emptyCase); TCase(ListConsDiscrim g tinst, consCase)], None
| [TCase(ListConsDiscrim g tinst, consCase); TCase(ListEmptyDiscrim g _, emptyCase)], None
when Option.isSome inpExprOpt ->
TDSwitch(expr, [TCase(DecisionTreeTest.IsNull, emptyCase)], Some consCase, m)
#endif

// All these should also always have default cases
| TCase(DecisionTreeTest.Const ConstNeedsDefaultCase, _) :: _, None ->
error(InternalError("inexhaustive match - need a default case!", m))
Expand Down Expand Up @@ -1272,25 +1241,6 @@ let CompilePatternBasic
AdjustValToHaveValReprInfo v origInputVal.TryDeclaringEntity ValReprInfo.emptyValData
Some addrExp, Some (mkInvisibleBind v e)



#if OPTIMIZE_LIST_MATCHING
| [EdgeDiscrim(_, ListConsDiscrim g tinst, m); EdgeDiscrim(_, ListEmptyDiscrim g _, _)]
| [EdgeDiscrim(_, ListEmptyDiscrim g _, _); EdgeDiscrim(_, ListConsDiscrim g tinst, m)]
| [EdgeDiscrim(_, ListConsDiscrim g tinst, m)]
| [EdgeDiscrim(_, ListEmptyDiscrim g tinst, m)]
(* check we can use a simple 'isinst' instruction *)
when isNil origInputValTypars ->

let ucaseTy = (mkProvenUnionCaseTy g.cons_ucref tinst)
let v, vExpr = mkCompGenLocal m "unionTestResult" ucaseTy
if origInputVal.IsMemberOrModuleBinding then
AdjustValToHaveValReprInfo v origInputVal.DeclaringEntity ValReprInfo.emptyValData
let argExpr = GetSubExprOfInput subexpr
let appExpr = mkIsInst ucaseTy argExpr mMatch
Some vExpr, Some (mkInvisibleBind v appExpr)
#endif

// Active pattern matches: create a variable to hold the results of executing the active pattern.
// If a struct return we continue with an expression for taking the address of that location.
| EdgeDiscrim(_, DecisionTreeTest.ActivePatternCase(activePatExpr, resTys, retKind, _apatVrefOpt, _, apinfo), m) :: _ ->
Expand Down Expand Up @@ -1343,9 +1293,6 @@ let CompilePatternBasic
let resPostBindOpt, ucaseBindOpt =
match discrim with
| DecisionTreeTest.UnionCase (ucref, tinst) when
#if OPTIMIZE_LIST_MATCHING
isNone inpExprOpt &&
#endif
(isNil origInputValTypars &&
not origInputVal.IsMemberOrModuleBinding &&
not ucref.Tycon.IsStructRecordOrUnionTycon &&
Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/Checking/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2144,10 +2144,6 @@ let CheckModuleBinding cenv env (TBind(v, e, _) as bind) =

error(Duplicate(kind, v.DisplayName, v.Range))

#if CASES_IN_NESTED_CLASS
if tcref.IsUnionTycon && nm = "Cases" then
errorR(NameClash(nm, kind, v.DisplayName, v.Range, "generated type", "Cases", tcref.Range))
#endif
if tcref.IsUnionTycon then
match nm with
| "Tag" -> errorR(NameClash(nm, kind, v.DisplayName, v.Range, FSComp.SR.typeInfoGeneratedProperty(), "Tag", tcref.Range))
Expand Down
7 changes: 0 additions & 7 deletions src/Compiler/Driver/CompilerImports.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2336,12 +2336,6 @@ and [<Sealed>] TcImports
match resolutions.TryFindByOriginalReference assemblyReference with
| Some assemblyResolution -> ResultD [ assemblyResolution ]
| None ->
#if NO_MSBUILD_REFERENCE_RESOLUTION
try
ResultD [ tcConfig.ResolveLibWithDirectories assemblyReference ]
with e ->
ErrorD e
#else
// Next try to lookup up by the exact full resolved path.
match resolutions.TryFindByResolvedPath assemblyReference.Text with
| Some assemblyResolution -> ResultD [ assemblyResolution ]
Expand Down Expand Up @@ -2374,7 +2368,6 @@ and [<Sealed>] TcImports
// Note, if mode=ResolveAssemblyReferenceMode.Speculative and the resolution failed then TryResolveLibsUsingMSBuildRules returns
// the empty list and we convert the failure into an AssemblyNotResolved here.
ErrorD(AssemblyNotResolved(assemblyReference.Text, assemblyReference.Range))
#endif
)

member tcImports.ResolveAssemblyReference(ctok, assemblyReference, mode) : AssemblyResolution list =
Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/Facilities/BuildGraph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ module GraphNode =
match preferredUiLang with
| Some s ->
culture <- CultureInfo s
#if FX_RESHAPED_GLOBALIZATION
CultureInfo.CurrentUICulture <- culture
#else
Thread.CurrentThread.CurrentUICulture <- culture
#endif
| None -> ()

[<Sealed>]
Expand Down
7 changes: 0 additions & 7 deletions src/Compiler/Optimize/Optimizer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2521,13 +2521,6 @@ and MakeOptimizedSystemStringConcatCall cenv env m args =
when IsILMethodRefSystemStringConcat ilMethRef ->
optimizeArgs args accArgs

// String constant folding requires a bit more work as we cannot quadratically concat strings at compile time.
#if STRING_CONSTANT_FOLDING
// Optimize string constants, e.g. "1" + "2" will turn into "12"
| Expr.Const (Const.String str1, _, _), Expr.Const (Const.String str2, _, _) :: accArgs ->
mkString g m (str1 + str2) :: accArgs
#endif

| arg, _ -> arg :: accArgs

and optimizeArgs args accArgs =
Expand Down
40 changes: 0 additions & 40 deletions src/Compiler/SyntaxTree/XmlDoc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,46 +118,6 @@ type XmlDoc(unprocessedLines: string[], range: range) =
with e ->
warning (Error(FSComp.SR.xmlDocBadlyFormed (e.Message), doc.Range))

#if CREF_ELABORATION
member doc.Elaborate(crefResolver) =
for see in
seq {
yield! xml.Descendants(XName.op_Implicit "see")
yield! xml.Descendants(XName.op_Implicit "seealso")
yield! xml.Descendants(XName.op_Implicit "exception")
} do
match see.Attribute(XName.op_Implicit "cref") with
| null -> warning (Error(FSComp.SR.xmlDocMissingCrossReference (), doc.Range))
| attr ->
let cref = attr.Value

if
cref.StartsWith("T:")
|| cref.StartsWith("P:")
|| cref.StartsWith("M:")
|| cref.StartsWith("E:")
|| cref.StartsWith("F:")
then
()
else
match crefResolver cref with
| None -> warning (Error(FSComp.SR.xmlDocUnresolvedCrossReference (nm), doc.Range))
| Some text ->
attr.Value <- text
modified <- true

if modified then
let m = doc.Range

let newLines =
[|
for e in xml.Elements() do
yield! e.ToString().Split([| '\r'; '\n' |], StringSplitOptions.RemoveEmptyEntries)
|]

lines <- newLines
#endif

// Discriminated unions can't contain statics, so we use a separate type
and XmlDocStatics() =

Expand Down
6 changes: 0 additions & 6 deletions src/Compiler/TypedTree/TypeProviders.fs
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,6 @@ type ProvidedConstructorInfo (x: ConstructorInfo, ctxt) =

type ProvidedExprType =
| ProvidedNewArrayExpr of ProvidedType * ProvidedExpr[]
#if PROVIDED_ADDRESS_OF
| ProvidedAddressOfExpr of ProvidedExpr
#endif
| ProvidedNewObjectExpr of ProvidedConstructorInfo * ProvidedExpr[]
| ProvidedWhileLoopExpr of ProvidedExpr * ProvidedExpr
| ProvidedNewDelegateExpr of ProvidedType * ProvidedVar[] * ProvidedExpr
Expand Down Expand Up @@ -919,9 +916,6 @@ type ProvidedExpr (x: Expr, ctxt) =
Some (ProvidedTryFinallyExpr (ProvidedExpr.Create ctxt b1, ProvidedExpr.Create ctxt b2))
| Patterns.TryWith(b, v1, e1, v2, e2) ->
Some (ProvidedTryWithExpr (ProvidedExpr.Create ctxt b, ProvidedVar.Create ctxt v1, ProvidedExpr.Create ctxt e1, ProvidedVar.Create ctxt v2, ProvidedExpr.Create ctxt e2))
#if PROVIDED_ADDRESS_OF
| Patterns.AddressOf e -> Some (ProvidedAddressOfExpr (ProvidedExpr.Create ctxt e))
#endif
| Patterns.TypeTest(e, ty) ->
Some (ProvidedTypeTestExpr(ProvidedExpr.Create ctxt e, ProvidedType.Create ctxt ty))
| Patterns.Let(v, e, b) ->
Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/TypedTree/TypeProviders.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,6 @@ type ProvidedExprType =

| ProvidedNewArrayExpr of ProvidedType * ProvidedExpr[]

#if PROVIDED_ADDRESS_OF
| ProvidedAddressOfExpr of ProvidedExpr
#endif

| ProvidedNewObjectExpr of ProvidedConstructorInfo * ProvidedExpr[]

| ProvidedWhileLoopExpr of ProvidedExpr * ProvidedExpr
Expand Down
Loading
Loading