diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 0fc3e73e247..5cf3ec58222 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -412,7 +412,7 @@ module Zmap = | Some y -> y | None -> failwithf "Zmap.force: %s: x = %+A" str x -let equalTypes (s: Type) (t: Type) = s.Equals t +let equalTypes (s: Type) (t: Type) = Type.op_Equality (s, t) let equalTypeLists (tys1: Type list) (tys2: Type list) = List.lengthsEqAndForall2 equalTypes tys1 tys2 @@ -820,7 +820,8 @@ let TypeBuilderInstantiationT = ty let typeIsNotQueryable (ty: Type) = - (ty :? TypeBuilder) || ((ty.GetType()).Equals(TypeBuilderInstantiationT)) + (ty :? TypeBuilder) + || Type.op_Equality (ty.GetType(), TypeBuilderInstantiationT) let queryableTypeGetField _emEnv (parentT: Type) (fref: ILFieldRef) = let res = diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 9e21c434270..a83ef7d669b 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -3953,7 +3953,7 @@ let rec TcTyparConstraint ridx (cenv: cenv) newOk checkConstraints occ (env: TcE | SynTypeConstraint.WhereTyparIsDelegate(tp, synTys, m) -> TcConstraintWhereTyparIsDelegate cenv env newOk checkConstraints occ tpenv tp synTys m - | SynTypeConstraint.WhereTyparSupportsMember(synSupportTys, synMemberSig, m) -> + | SynTypeConstraint.WhereTyparSupportsMember(TypesForTypar synSupportTys, synMemberSig, m) -> TcConstraintWhereTyparSupportsMember cenv env newOk tpenv synSupportTys synMemberSig m | SynTypeConstraint.WhereSelfConstrained(ty, m) -> @@ -4361,6 +4361,10 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn | SynType.Paren(innerType, _) | SynType.SignatureParameter(usedType = innerType) -> TcTypeOrMeasure kindOpt cenv newOk checkConstraints occ iwsam env tpenv innerType + + | SynType.Or(range = m) -> + // The inner types are expected to be collected by (|TypesForTypar|) at this point. + error(Error((FSComp.SR.tcSynTypeOrInvalidInDeclaration()), m)) and CheckIWSAM (cenv: cenv) (env: TcEnv) checkConstraints iwsam m tcref = let g = cenv.g @@ -5651,7 +5655,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE TcNonControlFlowExpr env <| fun env -> TcExprNamedIndexPropertySet cenv overallTy env tpenv (synLongId, synExpr1, synExpr2, mStmt) - | SynExpr.TraitCall (tps, synMemberSig, arg, m) -> + | SynExpr.TraitCall (TypesForTypar tps, synMemberSig, arg, m) -> TcNonControlFlowExpr env <| fun env -> TcExprTraitCall cenv overallTy env tpenv (tps, synMemberSig, arg, m) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 80c356d31db..2e3267b01a7 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1656,3 +1656,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3546,parsExpectingPatternInTuple,"Expecting pattern" 3547,parsExpectedPatternAfterToken,"Expected a pattern after this point" 3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard is not allowed for union case that takes no data." +3549,tcSynTypeOrInvalidInDeclaration,"SynType.Or is not permitted in this declaration" \ No newline at end of file diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index f3443fd95ff..274d2741365 100755 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -821,7 +821,8 @@ module SyntaxTraversal = | SynType.WithGlobalConstraints (ty, _, _) | SynType.Array (_, ty, _) -> traverseSynType path ty | SynType.StaticConstantNamed (ty1, ty2, _) - | SynType.MeasureDivide (ty1, ty2, _) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path) + | SynType.MeasureDivide (ty1, ty2, _) + | SynType.Or (ty1, ty2, _, _) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path) | SynType.Tuple (path = segments) -> getTypeFromTuplePath segments |> List.tryPick (traverseSynType path) | SynType.StaticConstantExpr (expr, _) -> traverseSynExpr [] expr | SynType.Paren (innerType = t) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index ef194965b34..3ff647478a8 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -607,7 +607,7 @@ module ParsedInput = | SynTypeConstraint.WhereTyparIsComparable (t, _) -> walkTypar t | SynTypeConstraint.WhereTyparIsEquatable (t, _) -> walkTypar t | SynTypeConstraint.WhereTyparSubtypeOfType (t, ty, _) -> walkTypar t |> Option.orElseWith (fun () -> walkType ty) - | SynTypeConstraint.WhereTyparSupportsMember (ts, sign, _) -> + | SynTypeConstraint.WhereTyparSupportsMember (TypesForTypar ts, sign, _) -> List.tryPick walkType ts |> Option.orElseWith (fun () -> walkMemberSig sign) | SynTypeConstraint.WhereTyparIsEnum (t, ts, _) -> walkTypar t |> Option.orElseWith (fun () -> List.tryPick walkType ts) | SynTypeConstraint.WhereTyparIsDelegate (t, ts, _) -> walkTypar t |> Option.orElseWith (fun () -> List.tryPick walkType ts) @@ -668,7 +668,8 @@ module ParsedInput = | SynType.Fun (argType = t1; returnType = t2) -> walkType t1 |> Option.orElseWith (fun () -> walkType t2) | SynType.WithGlobalConstraints (t, _, _) -> walkType t | SynType.HashConstraint (t, _) -> walkType t - | SynType.MeasureDivide (t1, t2, _) -> walkType t1 |> Option.orElseWith (fun () -> walkType t2) + | SynType.MeasureDivide (t1, t2, _) + | SynType.Or (t1, t2, _, _) -> walkType t1 |> Option.orElseWith (fun () -> walkType t2) | SynType.MeasurePower (t, _, _) -> walkType t | SynType.Paren (t, _) | SynType.SignatureParameter (usedType = t) -> walkType t @@ -838,7 +839,7 @@ module ParsedInput = | SynExpr.DoBang (e, _) -> walkExprWithKind parentKind e - | SynExpr.TraitCall (ts, sign, e, _) -> + | SynExpr.TraitCall (TypesForTypar ts, sign, e, _) -> List.tryPick walkType ts |> Option.orElseWith (fun () -> walkMemberSig sign) |> Option.orElseWith (fun () -> walkExprWithKind parentKind e) @@ -1621,7 +1622,7 @@ module ParsedInput = | SynTypeConstraint.WhereTyparIsDelegate (t, ts, _) -> walkTypar t List.iter walkType ts - | SynTypeConstraint.WhereTyparSupportsMember (ts, sign, _) -> + | SynTypeConstraint.WhereTyparSupportsMember (TypesForTypar ts, sign, _) -> List.iter walkType ts walkMemberSig sign | SynTypeConstraint.WhereSelfConstrained (ty, _) -> walkType ty @@ -1673,7 +1674,8 @@ module ParsedInput = | SynType.Paren (t, _) | SynType.SignatureParameter (usedType = t) -> walkType t | SynType.Fun (argType = t1; returnType = t2) - | SynType.MeasureDivide (t1, t2, _) -> + | SynType.MeasureDivide (t1, t2, _) + | SynType.Or (t1, t2, _, _) -> walkType t1 walkType t2 | SynType.LongIdent ident -> addLongIdentWithDots ident @@ -1820,7 +1822,7 @@ module ParsedInput = walkExpr eAndBang walkExpr e2 - | SynExpr.TraitCall (ts, sign, e, _) -> + | SynExpr.TraitCall (TypesForTypar ts, sign, e, _) -> List.iter walkType ts walkMemberSig sign walkExpr e diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 7ef394a67f0..051bb1e7af8 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -330,7 +330,7 @@ type SynTypeConstraint = | WhereTyparSubtypeOfType of typar: SynTypar * typeName: SynType * range: range - | WhereTyparSupportsMember of typars: SynType list * memberSig: SynMemberSig * range: range + | WhereTyparSupportsMember of typars: SynType * memberSig: SynMemberSig * range: range | WhereTyparIsEnum of typar: SynTypar * typeArgs: SynType list * range: range @@ -441,6 +441,8 @@ type SynType = | SignatureParameter of attributes: SynAttributes * optional: bool * id: Ident option * usedType: SynType * range: range + | Or of lhsType: SynType * rhsType: SynType * range: range * trivia: SynTypeOrTrivia + member x.Range = match x with | SynType.App (range = m) @@ -459,7 +461,8 @@ type SynType = | SynType.MeasureDivide (range = m) | SynType.MeasurePower (range = m) | SynType.Paren (range = m) - | SynType.SignatureParameter (range = m) -> m + | SynType.SignatureParameter (range = m) + | SynType.Or (range = m) -> m | SynType.LongIdent lidwd -> lidwd.Range [] @@ -647,7 +650,7 @@ type SynExpr = | AddressOf of isByref: bool * expr: SynExpr * opRange: range * range: range - | TraitCall of supportTys: SynType list * traitSig: SynMemberSig * argExpr: SynExpr * range: range + | TraitCall of supportTys: SynType * traitSig: SynMemberSig * argExpr: SynExpr * range: range | JoinIn of lhsExpr: SynExpr * lhsRange: range * rhsExpr: SynExpr * range: range diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 8d977a4c027..4ecffe92ef4 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -405,7 +405,7 @@ type SynTypeConstraint = | WhereTyparSubtypeOfType of typar: SynTypar * typeName: SynType * range: range /// F# syntax is ^T: (static member MemberName: ^T * int -> ^T) - | WhereTyparSupportsMember of typars: SynType list * memberSig: SynMemberSig * range: range + | WhereTyparSupportsMember of typars: SynType * memberSig: SynMemberSig * range: range /// F# syntax is 'typar: enum<'UnderlyingType> | WhereTyparIsEnum of typar: SynTypar * typeArgs: SynType list * range: range @@ -518,6 +518,9 @@ type SynType = usedType: SynType * range: range + /// F# syntax: ^a or ^b, used in trait calls + | Or of lhsType: SynType * rhsType: SynType * range: range * trivia: SynTypeOrTrivia + /// Gets the syntax range of this construct member Range: range @@ -817,7 +820,7 @@ type SynExpr = | AddressOf of isByref: bool * expr: SynExpr * opRange: range * range: range /// F# syntax: ((type1 or ... or typeN): (member-dig) expr) - | TraitCall of supportTys: SynType list * traitSig: SynMemberSig * argExpr: SynExpr * range: range + | TraitCall of supportTys: SynType * traitSig: SynMemberSig * argExpr: SynExpr * range: range /// F# syntax: ... in ... /// Computation expressions only, based on JOIN_IN token from lex filter diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index aefc238d10e..fda76bc0e47 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -1082,3 +1082,12 @@ let (|MultiDimensionArrayType|_|) (t: SynType) = else None | _ -> None + +let (|TypesForTypar|) (t: SynType) = + let rec visit continuation t = + match t with + | SynType.Paren (innerT, _) -> visit continuation innerT + | SynType.Or (lhsT, rhsT, _, _) -> visit (fun lhsTs -> [ yield! lhsTs; yield rhsT ] |> continuation) lhsT + | _ -> continuation [ t ] + + visit id t diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi index b78563d4bce..bb72345971e 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi @@ -357,3 +357,5 @@ val desugarGetSetMembers: memberDefns: SynMemberDefns -> SynMemberDefns val getTypeFromTuplePath: path: SynTupleTypeSegment list -> SynType list val (|MultiDimensionArrayType|_|): t: SynType -> (int * SynType * range) option + +val (|TypesForTypar|): t: SynType -> SynType list diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index fa4ebc784c8..7c15170e74f 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -265,3 +265,6 @@ type SynMemberGetSetTrivia = [] type SynArgPatsNamePatPairsTrivia = { ParenRange: range } + +[] +type SynTypeOrTrivia = { OrKeyword: range } diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi index b6f0532d73c..c52cacea7b2 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi @@ -384,3 +384,11 @@ type SynArgPatsNamePatPairsTrivia = /// The syntax range from the beginning of the `(` token till the end of the `)` token. ParenRange: range } + +/// Represents additional information for SynType.Or +[] +type SynTypeOrTrivia = + { + /// The syntax range of the `or` keyword + OrKeyword: range + } diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs index 662081a1f45..02f6fafd05d 100644 --- a/src/Compiler/TypedTree/TypeProviders.fs +++ b/src/Compiler/TypedTree/TypeProviders.fs @@ -415,7 +415,7 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) = member _.ApplyStaticArguments(provider: ITypeProvider, fullTypePathAfterArguments, staticArgs: obj[]) = provider.ApplyStaticArguments(x, fullTypePathAfterArguments, staticArgs) |> ProvidedType.Create ctxt - member _.IsVoid = (typeof.Equals x || (x.Namespace = "System" && x.Name = "Void")) + member _.IsVoid = (Type.op_Equality(x, typeof) || (x.Namespace = "System" && x.Name = "Void")) member _.IsGenericParameter = x.IsGenericParameter diff --git a/src/Compiler/Utilities/sformat.fs b/src/Compiler/Utilities/sformat.fs index 42b13e28ff9..303e2f968b5 100644 --- a/src/Compiler/Utilities/sformat.fs +++ b/src/Compiler/Utilities/sformat.fs @@ -455,9 +455,9 @@ module ReflectUtils = isNamedType (ty1) && if ty1.IsGenericType then ty2.IsGenericType - && (ty1.GetGenericTypeDefinition()).Equals(ty2.GetGenericTypeDefinition()) + && Type.op_Equality (ty1.GetGenericTypeDefinition(), ty2.GetGenericTypeDefinition()) else - ty1.Equals(ty2) + Type.op_Equality (ty1, ty2) let option = typedefof diff --git a/src/Compiler/Utilities/sr.fs b/src/Compiler/Utilities/sr.fs index 245ed9841c2..77552a03b90 100644 --- a/src/Compiler/Utilities/sr.fs +++ b/src/Compiler/Utilities/sr.fs @@ -37,7 +37,7 @@ module internal DiagnosticMessage = let isFunctionType (ty1: System.Type) = isNamedType (ty1) && ty1.IsGenericType - && (ty1.GetGenericTypeDefinition()).Equals(funTyC) + && System.Type.op_Equality (ty1.GetGenericTypeDefinition(), funTyC) let rec destFunTy (ty: System.Type) = if isFunctionType ty then diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 4b5888bf2f4..1dc110accee 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2226,10 +2226,12 @@ typeConstraint: | typar COLON LPAREN classMemberSpfn rparen { let tp = $1 - SynTypeConstraint.WhereTyparSupportsMember([ SynType.Var(tp, tp.Range) ], $4, lhs parseState) } + SynTypeConstraint.WhereTyparSupportsMember(SynType.Var(tp, tp.Range), $4, lhs parseState) } | LPAREN typeAlts rparen COLON LPAREN classMemberSpfn rparen - { SynTypeConstraint.WhereTyparSupportsMember(List.rev($2), $6, lhs parseState) } + { let mParen = rhs2 parseState 1 3 + let t = SynType.Paren($2, mParen) + SynTypeConstraint.WhereTyparSupportsMember(t, $6, lhs parseState) } | typar COLON DELEGATE typeArgsNoHpaDeprecated { let _ltm, _gtm, args, _commas, mWhole = $4 @@ -2254,10 +2256,12 @@ typeConstraint: typeAlts: | typeAlts OR appType - { $3 :: $1 } + { let mOr = rhs parseState 2 + let m = unionRanges $1.Range $3.Range + SynType.Or($1, $3, m, { OrKeyword = mOr }) } | appType - { [$1] } + { $1 } /* The core of a union type definition */ unionTypeRepr: @@ -4485,17 +4489,20 @@ parenExprBody: typars: | typar - { [SynType.Var($1, rhs parseState 1)] } + { SynType.Var($1, rhs parseState 1) } - | LPAREN typarAlts rparen - { List.rev $2 } + | LPAREN typarAlts rparen + { let m = rhs2 parseState 1 3 + SynType.Paren($2, m) } typarAlts: | typarAlts OR appType - {$3 :: $1} + { let mOr = rhs parseState 2 + let m = unionRanges $1.Range $3.Range + SynType.Or($1, $3, m, { OrKeyword = mOr }) } | typar - { [SynType.Var($1, rhs parseState 1)] } + { SynType.Var($1, rhs parseState 1) } braceExpr: | LBRACE braceExprBody rbrace diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 888a4cfe53e..291ad731c7d 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -977,6 +977,11 @@ Tento výraz implicitně převede typ {0} na typ {1}. Přečtěte si téma https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. Vlastnost{0}vyvolaná tímto voláním má více typů podpory. Tato syntaxe volání není pro takové vlastnosti povolená. Pokyny najdete v https://aka.ms/fsharp-srtp. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 6c56fdfa8d5..e58a3276859 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -977,6 +977,11 @@ Dieser Ausdruck konvertiert den Typ "{0}" implizit in den Typ "{1}". Siehe https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. Das Merkmal „{0}“, das von diesem Aufruf aufgerufen wird, weist mehrere Unterstützungstypen auf. Diese Aufrufsyntax ist für solche Merkmale nicht zulässig. Anleitungen finden Sie unter https://aka.ms/fsharp-srtp. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index d7850b578e8..2b6e5826209 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -977,6 +977,11 @@ Esta expresión convierte implícitamente el tipo '{0}' al tipo '{1}'. Consulte https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. El rasgo '{0}' invocado por esta llamada tiene varios tipos de soporte. No se permite esta sintaxis de invocación para estos rasgos. Consulte https://aka.ms/fsharp-srtp para obtener instrucciones. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 24de79e7038..64f38063f4c 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -977,6 +977,11 @@ Cette expression convertit implicitement le type « {0} » en type « {1} ». Voir https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. La caractéristique '{0}' invoquée par cet appel a plusieurs types de prise en charge. Cette syntaxe d’appel n’est pas autorisée pour de telles caractéristiques. Consultez https://aka.ms/fsharp-srtp pour obtenir de l’aide. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index a75b76675e1..35337e16176 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -977,6 +977,11 @@ Questa espressione converte in modo implicito il tipo '{0}' nel tipo '{1}'. Vedere https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. Il tratto '{0}' chiamato da questa chiamata ha più tipi di supporto. Questa sintassi di chiamata non è consentita per tali tratti. Per indicazioni, vedere https://aka.ms/fsharp-srtp. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 63017aee6b7..55a9655cdcd 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -977,6 +977,11 @@ この式は、型 '{0}' を型 '{1}' に暗黙的に変換します。https://aka.ms/fsharp-implicit-convs を参照してください。 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 3d374bfac58..10f359b55f9 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -977,6 +977,11 @@ 이 식은 암시적으로 '{0}' 형식을 '{1}' 형식으로 변환 합니다. https://aka.ms/fsharp-implicit-convs 참조 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. 이 호출에서 호출한 '{0}' 특성에는 여러 지원 유형이 있습니다. 이러한 특성에는 이 호출 구문을 사용할 수 없습니다. 지침은 https://aka.ms/fsharp-srtp를 참조하세요. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 511dc107e84..708a42f3cfc 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -977,6 +977,11 @@ To wyrażenie bezwzględnie konwertuje typ "{0}" na typ "{1}". Zobacz https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. Cecha „{0}” wywołana przez to wywołanie ma wiele typów obsługi. Ta składnia wywołania nie jest dozwolona dla takich cech. Aby uzyskać wskazówki, zobacz https://aka.ms/fsharp-srtp. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index a81a1ddf502..9f7ac0984d3 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -977,6 +977,11 @@ Essa expressão converte implicitamente o tipo '{0}' ao tipo '{1}'. Consulte https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. A característica '{0}' invocada por essa chamada tem vários tipos de suporte. Essa sintaxe de invocação não é permitida para essas características. Confira https://aka.ms/fsharp-srtp para obter as diretrizes. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index e2d9593f02e..65c299291a5 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -977,6 +977,11 @@ Это выражение неявно преобразует тип "{0}" в тип "{1}". См. сведения на странице https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. Признак "{0}", вызываемый этим звонком, имеет несколько типов поддержки. Этот синтаксис вызова не разрешен для таких признаков. См. руководство на https://aka.ms/fsharp-srtp. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 419f79f5b1a..3f06b53012d 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -977,6 +977,11 @@ Bu ifade '{0}' türünü örtülü olarak '{1}' türüne dönüştürür. https://aka.ms/fsharp-implicit-convs adresine bakın. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. Bu çağrı tarafından çağrılan '{0}' özelliği birden çok destek türüne sahiptir. Bu tür nitelikler için bu çağrı söz dizimine izin verilmez. Rehber için bkz. https://aka.ms/fsharp-srtp. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index db25dca065c..6df32617295 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -977,6 +977,11 @@ 此表达式将类型“{0}”隐式转换为类型“{1}”。请参阅 https://aka.ms/fsharp-implicit-convs。 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. 此调用过程调用的特征 "{0}" 具有多种支持类型。此类特征不允许使用此调用语法。有关指南,请参阅 https://aka.ms/fsharp-srtp。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index e367a57cd31..1b5c55a5c74 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -977,6 +977,11 @@ 此運算式將類型 '{0}' 隱含轉換為類型 '{1}'。請參閱 https://aka.ms/fsharp-implicit-convs。 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/FSharp.Build/FSharpEmbedResourceText.fs b/src/FSharp.Build/FSharpEmbedResourceText.fs index 77002aa4f54..d8a3848ba27 100644 --- a/src/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/FSharp.Build/FSharpEmbedResourceText.fs @@ -289,7 +289,7 @@ open Printf static let isNamedType(ty:System.Type) = not (ty.IsArray || ty.IsByRef || ty.IsPointer) static let isFunctionType (ty1:System.Type) = - isNamedType(ty1) && getTypeInfo(ty1).IsGenericType && (ty1.GetGenericTypeDefinition()).Equals(funTyC) + isNamedType(ty1) && getTypeInfo(ty1).IsGenericType && System.Type.op_Equality(ty1.GetGenericTypeDefinition(), funTyC) static let rec destFunTy (ty:System.Type) = if isFunctionType ty then diff --git a/src/FSharp.Core/Linq.fs b/src/FSharp.Core/Linq.fs index 33a1dd18265..6b62eccb93e 100644 --- a/src/FSharp.Core/Linq.fs +++ b/src/FSharp.Core/Linq.fs @@ -44,9 +44,9 @@ module LeafExpressionConverter = let equivHeadTypes (ty1:Type) (ty2:Type) = isNamedType(ty1) && if ty1.IsGenericType then - ty2.IsGenericType && (ty1.GetGenericTypeDefinition()).Equals(ty2.GetGenericTypeDefinition()) + ty2.IsGenericType && Type.op_Equality(ty1.GetGenericTypeDefinition(), ty2.GetGenericTypeDefinition()) else - ty1.Equals(ty2) + Type.op_Equality(ty1, ty2) let isFunctionType typ = equivHeadTypes typ (typeof<(int -> int)>) @@ -458,7 +458,7 @@ module LeafExpressionConverter = let converted = ConvExprToLinqInContext env x // Most of conversion scenarios in C# are covered by Expression.Convert - if x.Type.Equals toTy then converted // source and target types match - do nothing + if Type.op_Equality(x.Type, toTy) then converted // source and target types match - do nothing elif not (x.Type.IsValueType || toTy.IsValueType) && toTy.IsAssignableFrom x.Type then converted // converting reference type to supertype - do nothing else Expression.Convert(converted, toTy) |> asExpr // emit Expression.Convert @@ -522,7 +522,10 @@ module LeafExpressionConverter = Expression.New(ctor, argsR, [| for p in props -> (p :> MemberInfo) |]) |> asExpr // Do the same thing as C# compiler for string addition - | PlusQ (_, GenericArgs [|ty1; ty2; ty3|], [x1; x2]) when ty1 = typeof && ty2 = typeof && ty3 = typeof -> + | PlusQ (_, GenericArgs [|ty1; ty2; ty3|], [x1; x2]) + when Type.op_Equality(ty1, typeof) && + Type.op_Equality(ty2, typeof) && + Type.op_Equality(ty3, typeof) -> Expression.Add(ConvExprToLinqInContext env x1, ConvExprToLinqInContext env x2, StringConcat) |> asExpr // LanguagePrimitives.PhysicalEquality's generic constraint of both sides being the same reference type is already sufficient for Linq Expressions' requirements diff --git a/src/FSharp.Core/Query.fs b/src/FSharp.Core/Query.fs index ae11d3835a1..28a460619f6 100644 --- a/src/FSharp.Core/Query.fs +++ b/src/FSharp.Core/Query.fs @@ -440,7 +440,7 @@ module Query = let IsIEnumerableTy (ty: System.Type) = ty.IsGenericType && ty.GetGenericTypeDefinition() = IEnumerableTypeDef // Check a tag type on QuerySource is IQueryable - let qTyIsIQueryable (ty : System.Type) = not (ty.Equals(typeof)) + let qTyIsIQueryable (ty : System.Type) = not (Type.op_Equality(ty, typeof)) let FuncExprToDelegateExpr (srcTy, targetTy, v, body) = Expr.NewDelegate (Linq.Expressions.Expression.GetFuncType [| srcTy; targetTy |], [v], body) @@ -588,21 +588,21 @@ module Query = let selector = MakeImplicitExpressionConversion selector let maker = match resTyNoNullable with - | ty when ty = typeof -> mq_double - | ty when ty = typeof -> mq_single - | ty when ty = typeof -> mq_decimal - | ty when ty = typeof -> mq_int32 - | ty when ty = typeof -> mq_int64 + | ty when Type.op_Equality(ty, typeof) -> mq_double + | ty when Type.op_Equality(ty, typeof) -> mq_single + | ty when Type.op_Equality(ty, typeof) -> mq_decimal + | ty when Type.op_Equality(ty, typeof) -> mq_int32 + | ty when Type.op_Equality(ty, typeof) -> mq_int64 | _ -> failDueToUnsupportedInputTypeInSumByOrAverageBy() maker ([srcItemTy], [src; selector]) else // Try to dynamically invoke a LINQ method if one exists, since these may be optimized over arrays etc. match resTyNoNullable with - | ty when ty = typeof -> me_double ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_single ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_decimal ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_int32 ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_int64 ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_double ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_single ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_decimal ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_int32 ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_int64 ([srcItemTy], [src; selector]) | _ -> // The F# implementation needs a QuerySource as a parameter. let qTy = typeof @@ -617,22 +617,22 @@ module Query = let selector = FuncExprToLinqFunc2Expression (srcItemTy, resTy, v, res) let caller = match resTyNoNullable with - | ty when ty = typeof -> cq_double - | ty when ty = typeof -> cq_single - | ty when ty = typeof -> cq_decimal - | ty when ty = typeof -> cq_int32 - | ty when ty = typeof -> cq_int64 + | ty when Type.op_Equality(ty, typeof) -> cq_double + | ty when Type.op_Equality(ty, typeof) -> cq_single + | ty when Type.op_Equality(ty, typeof) -> cq_decimal + | ty when Type.op_Equality(ty, typeof) -> cq_int32 + | ty when Type.op_Equality(ty, typeof) -> cq_int64 | _ -> failDueToUnsupportedInputTypeInSumByOrAverageBy() caller ([srcItemTy], [src; box selector]) : obj else // Try to dynamically invoke a LINQ method if one exists, since these may be optimized over arrays etc. let linqMethOpt = match resTyNoNullable with - | ty when ty = typeof -> Some ce_double - | ty when ty = typeof -> Some ce_single - | ty when ty = typeof -> Some ce_decimal - | ty when ty = typeof -> Some ce_int32 - | ty when ty = typeof -> Some ce_int64 + | ty when Type.op_Equality(ty, typeof) -> Some ce_double + | ty when Type.op_Equality(ty, typeof) -> Some ce_single + | ty when Type.op_Equality(ty, typeof) -> Some ce_decimal + | ty when Type.op_Equality(ty, typeof) -> Some ce_int32 + | ty when Type.op_Equality(ty, typeof) -> Some ce_int64 | _ -> None match linqMethOpt with | Some ce -> @@ -1617,7 +1617,7 @@ module Query = let IQueryableTySpec = MakeIQueryableTy tyArg // if result type of nested query is derived from IQueryable but not IQueryable itself (i.e. IOrderedQueryable) // then add coercion to IQueryable so result type will match expected signature of QuerySource.Run - if (IQueryableTySpec.IsAssignableFrom replNestedQuery.Type) && not (IQueryableTySpec.Equals replNestedQuery.Type) then + if (IQueryableTySpec.IsAssignableFrom replNestedQuery.Type) && not (Type.op_Equality(IQueryableTySpec, replNestedQuery.Type)) then Expr.Coerce (replNestedQuery, IQueryableTySpec) else replNestedQuery diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 0489528c062..85befedcb4b 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -606,7 +606,7 @@ namespace Microsoft.FSharp.Core then TypeNullnessSemantics_NullNever else if not (typeof<'T>.IsDefined(typeof, false)) then TypeNullnessSemantics_NullIsExtraValue - elif typeof<'T>.Equals(typeof) then + elif Type.op_Equality (typeof<'T>, typeof) then TypeNullnessSemantics_NullTrueValue elif typeof.IsAssignableFrom(typeof<'T>) then TypeNullnessSemantics_NullIsExtraValue @@ -2098,22 +2098,22 @@ namespace Microsoft.FSharp.Core type FastGenericEqualityComparerTable<'T>() = static let f : IEqualityComparer<'T> = match typeof<'T> with - | ty when ty.Equals(typeof) -> unboxPrim (box BoolIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box ByteIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Int32IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt32IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box CharIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box SByteIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Int16IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Int64IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box IntPtrIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt16IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt64IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UIntPtrIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box FloatIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Float32IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box DecimalIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box StringIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box BoolIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box ByteIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int32IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt32IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box CharIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box SByteIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int16IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int64IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box IntPtrIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt16IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt64IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UIntPtrIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box FloatIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Float32IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box DecimalIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box StringIEquality) | _ -> MakeGenericEqualityComparer<'T>() static member Function : IEqualityComparer<'T> = f @@ -2193,42 +2193,42 @@ namespace Microsoft.FSharp.Core // REVIEW: in a future version we could extend this to include additional types static let fCanBeNull : IComparer<'T> = match typeof<'T> with - | ty when ty.Equals(typeof) -> unboxPrim (box IntPtrComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UIntPtrComparer) - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> unboxPrim (box StringComparer) - | ty when ty.Equals(typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box IntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UIntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box StringComparer) + | ty when Type.op_Equality(ty, typeof) -> null | _ -> MakeGenericComparer<'T>() static let f : IComparer<'T> = match typeof<'T> with - | ty when ty.Equals(typeof) -> unboxPrim (box ByteComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box CharComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box SByteComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Int16Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Int32Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Int64Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box IntPtrComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt16Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt32Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt64Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UIntPtrComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box FloatComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Float32Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box DecimalComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box StringComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box BoolComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box ByteComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box CharComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box SByteComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int16Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int32Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int64Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box IntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt16Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt32Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt64Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UIntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box FloatComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Float32Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box DecimalComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box StringComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box BoolComparer) | _ -> // Review: There are situations where we should be able // to return Generic.Comparer<'T>.Default here. @@ -2450,46 +2450,46 @@ namespace Microsoft.FSharp.Core type GenericZeroDynamicImplTable<'T>() = static let result : 'T = // The dynamic implementation - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<'T> (box 0y) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0s) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0L) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0n) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0uy) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0us) - elif aty.Equals(typeof) then unboxPrim<'T> (box '\000') - elif aty.Equals(typeof) then unboxPrim<'T> (box 0u) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0UL) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0un) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0M) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0.0) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0.0f) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0y) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0s) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0L) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0n) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0uy) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0us) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box '\000') + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0u) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0UL) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0un) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0M) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0.0) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0.0f) else - let pinfo = aty.GetProperty("Zero") + let pinfo = ty.GetProperty("Zero") unboxPrim<'T> (pinfo.GetValue(null,null)) static member Result : 'T = result type GenericOneDynamicImplTable<'T>() = static let result : 'T = // The dynamic implementation - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<'T> (box 1y) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1s) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1L) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1n) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1uy) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1us) - elif aty.Equals(typeof) then unboxPrim<'T> (box '\001') - elif aty.Equals(typeof) then unboxPrim<'T> (box 1u) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1UL) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1un) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1M) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1.0) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1.0f) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1y) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1s) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1L) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1n) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1uy) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1us) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box '\001') + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1u) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1UL) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1un) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1M) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1.0) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1.0f) else - let pinfo = aty.GetProperty("One") + let pinfo = ty.GetProperty("One") unboxPrim<'T> (pinfo.GetValue(null,null)) static member Result : 'T = result @@ -2604,7 +2604,7 @@ namespace Microsoft.FSharp.Core let ameth = aty.GetSingleStaticMethodByTypes(opName, [| aty; bty |]) let bmeth = - if aty.Equals(bty) then null else + if Type.op_Equality(aty, bty) then null else bty.GetSingleStaticMethodByTypes(opName, [| aty; bty |]) match ameth, bmeth with | null, null -> raise (NotSupportedException (SR.GetString(SR.dyInvOpAddCoerce))) @@ -4175,7 +4175,7 @@ namespace Microsoft.FSharp.Core let Failure message = new Exception(message) [] - let (|Failure|_|) (error: exn) = if error.GetType().Equals(typeof) then Some error.Message else None + let (|Failure|_|) (error: exn) = if Type.op_Equality(error.GetType(), typeof) then Some error.Message else None let inline (<) x y = GenericLessThan x y @@ -5002,7 +5002,7 @@ namespace Microsoft.FSharp.Core when ^T : string = not (# "clt" (String.CompareOrdinal((# "" x : string #),(# "" y : string #))) 0 : bool #) when ^T : ^T = ((^T or ^U): (static member (>=) : ^T * ^U -> bool) (x,y)) - /// Static greater-than-or-equal with static optimizations for some well-known cases. + /// Static equal with static optimizations for some well-known cases. let inline (=) (x:^T) (y:^T) = EqualityDynamic<(^T), (^T), bool> x y when ^T : bool = (# "ceq" x y : bool #) @@ -5023,6 +5023,7 @@ namespace Microsoft.FSharp.Core when ^T : decimal = Decimal.op_Equality((# "" x:decimal #), (# "" y:decimal #)) when ^T : ^T = (^T : (static member (=) : ^T * ^T -> bool) (x,y)) + /// Static unequal with static optimizations for some well-known cases. let inline (<>) (x:^T) (y:^T) = InequalityDynamic<(^T), (^T), bool> x y when ^T : bool = not (# "ceq" x y : bool #) @@ -6472,181 +6473,181 @@ namespace Microsoft.FSharp.Core type AbsDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:sbyte) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int16) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int32) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int64) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:nativeint) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:decimal) -> absImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:sbyte) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int16) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int32) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int64) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:nativeint) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:decimal) -> absImpl x) else UnaryDynamicImpl "Abs" static member Result : ('T -> 'T) = result type AcosDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> acosImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> acosImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> acosImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> acosImpl x) else UnaryDynamicImpl "Acos" static member Result : ('T -> 'T) = result type AsinDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> asinImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> asinImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> asinImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> asinImpl x) else UnaryDynamicImpl "Asin" static member Result : ('T -> 'T) = result type AtanDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> atanImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> atanImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> atanImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> atanImpl x) else UnaryDynamicImpl "Atan" static member Result : ('T -> 'T) = result type Atan2DynamicImplTable<'T,'U>() = static let result : ('T -> 'T -> 'U) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) (y:float) -> atan2Impl x y) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> atan2Impl x y) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) (y:float) -> atan2Impl x y) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> atan2Impl x y) else BinaryDynamicImpl "Atan2" static member Result : ('T -> 'T -> 'U) = result type CeilingDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> ceilImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> ceilImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> ceilImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> ceilImpl x) else UnaryDynamicImpl "Ceiling" static member Result : ('T -> 'T) = result type ExpDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> expImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> expImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> expImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> expImpl x) else UnaryDynamicImpl "Exp" static member Result : ('T -> 'T) = result type FloorDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> floorImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> floorImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> floorImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> floorImpl x) else UnaryDynamicImpl "Floor" static member Result : ('T -> 'T) = result type TruncateDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> truncateImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> truncateImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> truncateImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> truncateImpl x) else UnaryDynamicImpl "Truncate" static member Result : ('T -> 'T) = result type RoundDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> roundImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> roundImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> roundImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> roundImpl x) else UnaryDynamicImpl "Round" static member Result : ('T -> 'T) = result type SignDynamicImplTable<'T>() = static let result : ('T -> int) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:nativeint) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:decimal) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int16) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int32) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int64) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:sbyte) -> signImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:nativeint) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:decimal) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int16) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int32) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int64) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:sbyte) -> signImpl x) else UnaryDynamicImpl "Sign" static member Result : ('T -> int) = result type LogDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> logImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> logImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> logImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> logImpl x) else UnaryDynamicImpl "Log" static member Result : ('T -> 'T) = result type Log10DynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> log10Impl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> log10Impl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> log10Impl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> log10Impl x) else UnaryDynamicImpl "Log10" static member Result : ('T -> 'T) = result type SqrtDynamicImplTable<'T,'U>() = static let result : ('T -> 'U) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> sqrtImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> sqrtImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> sqrtImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> sqrtImpl x) else UnaryDynamicImpl "Sqrt" static member Result : ('T -> 'U) = result type CosDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> cosImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> cosImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> cosImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> cosImpl x) else UnaryDynamicImpl "Cos" static member Result : ('T -> 'T) = result type CoshDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> coshImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> coshImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> coshImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> coshImpl x) else UnaryDynamicImpl "Cosh" static member Result : ('T -> 'T) = result type SinDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> sinImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> sinImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> sinImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> sinImpl x) else UnaryDynamicImpl "Sin" static member Result : ('T -> 'T) = result type SinhDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> sinhImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> sinhImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> sinhImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> sinhImpl x) else UnaryDynamicImpl "Sinh" static member Result : ('T -> 'T) = result type TanDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> tanImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> tanImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> tanImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> tanImpl x) else UnaryDynamicImpl "Tan" static member Result : ('T -> 'T) = result type TanhDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> tanhImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> tanhImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> tanhImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> tanhImpl x) else UnaryDynamicImpl "Tanh" static member Result : ('T -> 'T) = result type PowDynamicImplTable<'T,'U>() = static let result : ('T -> 'U -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) (y:float) -> powImpl x y) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> powImpl x y) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) (y:float) -> powImpl x y) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> powImpl x y) else BinaryDynamicImpl "Pow" static member Result : ('T -> 'U -> 'T) = result diff --git a/src/FSharp.Core/quotations.fs b/src/FSharp.Core/quotations.fs index c3c7317e522..20f2e8ca06b 100644 --- a/src/FSharp.Core/quotations.fs +++ b/src/FSharp.Core/quotations.fs @@ -1403,7 +1403,7 @@ module Patterns = | Ambiguous of 'R let typeEquals (ty1: Type) (ty2: Type) = - ty1.Equals ty2 + Type.op_Equality (ty1, ty2) let typesEqual (tys1: Type list) (tys2: Type list) = (tys1.Length = tys2.Length) && List.forall2 typeEquals tys1 tys2 diff --git a/src/FSharp.Core/reflect.fs b/src/FSharp.Core/reflect.fs index 76dbb87c490..e9522f68c99 100644 --- a/src/FSharp.Core/reflect.fs +++ b/src/FSharp.Core/reflect.fs @@ -43,9 +43,9 @@ module internal Impl = isNamedType ty1 && if ty1.IsGenericType then ty2.IsGenericType - && (ty1.GetGenericTypeDefinition()).Equals(ty2.GetGenericTypeDefinition()) + && Type.op_Equality (ty1.GetGenericTypeDefinition(), ty2.GetGenericTypeDefinition()) else - ty1.Equals ty2 + Type.op_Equality (ty1, ty2) let func = typedefof<(obj -> obj)> diff --git a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs index 294cf2df55d..0740f5aa753 100644 --- a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs +++ b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs @@ -132,7 +132,7 @@ module FSharpDependencyManager = | Some "timeout", None -> raise (ArgumentException(SR.missingTimeoutValue ())) | Some "timeout", value -> match value with - | Some v when v.GetType() = typeof -> + | Some v when Type.op_Equality (v.GetType(), typeof) -> let parsed, value = Int32.TryParse(v) if parsed && value >= 0 then diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected index 9045f24ab29..d7f8a490d26 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected @@ -6744,10 +6744,10 @@ FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynExpr argExpr FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynExpr get_argExpr() FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynMemberSig get_traitSig() FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynMemberSig traitSig +FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynType get_supportTys() +FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynType supportTys FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Text.Range range -FSharp.Compiler.Syntax.SynExpr+TraitCall: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_supportTys() -FSharp.Compiler.Syntax.SynExpr+TraitCall: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] supportTys FSharp.Compiler.Syntax.SynExpr+TryFinally: FSharp.Compiler.Syntax.DebugPointAtFinally finallyDebugPoint FSharp.Compiler.Syntax.SynExpr+TryFinally: FSharp.Compiler.Syntax.DebugPointAtFinally get_finallyDebugPoint() FSharp.Compiler.Syntax.SynExpr+TryFinally: FSharp.Compiler.Syntax.DebugPointAtTry get_tryDebugPoint() @@ -7030,7 +7030,7 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewRecord(Microso FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSequential(FSharp.Compiler.Syntax.DebugPointAtSequential, Boolean, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSequentialOrImplicitYield(FSharp.Compiler.Syntax.DebugPointAtSequential, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTraitCall(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTraitCall(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTryFinally(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.DebugPointAtTry, FSharp.Compiler.Syntax.DebugPointAtFinally, FSharp.Compiler.SyntaxTrivia.SynExprTryFinallyTrivia) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTryWith(FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynMatchClause], FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.DebugPointAtTry, FSharp.Compiler.Syntax.DebugPointAtWith, FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTuple(Boolean, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynExpr], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) @@ -8512,6 +8512,14 @@ FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynType base FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynType get_baseMeasure() FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType get_lhsType() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType get_rhsType() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType lhsType +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType rhsType +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia get_trivia() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia trivia +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Paren: FSharp.Compiler.Syntax.SynType get_innerType() FSharp.Compiler.Syntax.SynType+Paren: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+Paren: FSharp.Compiler.Text.Range get_range() @@ -8550,6 +8558,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentApp FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasureDivide FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasurePower +FSharp.Compiler.Syntax.SynType+Tags: Int32 Or FSharp.Compiler.Syntax.SynType+Tags: Int32 Paren FSharp.Compiler.Syntax.SynType+Tags: Int32 SignatureParameter FSharp.Compiler.Syntax.SynType+Tags: Int32 StaticConstant @@ -8584,6 +8593,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentApp FSharp.Compiler.Syntax.SynType: Boolean IsMeasureDivide FSharp.Compiler.Syntax.SynType: Boolean IsMeasurePower +FSharp.Compiler.Syntax.SynType: Boolean IsOr FSharp.Compiler.Syntax.SynType: Boolean IsParen FSharp.Compiler.Syntax.SynType: Boolean IsSignatureParameter FSharp.Compiler.Syntax.SynType: Boolean IsStaticConstant @@ -8602,6 +8612,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentApp() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasureDivide() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasurePower() +FSharp.Compiler.Syntax.SynType: Boolean get_IsOr() FSharp.Compiler.Syntax.SynType: Boolean get_IsParen() FSharp.Compiler.Syntax.SynType: Boolean get_IsSignatureParameter() FSharp.Compiler.Syntax.SynType: Boolean get_IsStaticConstant() @@ -8620,6 +8631,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSha FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasureDivide(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewOr(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewParen(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewSignatureParameter(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewStaticConstant(FSharp.Compiler.Syntax.SynConst, FSharp.Compiler.Text.Range) @@ -8638,6 +8650,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdent FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdentApp FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+MeasureDivide FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+MeasurePower +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Or FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Paren FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+SignatureParameter FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+StaticConstant @@ -8715,10 +8728,10 @@ FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSubtypeOfType: FSharp.Compile FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSubtypeOfType: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynMemberSig get_memberSig() FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynMemberSig memberSig +FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynType get_typars() +FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynType typars FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Text.Range range -FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_typars() -FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] typars FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Syntax.SynTypar get_typar() FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Syntax.SynTypar typar FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Text.Range get_range() @@ -8757,7 +8770,7 @@ FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstrai FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparIsUnmanaged(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparIsValueType(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSubtypeOfType(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsMember(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsMember(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsNull(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+Tags FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained @@ -9594,6 +9607,11 @@ FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range ArrowR FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range get_ArrowRange() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range OrKeyword +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range get_OrKeyword() +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] BarRange FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_BarRange() diff --git a/tests/service/SyntaxTreeTests/SynTypeTests.fs b/tests/service/SyntaxTreeTests/SynTypeTests.fs index 1ab5ed12e94..7f18521a995 100644 --- a/tests/service/SyntaxTreeTests/SynTypeTests.fs +++ b/tests/service/SyntaxTreeTests/SynTypeTests.fs @@ -49,3 +49,159 @@ type T = ])) -> assertRange (3, 14) (3, 56) mTuple | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.Or inside SynExpr.TraitCall`` () = + let parseResults = + getParseResults + """ +let inline (!!) (x: ^a) : ^b = ((^a or ^b): (static member op_Implicit: ^a -> ^b) x) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(expr = + SynExpr.Typed(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Paren( + SynType.Or( + SynType.Var(range = mVar1), + SynType.Var(range = mVar2), + mOrType, + { OrKeyword = mOrWord }), + mParen)) + ))) + ]) ]) ])) -> + assertRange (2, 33) (2, 35) mVar1 + assertRange (2, 36) (2, 38) mOrWord + assertRange (2, 39) (2, 41) mVar2 + assertRange (2, 33) (2, 41) mOrType + assertRange (2, 32) (2, 42) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.Or inside SynTypeConstraint.WhereTyparSupportsMember`` () = + let parseResults = + getParseResults + """ +let inline f_StaticMethod<'T1, 'T2 when ('T1 or 'T2) : (static member StaticMethod: int -> int) >() : int = + () + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(headPat = + SynPat.LongIdent(typarDecls = Some (SynValTyparDecls(typars = Some (SynTyparDecls.PostfixList(constraints = [ + SynTypeConstraint.WhereTyparSupportsMember(typars = SynType.Paren( + SynType.Or( + SynType.Var(range = mVar1), + SynType.Var(range = mVar2), + mOrType, + { OrKeyword = mOrWord }), + mParen + )) + ])))))) + ]) ]) ])) -> + assertRange (2, 41) (2, 44) mVar1 + assertRange (2, 45) (2, 47) mOrWord + assertRange (2, 48) (2, 51) mVar2 + assertRange (2, 41) (2, 51) mOrType + assertRange (2, 40) (2, 52) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``Nested SynType.Or inside SynExpr.TraitCall`` () = + let parseResults = + getParseResults + """ +let inline (!!) (x: ^a * ^b) : ^c = ((^a or ^b or ^c): (static member op_Implicit: ^a * ^b -> ^c) x) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(expr = + SynExpr.Typed(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Paren( + SynType.Or( + SynType.Or( + SynType.Var(range = mVarA), + SynType.Var(range = mVarB), + mOrType1, + { OrKeyword = mOrWord1 } + ), + SynType.Var(range = mVarC), + mOrType2, + { OrKeyword = mOrWord2 }), + mParen)) + ))) + ]) ]) ])) -> + assertRange (2, 38) (2, 40) mVarA + assertRange (2, 41) (2, 43) mOrWord1 + assertRange (2, 44) (2, 46) mVarB + assertRange (2, 38) (2, 46) mOrType1 + assertRange (2, 47) (2, 49) mOrWord2 + assertRange (2, 50) (2, 52) mVarC + assertRange (2, 38) (2, 52) mOrType2 + assertRange (2, 37) (2, 53) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``Single SynType inside SynExpr.TraitCall`` () = + let parseResults = + getParseResults + """ +type X = + static member inline replace< ^a, ^b, ^c when ^b: (static member replace: ^a * ^b -> ^c)>(a: ^a, f: ^b) = + (^b : (static member replace: ^a * ^b -> ^c) (a, f)) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.Member(memberDefn = + SynBinding(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Var(range = mVar)) + ))) + ])) + ]) ]) ])) -> + assertRange (4, 9) (4, 11) mVar + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.Or with appType on the right hand side`` () = + let parseResults = + getParseResults + """ +let inline f (x: 'T) = ((^T or int) : (static member A: int) ()) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Paren( + SynType.Or( + SynType.Var(range = mVar), + (SynType.LongIdent _ as appType), + mOrType, + { OrKeyword = mOrWord }), + mParen)) + )) + ]) ]) ])) -> + assertRange (2, 25) (2,27) mVar + assertRange (2, 28) (2, 30) mOrWord + assertRange (2, 31) (2, 34) appType.Range + assertRange (2,25) (2, 34) mOrType + assertRange (2,24) (2, 35) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" diff --git a/tests/service/data/TestTP/ProvidedTypes.fs b/tests/service/data/TestTP/ProvidedTypes.fs index c13961cbc27..4e7a7604c6b 100644 --- a/tests/service/data/TestTP/ProvidedTypes.fs +++ b/tests/service/data/TestTP/ProvidedTypes.fs @@ -76,7 +76,7 @@ module Utils = /// General implementation of .Equals(Type) logic for System.Type over symbol types. You can use this with other types too. let rec eqTypes (ty1: Type) (ty2: Type) = if Object.ReferenceEquals(ty1, ty2) then true - elif ty1.IsGenericTypeDefinition then ty2.IsGenericTypeDefinition && ty1.Equals(ty2) + elif ty1.IsGenericTypeDefinition then ty2.IsGenericTypeDefinition && Type.op_Equality(ty1, ty2) elif ty1.IsGenericType then ty2.IsGenericType && not ty2.IsGenericTypeDefinition && eqTypes (ty1.GetGenericTypeDefinition()) (ty2.GetGenericTypeDefinition()) && lengthsEqAndForall2 (ty1.GetGenericArguments()) (ty2.GetGenericArguments()) eqTypes elif ty1.IsArray then ty2.IsArray && ty1.GetArrayRank() = ty2.GetArrayRank() && eqTypes (ty1.GetElementType()) (ty2.GetElementType()) elif ty1.IsPointer then ty2.IsPointer && eqTypes (ty1.GetElementType()) (ty2.GetElementType())