Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
mkAppTy resolved
  • Loading branch information
T-Gro committed Mar 14, 2024
commit 4ba648bdabf334eef698c19cbc512041a76be511
2 changes: 1 addition & 1 deletion src/Compiler/Checking/AttributeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ let IsSecurityAttribute (g: TcGlobals) amap (casmap : IDictionary<Stamp, bool>)
match casmap.TryGetValue tcs with
| true, c -> c
| _ ->
let exists = ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkAppTy attr.TyconRef [])) g amap m AllowMultiIntfInstantiations.Yes (mkAppTy tcref [])
let exists = ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkWoNullAppTy attr.TyconRef [])) g amap m AllowMultiIntfInstantiations.Yes (mkWoNullAppTy tcref [])
casmap[tcs] <- exists
exists
| ValueNone -> false
Expand Down
8 changes: 4 additions & 4 deletions src/Compiler/Checking/AugmentWithHashCompare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let mkIComparableCompareToSlotSig (g: TcGlobals) =
let mkGenericIComparableCompareToSlotSig (g: TcGlobals) ty =
TSlotSig(
"CompareTo",
(mkAppTy g.system_GenericIComparable_tcref [ ty ]),
(mkWoNullAppTy g.system_GenericIComparable_tcref [ ty ]),
[],
[],
[ [ TSlotParam(Some("obj"), ty, false, false, false, []) ] ],
Expand All @@ -44,7 +44,7 @@ let mkIStructuralComparableCompareToSlotSig (g: TcGlobals) =
let mkGenericIEquatableEqualsSlotSig (g: TcGlobals) ty =
TSlotSig(
"Equals",
(mkAppTy g.system_GenericIEquatable_tcref [ ty ]),
(mkWoNullAppTy g.system_GenericIEquatable_tcref [ ty ]),
[],
[],
[ [ TSlotParam(Some("obj"), ty, false, false, false, []) ] ],
Expand Down Expand Up @@ -414,7 +414,7 @@ let mkExnEquality (g: TcGlobals) exnref (exnc: Tycon) =

let cases =
[
mkCase (DecisionTreeTest.IsInst(g.exn_ty, mkAppTy exnref []), mbuilder.AddResultTarget(expr))
mkCase (DecisionTreeTest.IsInst(g.exn_ty, mkWoNullAppTy exnref []), mbuilder.AddResultTarget(expr))
]

let dflt = Some(mbuilder.AddResultTarget(mkFalse g m))
Expand Down Expand Up @@ -445,7 +445,7 @@ let mkExnEqualityWithComparer g exnref (exnc: Tycon) (_thisv, thise) thatobje (t

let cases =
[
mkCase (DecisionTreeTest.IsInst(g.exn_ty, mkAppTy exnref []), mbuilder.AddResultTarget(expr))
mkCase (DecisionTreeTest.IsInst(g.exn_ty, mkWoNullAppTy exnref []), mbuilder.AddResultTarget(expr))
]

let dflt = mbuilder.AddResultTarget(mkFalse g m)
Expand Down
12 changes: 6 additions & 6 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ module AddAugmentationDeclarations =
let tcaug = tycon.TypeContents
let ty = if tcref.Deref.IsFSharpException then g.exn_ty else generalizedTyconRef g tcref
let m = tycon.Range
let genericIComparableTy = mkAppTy g.system_GenericIComparable_tcref [ty]
let genericIComparableTy = mkWoNullAppTy g.system_GenericIComparable_tcref [ty]


let hasExplicitIComparable = tycon.HasInterface g g.mk_IComparable_ty
Expand Down Expand Up @@ -873,7 +873,7 @@ module AddAugmentationDeclarations =
let vspec1, vspec2 = AugmentTypeDefinitions.MakeValsForEqualsAugmentation g tcref
tcaug.SetEquals (mkLocalValRef vspec1, mkLocalValRef vspec2)
if not tycon.IsFSharpException then
PublishInterface cenv env.DisplayEnv tcref m true (mkAppTy g.system_GenericIEquatable_tcref [ty])
PublishInterface cenv env.DisplayEnv tcref m true (mkWoNullAppTy g.system_GenericIEquatable_tcref [ty])
PublishValueDefn cenv env ModuleOrMemberBinding vspec1
PublishValueDefn cenv env ModuleOrMemberBinding vspec2
AugmentTypeDefinitions.MakeBindingsForEqualsAugmentation g tycon
Expand Down Expand Up @@ -1991,8 +1991,8 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env

if (generatedCompareToValues && typeEquiv g intfTyR g.mk_IComparable_ty) ||
(generatedCompareToWithComparerValues && typeEquiv g intfTyR g.mk_IStructuralComparable_ty) ||
(generatedCompareToValues && typeEquiv g intfTyR (mkAppTy g.system_GenericIComparable_tcref [ty])) ||
(generatedHashAndEqualsWithComparerValues && typeEquiv g intfTyR (mkAppTy g.system_GenericIEquatable_tcref [ty])) ||
(generatedCompareToValues && typeEquiv g intfTyR (mkWoNullAppTy g.system_GenericIComparable_tcref [ty])) ||
(generatedHashAndEqualsWithComparerValues && typeEquiv g intfTyR (mkWoNullAppTy g.system_GenericIEquatable_tcref [ty])) ||
(generatedHashAndEqualsWithComparerValues && typeEquiv g intfTyR g.mk_IStructuralEquatable_ty) then
errorR(Error(FSComp.SR.tcDefaultImplementationForInterfaceHasAlreadyBeenAdded(), intfTy.Range))

Expand Down Expand Up @@ -3316,7 +3316,7 @@ module EstablishTypeDefinitionCores =
super |> Option.map (fun ty ->
if isFunTy g ty then
let a,b = destFunTy g ty
mkAppTy g.fastFunc_tcr [a; b]
mkWoNullAppTy g.fastFunc_tcr [a; b]
else ty)

// Publish the super type
Expand Down Expand Up @@ -3715,7 +3715,7 @@ module EstablishTypeDefinitionCores =
// validate ConditionalAttribute, should it be applied (it's only valid on a type if the type is an attribute type)
match attrs |> List.tryFind (IsMatchingFSharpAttribute g g.attrib_ConditionalAttribute) with
| Some _ ->
if not(ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkAppTy g.tcref_System_Attribute [])) g cenv.amap m AllowMultiIntfInstantiations.Yes thisTy) then
if not(ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkWoNullAppTy g.tcref_System_Attribute [])) g cenv.amap m AllowMultiIntfInstantiations.Yes thisTy) then
errorR(Error(FSComp.SR.tcConditionalAttributeUsage(), m))
| _ -> ()

Expand Down
16 changes: 8 additions & 8 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,10 @@ let TcConst (cenv: cenv) (overallTy: TType) m env synConst =
let measureTy =
match synConst with
| SynConst.Measure(synMeasure = SynMeasure.Anon _) ->
(mkAppTy tcr [TType_measure (Measure.Var (NewAnonTypar (TyparKind.Measure, m, TyparRigidity.Anon, (if iszero then TyparStaticReq.None else TyparStaticReq.HeadType), TyparDynamicReq.No)))])
(mkWoNullAppTy tcr [TType_measure (Measure.Var (NewAnonTypar (TyparKind.Measure, m, TyparRigidity.Anon, (if iszero then TyparStaticReq.None else TyparStaticReq.HeadType), TyparDynamicReq.No)))])

| SynConst.Measure(synMeasure = ms) -> mkAppTy tcr [TType_measure (tcMeasure ms)]
| _ -> mkAppTy tcr [TType_measure Measure.One]
| SynConst.Measure(synMeasure = ms) -> mkWoNullAppTy tcr [TType_measure (tcMeasure ms)]
| _ -> mkWoNullAppTy tcr [TType_measure Measure.One]
unif measureTy

let expandedMeasurablesEnabled =
Expand All @@ -853,7 +853,7 @@ let TcConst (cenv: cenv) (overallTy: TType) m env synConst =
unif g.float_ty
Const.Double f
| SynConst.Decimal f ->
unif (mkAppTy g.decimal_tcr [])
unif (mkWoNullAppTy g.decimal_tcr [])
Const.Decimal f
| SynConst.SByte i ->
unif g.sbyte_ty
Expand Down Expand Up @@ -3419,7 +3419,7 @@ let AnalyzeArbitraryExprAsEnumerable (cenv: cenv) (env: TcEnv) localAlloc m expr
match probe exprTyAsSeq with
| Some res -> res
| None ->
let ienumerable = mkAppTy g.tcref_System_Collections_IEnumerable []
let ienumerable = mkWoNullAppTy g.tcref_System_Collections_IEnumerable []
match probe ienumerable with
| Some res -> res
| None ->
Expand Down Expand Up @@ -5025,7 +5025,7 @@ and TcProvidedTypeApp (cenv: cenv) env tpenv tcref args m =
// We put the type name check after the 'isDirectReferenceToGenerated' check because we need the 'isDirectReferenceToGenerated' error to be shown for generated types
checkTypeName()
if hasNoArgs then
mkAppTy tcref [], tpenv
mkWoNullAppTy tcref [], tpenv
else
let ty = Import.ImportProvidedType cenv.amap m providedTypeAfterStaticArguments
ty, tpenv
Expand Down Expand Up @@ -7642,7 +7642,7 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, withExprOpt, synRecdFields, m
| None -> []
| Some(tinst, tcref, _, fldsList) ->

let gtyp = mkAppTy tcref tinst
let gtyp = mkWoNullAppTy tcref tinst
UnifyTypes cenv env mWholeExpr overallTy gtyp

[ for n, v in fldsList do
Expand Down Expand Up @@ -12105,7 +12105,7 @@ and TcLetrecBinding
| None ->
let reqdThisValTy = if isByrefTy g reqdThisValTy then destByrefTy g reqdThisValTy else reqdThisValTy
let enclosingTyconRef = tcrefOfAppTy g reqdThisValTy
reqdThisValTy, (mkAppTy enclosingTyconRef (List.map mkTyparTy enclosingDeclaredTypars)), vspec.Range
reqdThisValTy, (mkWoNullAppTy enclosingTyconRef (List.map mkTyparTy enclosingDeclaredTypars)), vspec.Range
| Some thisVal ->
reqdThisValTy, thisVal.Type, thisVal.Range
if not (AddCxTypeEqualsTypeUndoIfFailed envRec.DisplayEnv cenv.css rangeForCheck actualThisValTy reqdThisValTy) then
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckPatterns.fs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ and TcRecordPat warnOnUpper cenv env vFlags patEnv ty fieldPats m =
| None -> (fun _ -> TPat_error m), patEnv
| Some(tinst, tcref, fldsmap, _fldsList) ->

let gtyp = mkAppTy tcref tinst
let gtyp = mkWoNullAppTy tcref tinst
let inst = List.zip (tcref.Typars m) tinst

UnifyTypes cenv env m ty gtyp
Expand Down
16 changes: 8 additions & 8 deletions src/Compiler/Checking/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ and DepthCheck ndeep m =
and SolveDimensionlessNumericType (csenv: ConstraintSolverEnv) ndeep m2 trace ty =
match getMeasureOfType csenv.g ty with
| Some (tcref, _) ->
SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace ty (mkAppTy tcref [TType_measure Measure.One])
SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace ty (mkWoNullAppTy tcref [TType_measure Measure.One])
| None ->
CompleteD

Expand Down Expand Up @@ -1641,17 +1641,17 @@ and SolveMemberConstraint (csenv: ConstraintSolverEnv) ignoreUnresolvedOverload
match getMeasureOfType g argTy1 with
| Some (tcref, ms1) ->
let ms2 = freshMeasure ()
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy2 (mkAppTy tcref [TType_measure ms2])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkAppTy tcref [TType_measure (Measure.Prod(ms1, if nm = "op_Multiply" then ms2 else Measure.Inv ms2))])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy2 (mkWoNullAppTy tcref [TType_measure ms2])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkWoNullAppTy tcref [TType_measure (Measure.Prod(ms1, if nm = "op_Multiply" then ms2 else Measure.Inv ms2))])
return TTraitBuiltIn

| _ ->

match getMeasureOfType g argTy2 with
| Some (tcref, ms2) ->
let ms1 = freshMeasure ()
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy1 (mkAppTy tcref [TType_measure ms1])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkAppTy tcref [TType_measure (Measure.Prod(ms1, if nm = "op_Multiply" then ms2 else Measure.Inv ms2))])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy1 (mkWoNullAppTy tcref [TType_measure ms1])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkWoNullAppTy tcref [TType_measure (Measure.Prod(ms1, if nm = "op_Multiply" then ms2 else Measure.Inv ms2))])
return TTraitBuiltIn

| _ ->
Expand Down Expand Up @@ -1785,8 +1785,8 @@ and SolveMemberConstraint (csenv: ConstraintSolverEnv) ignoreUnresolvedOverload
match getMeasureOfType g argTy1 with
| Some (tcref, _) ->
let ms1 = freshMeasure ()
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy1 (mkAppTy tcref [TType_measure (Measure.Prod (ms1, ms1))])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkAppTy tcref [TType_measure ms1])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy1 (mkWoNullAppTy tcref [TType_measure (Measure.Prod (ms1, ms1))])
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkWoNullAppTy tcref [TType_measure ms1])
return TTraitBuiltIn
| None ->
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy argTy1
Expand Down Expand Up @@ -1838,7 +1838,7 @@ and SolveMemberConstraint (csenv: ConstraintSolverEnv) ignoreUnresolvedOverload
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy2 argTy1
match getMeasureOfType g argTy1 with
| None -> do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy argTy1
| Some (tcref, _) -> do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkAppTy tcref [TType_measure Measure.One])
| Some (tcref, _) -> do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy (mkWoNullAppTy tcref [TType_measure Measure.One])
return TTraitBuiltIn

| _ ->
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/Checking/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ let GetNestedTyconRefsOfType (infoReader: InfoReader) (amap: Import.ImportMap) (
let MakeNestedType (ncenv: NameResolver) (tinst: TType list) m (tcrefNested: TyconRef) =
let tps = match tcrefNested.Typars m with [] -> [] | l -> List.skip tinst.Length l
let tinstNested = ncenv.InstantiationGenerator m tps
mkAppTy tcrefNested (tinst @ tinstNested)
mkWoNullAppTy tcrefNested (tinst @ tinstNested)

/// Get all the accessible nested types of an existing type.
let GetNestedTypesOfType (ad, ncenv: NameResolver, optFilter, staticResInfo, checkForGenerated, m) ty =
Expand Down Expand Up @@ -3400,7 +3400,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa
| tcref :: _ when tcref.IsUnionTycon ->
let res = ResolutionInfo.Empty.AddEntity (id.idRange, tcref)
ResolutionInfo.SendEntityPathToSink (sink, ncenv, nenv, ItemOccurence.Pattern, ad, res, ResultTyparChecker(fun () -> true))
Item.Types (id.idText, [ mkAppTy tcref [] ])
Item.Types (id.idText, [ mkWoNullAppTy tcref [] ])
| _ ->
match ResolveLongIdentAsModuleOrNamespace sink ncenv.amap id.idRange true fullyQualified nenv ad id [] false ShouldNotifySink.Yes with
| Result ((_, mref, _) :: _) ->
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/Checking/PatternMatchCompilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ let getDiscrimOfPattern (g: TcGlobals) tpinst t =
| TPat_isinst (srcTy, tgtTy, _, _m) ->
Some(DecisionTreeTest.IsInst (instType tpinst srcTy, instType tpinst tgtTy))
| TPat_exnconstr(tcref, _, _m) ->
Some(DecisionTreeTest.IsInst (g.exn_ty, mkAppTy tcref []))
Some(DecisionTreeTest.IsInst (g.exn_ty, mkWoNullAppTy tcref []))
| TPat_const (c, _m) ->
Some(DecisionTreeTest.Const c)
| TPat_unioncase (c, tyargs', _, _m) ->
Expand Down Expand Up @@ -1520,7 +1520,7 @@ let CompilePatternBasic
| TPat_exnconstr (ecref, argpats, _) ->

let srcTy1 = g.exn_ty
let tgtTy1 = mkAppTy ecref []
let tgtTy1 = mkWoNullAppTy ecref []
if taken |> List.exists (discrimsEq g (DecisionTreeTest.IsInst (srcTy1, tgtTy1))) then [] else

match discrim with
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/QuotationTranslator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.

| TOp.ExnConstr tcref, _, args ->
let _rgtypR = ConvTyconRef cenv tcref m
let _typ = mkAppTy tcref []
let _typ = mkWoNullAppTy tcref []
let parentTyconR = ConvTyconRef cenv tcref m
let argTys = tcref |> recdFieldsOfExnDefRef |> List.map (fun rfld -> rfld.FormalType)
let methArgTypesR = ConvTypes cenv env m argTys
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/Checking/TypeHierarchy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ and GetImmediateInterfacesOfMeasureAnnotatedType skipUnref g amap m ty reprTy =
// However since F# 2.0 we have always reported these interfaces for all measure-annotated types.

//if ExistsInInterfaceHierarchy (typeEquiv g (mkAppTy g.system_GenericIComparable_tcref [reprTy])) skipUnref g amap m ty then
mkAppTy g.system_GenericIComparable_tcref [ty]
mkWoNullAppTy g.system_GenericIComparable_tcref [ty]

//if ExistsInInterfaceHierarchy (typeEquiv g (mkAppTy g.system_GenericIEquatable_tcref [reprTy])) skipUnref g amap m ty then
mkAppTy g.system_GenericIEquatable_tcref [ty]
mkWoNullAppTy g.system_GenericIEquatable_tcref [ty]
]

// Check for any System.Numerics type in the interface hierarchy
Expand Down
8 changes: 4 additions & 4 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ let GetMethodSpecForMemberVal cenv (memberInfo: ValMemberInfo) (vref: ValRef) =
if isCtor || cctor then ILType.Void else ilRetTy

let ilTy =
GenType cenv m tyenvUnderTypars (mkAppTy parentTcref (List.map mkTyparTy ctps))
GenType cenv m tyenvUnderTypars (mkWoNullAppTy parentTcref (List.map mkTyparTy ctps))

let nm = vref.CompiledName g.CompilerGlobalState

Expand Down Expand Up @@ -2195,9 +2195,9 @@ type AnonTypeGenerationTable() =
[
(g.mk_IStructuralComparable_ty, true, m)
(g.mk_IComparable_ty, true, m)
(mkAppTy g.system_GenericIComparable_tcref [ ty ], true, m)
(mkWoNullAppTy g.system_GenericIComparable_tcref [ ty ], true, m)
(g.mk_IStructuralEquatable_ty, true, m)
(mkAppTy g.system_GenericIEquatable_tcref [ ty ], true, m)
(mkWoNullAppTy g.system_GenericIEquatable_tcref [ ty ], true, m)
]

let vspec1, vspec2 = AugmentTypeDefinitions.MakeValsForEqualsAugmentation g tcref
Expand Down Expand Up @@ -5450,7 +5450,7 @@ and CommitCallSequel cenv eenv m cloc cgbuf mustGenerateUnitAfterCall sequel =

and MakeNotSupportedExnExpr cenv eenv (argExpr, m) =
let g = cenv.g
let ety = mkAppTy (g.FindSysTyconRef [ "System" ] "NotSupportedException") []
let ety = mkWoNullAppTy (g.FindSysTyconRef [ "System" ] "NotSupportedException") []
let ilTy = GenType cenv m eenv.tyenv ety
let mref = mkILCtorMethSpecForTy(ilTy, [ g.ilg.typ_String ]).MethodRef
Expr.Op(TOp.ILCall(false, false, false, true, NormalValUse, false, false, mref, [], [], [ ety ]), [], [ argExpr ], m)
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Optimize/Optimizer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ let TryDetectQueryQuoteAndRun cenv (expr: Expr) =
| QuerySelect g (qTy, _, resultElemTy, _, _)
| QueryYield g (qTy, resultElemTy, _)
| QueryYieldFrom g (qTy, resultElemTy, _)
when typeEquiv g qTy (mkAppTy g.tcref_System_Collections_IEnumerable []) ->
when typeEquiv g qTy (mkWoNullAppTy g.tcref_System_Collections_IEnumerable []) ->

match tryRewriteToSeqCombinators g e with
| Some newSource ->
Expand Down
Loading