diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 332cea09879..06dffcaa76b 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -4298,6 +4298,9 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn | SynType.LongIdent synLongId -> TcLongIdentType kindOpt cenv newOk checkConstraints occ iwsam env tpenv synLongId + | SynType.LongIdentModule (synLongId, m) -> + TcLongIdentModule cenv checkConstraints occ env tpenv synLongId m + | MultiDimensionArrayType (rank, elemTy, m) -> TcElementType cenv newOk checkConstraints occ env tpenv rank elemTy m @@ -4366,6 +4369,22 @@ and CheckIWSAM (cenv: cenv) (env: TcEnv) checkConstraints iwsam m tcref = if meths |> List.exists (fun meth -> not meth.IsInstance && meth.IsDispatchSlot && not meth.IsExtensionMember) then warning(Error(FSComp.SR.tcUsingInterfaceWithStaticAbstractMethodAsType(tcref.DisplayNameWithStaticParametersAndUnderscoreTypars), m)) +and TcLongIdentModule (cenv: cenv) checkConstraints occ (env: TcEnv) tpenv synLongId mAll = + if occ = ItemOccurence.UseInTypeAnnotation then + error(Error(FSComp.SR.tcModuleUsedInTypeAnnotation(), mAll)) + + let (SynLongIdent (tc, _, _)) = synLongId + let id, rest = List.headAndTail tc + let mIdent = synLongId.Range + + let results = + ResolveLongIdentAsModule cenv.tcSink cenv.amap mIdent true OpenQualified env.NameEnv env.eAccessRights id rest + |> ForceRaise + + match results with + | [] -> failwith "unreachable" // handled in ResolveLongIdentAsModule above + | (_, tcref, _) :: _ -> TcTypeApp cenv NoNewTypars checkConstraints occ env tpenv mAll tcref [] [] + and TcLongIdentType kindOpt (cenv: cenv) newOk checkConstraints occ iwsam env tpenv synLongId = let (SynLongIdent(tc, _, _)) = synLongId let m = synLongId.Range @@ -5722,7 +5741,7 @@ and TcExprMatchLambda (cenv: cenv) overallTy env tpenv (isExnMatch, mArg, clause overallExpr, tpenv and TcExprTypeAnnotated (cenv: cenv) overallTy env tpenv (synBodyExpr, synType, m) = - let tgtTy, tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv synType + let tgtTy, tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInTypeAnnotation WarnOnIWSAM.Yes env tpenv synType UnifyOverallType cenv env m overallTy tgtTy let bodyExpr, tpenv = TcExpr cenv (MustConvertTo (false, tgtTy)) env tpenv synBodyExpr let bodyExpr2 = TcAdjustExprForTypeDirectedConversions cenv overallTy tgtTy env m bodyExpr @@ -7992,7 +8011,7 @@ and TcNameOfExpr (cenv: cenv) env tpenv (synArg: SynExpr) = // expr : type" allowed with no subsequent qualifications | SynExpr.Typed (synBodyExpr, synType, _) when delayed.IsEmpty && overallTyOpt.IsNone -> - let tgtTy, _tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv synType + let tgtTy, _tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInTypeAnnotation WarnOnIWSAM.Yes env tpenv synType check (Some (MustEqual tgtTy)) resultOpt synBodyExpr delayed | _ -> @@ -11319,7 +11338,7 @@ and AnalyzeRecursiveDecl match pat with | SynPat.FromParseError(innerPat, _) -> analyzeRecursiveDeclPat tpenv innerPat | SynPat.Typed(innerPat, tgtTy, _) -> - let tgtTyR, tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes envinner tpenv tgtTy + let tgtTyR, tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInTypeAnnotation WarnOnIWSAM.Yes envinner tpenv tgtTy UnifyTypes cenv envinner mBinding ty tgtTyR analyzeRecursiveDeclPat tpenv innerPat | SynPat.Attrib(_innerPat, _attribs, m) -> diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 88998544d52..4569d6eead6 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -97,7 +97,7 @@ and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p = id.idText, patEnvR | SynSimplePat.Typed (p, cty, m) -> - let ctyR, tpenv = TcTypeAndRecover cenv NewTyparsOK checkConstraints ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv cty + let ctyR, tpenv = TcTypeAndRecover cenv NewTyparsOK checkConstraints ItemOccurence.UseInTypeAnnotation WarnOnIWSAM.Yes env tpenv cty match p with // Optional arguments on members @@ -278,7 +278,7 @@ and TcPat warnOnUpper (cenv: cenv) env valReprInfo vFlags (patEnv: TcPatLinearEn | SynPat.Typed (p, cty, m) -> let (TcPatLinearEnv(tpenv, names, takenNames)) = patEnv - let ctyR, tpenvR = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv cty + let ctyR, tpenvR = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInTypeAnnotation WarnOnIWSAM.Yes env tpenv cty UnifyTypes cenv env m ty ctyR let patEnvR = TcPatLinearEnv(tpenvR, names, takenNames) TcPat warnOnUpper cenv env valReprInfo vFlags patEnvR ty p diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 2110af9fd08..25e7983c9ed 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -1717,8 +1717,10 @@ type ItemOccurence = | Binding /// This is a usage of the item | Use - /// This is a usage of a type name in a type + /// This is a usage of a type name in a type, other than an annotation | UseInType + /// This is a usage of a type name in a type annotation + | UseInTypeAnnotation /// This is a usage of a type name in an attribute | UseInAttribute /// Inside pattern matching @@ -2460,6 +2462,59 @@ let rec ResolveLongIdentAsModuleOrNamespace sink (atMostOne: ResultCollectionSet else raze (namespaceNotFound.Force()) +/// Perform name resolution for an identifier which must resolve to be a module. +let rec ResolveLongIdentAsModule sink amap m first fullyQualified (nenv: NameResolutionEnv) ad (id: Ident) rest = + if first && id.idText = MangledGlobalName then + match rest with + | [] -> + error (Error(FSComp.SR.nrGlobalUsedOnlyAsFirstName(), id.idRange)) + | id2 :: rest2 -> + ResolveLongIdentAsModule sink amap m false FullyQualified nenv ad id2 rest2 + else + let notFound (id: Ident) (rest: Ident list) depth = + let message = + // "undefined module" when the last bit is not a known module - `typeof`, `typeof` + if rest.IsEmpty then + FSComp.SR.undefinedNameModule + // "undefined namespace or module" otherwise - `typeof` + else + FSComp.SR.undefinedNameNamespaceOrModule + + UndefinedName (depth, message, id, NoSuggestions) |> Exception + + let notifyNameResolution (modref: ModuleOrNamespaceRef) m = + let item = Item.ModuleOrNamespaces [modref] + CallNameResolutionSink sink (m, nenv, item, emptyTyparInst, ItemOccurence.Use, ad) + + match (nenv.ModulesAndNamespaces fullyQualified).TryGetValue id.idText with + | true, modrefs -> + // Look through the sub-namespaces and/or modules + let rec look depth (modref: ModuleOrNamespaceRef) (lid: Ident list) = + let mty = modref.ModuleOrNamespaceType + match lid with + | [] when modref.IsModule -> success [ (depth, modref, mty) ] + | [] -> notFound id rest depth + | id :: rest -> + match mty.ModulesAndNamespacesByDemangledName.TryGetValue id.idText with + | true, res -> + let subref = modref.NestedTyconRef res + if IsEntityAccessible amap m ad subref then + notifyNameResolution subref id.idRange + look (depth + 1) subref rest + else + notFound id rest depth + | _ -> notFound id rest depth + + modrefs + |> List.map (fun modref -> + if IsEntityAccessible amap m ad modref then + notifyNameResolution modref id.idRange + look 1 modref rest + else + notFound id rest 0) + |> List.reduce AddResults + | _ -> notFound id rest 0 + // Note - 'rest' is annotated due to a bug currently in Unity (see: https://github.com/dotnet/fsharp/pull/7427) let ResolveLongIdentAsModuleOrNamespaceThen sink atMostOne amap m fullyQualified (nenv: NameResolutionEnv) ad id (rest: Ident list) isOpenDecl f = match ResolveLongIdentAsModuleOrNamespace sink ResultCollectionSettings.AllResults amap m true fullyQualified nenv ad id [] isOpenDecl with diff --git a/src/Compiler/Checking/NameResolution.fsi b/src/Compiler/Checking/NameResolution.fsi index c93881d7712..ce5d60799aa 100755 --- a/src/Compiler/Checking/NameResolution.fsi +++ b/src/Compiler/Checking/NameResolution.fsi @@ -368,6 +368,7 @@ type internal ItemOccurence = | Binding | Use | UseInType + | UseInTypeAnnotation | UseInAttribute | Pattern | Implemented @@ -675,6 +676,19 @@ val internal ResolveLongIdentAsModuleOrNamespace: isOpenDecl: bool -> ResultOrException<(int * ModuleOrNamespaceRef * ModuleOrNamespaceType) list> +/// Resolve a long identifier to a module. +val internal ResolveLongIdentAsModule: + sink: TcResultsSink -> + amap: ImportMap -> + m: range -> + first: bool -> + fullyQualified: FullyQualifiedFlag -> + nenv: NameResolutionEnv -> + ad: AccessorDomain -> + id: Ident -> + rest: Ident list -> + ResultOrException<(int * ModuleOrNamespaceRef * ModuleOrNamespaceType) list> + /// Resolve a long identifier to an object constructor. val internal ResolveObjectConstructor: ncenv: NameResolver -> denv: DisplayEnv -> m: range -> ad: AccessorDomain -> ty: TType -> ResultOrException diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 063a6b973c8..9a0faa10b0f 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1,6 +1,7 @@ # ------------------------------------------------------------------------------- # use a completely new error number and keep messages in their surrounding groups # ------------------------------------------------------------------------------- +undefinedNameModule,"The module '%s' is not defined." undefinedNameNamespace,"The namespace '%s' is not defined." undefinedNameNamespaceOrModule,"The namespace or module '%s' is not defined." undefinedNameFieldConstructorOrMember,"The field, constructor or member '%s' is not defined." @@ -1563,6 +1564,7 @@ featureArithmeticInLiterals,"Allow arithmetic and logical operations in literals featureErrorReportingOnStaticClasses,"Error reporting on static classes" featureTryWithInSeqExpressions,"Support for try-with in sequence expressions" featureWarningWhenCopyAndUpdateRecordChangesAllFields,"Raises warnings when an copy-and-update record expression changes all fields of a record." +featureModulesInTypeApplication,"Allow modules to be used in type application" 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." @@ -1677,3 +1679,4 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form 3558,chkExplicitFieldsDeclarationsOnStaticClasses,"If a type uses both [] and [] attributes, it means it is static. Explicit field declarations are not allowed." 3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'." 3560,tcCopyAndUpdateRecordChangesAllFields,"This copy-and-update record expression changes all fields of record type '%s'. Consider using the record construction syntax instead." +3561,tcModuleUsedInTypeAnnotation,"Module references are intended to be used in 'typeof'." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 46748d6f889..3a471414cf5 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -63,6 +63,7 @@ type LanguageFeature = | ErrorReportingOnStaticClasses | TryWithInSeqExpression | WarningWhenCopyAndUpdateRecordChangesAllFields + | ModulesInTypeApplication /// LanguageVersion management type LanguageVersion(versionText) = @@ -142,6 +143,7 @@ type LanguageVersion(versionText) = LanguageFeature.ErrorReportingOnStaticClasses, previewVersion LanguageFeature.TryWithInSeqExpression, previewVersion LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields, previewVersion + LanguageFeature.ModulesInTypeApplication, previewVersion ] @@ -258,6 +260,7 @@ type LanguageVersion(versionText) = | LanguageFeature.ErrorReportingOnStaticClasses -> FSComp.SR.featureErrorReportingOnStaticClasses () | LanguageFeature.TryWithInSeqExpression -> FSComp.SR.featureTryWithInSeqExpressions () | LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields -> FSComp.SR.featureWarningWhenCopyAndUpdateRecordChangesAllFields () + | LanguageFeature.ModulesInTypeApplication -> FSComp.SR.featureModulesInTypeApplication () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 8ab8b72704b..550901c0fc2 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -53,6 +53,7 @@ type LanguageFeature = | ErrorReportingOnStaticClasses | TryWithInSeqExpression | WarningWhenCopyAndUpdateRecordChangesAllFields + | ModulesInTypeApplication /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index c66bb3e5142..2e348a54374 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -236,7 +236,11 @@ type FSharpSymbolUse(denv: DisplayEnv, symbol: FSharpSymbol, inst: TyparInstanti member _.IsFromPattern = itemOcc = ItemOccurence.Pattern - member _.IsFromType = itemOcc = ItemOccurence.UseInType + member _.IsFromType = + match itemOcc with + | ItemOccurence.UseInType + | ItemOccurence.UseInTypeAnnotation -> true + | _ -> false member _.IsFromAttribute = itemOcc = ItemOccurence.UseInAttribute @@ -1329,7 +1333,13 @@ type internal TypeCheckInfo denv, m) - | Some (CompletionContext.OpenDeclaration isOpenType) -> + | Some CompletionContext.ModuleAsType + | Some (CompletionContext.OpenDeclaration _) -> + let isOpenType = + match completionContext with + | Some (CompletionContext.OpenDeclaration true) -> true + | _ -> false + GetDeclaredItems( parseResultsOpt, lineStr, diff --git a/src/Compiler/Service/SemanticClassification.fs b/src/Compiler/Service/SemanticClassification.fs index f1fdc92c0bb..76d373405fc 100644 --- a/src/Compiler/Service/SemanticClassification.fs +++ b/src/Compiler/Service/SemanticClassification.fs @@ -148,6 +148,7 @@ module TcResolutionsExtensions = let (|LegitTypeOccurence|_|) occ = match occ with | ItemOccurence.UseInType + | ItemOccurence.UseInTypeAnnotation | ItemOccurence.UseInAttribute | ItemOccurence.Use | ItemOccurence.Binding diff --git a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs index dc704d12fd8..1faae5935f9 100644 --- a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs +++ b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs @@ -116,6 +116,9 @@ type InterfaceData = | TyparStaticReq.None -> Some("'" + s.idText) | TyparStaticReq.HeadType -> Some("^" + s.idText) | SynType.LongIdent (SynLongIdent (xs, _, _)) -> xs |> Seq.map (fun x -> x.idText) |> String.concat "." |> Some + | SynType.LongIdentModule (SynLongIdent (xs, _, _), _) -> + let ident = xs |> Seq.map (fun x -> x.idText) |> String.concat "." + Some(sprintf "module %s" ident) | SynType.App (t, _, ts, _, _, isPostfix, _) -> match t, ts with | TypeIdent typeName, [] -> Some typeName diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index 7e932bdb83f..e8df3dd2fbe 100644 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -826,6 +826,7 @@ module SyntaxTraversal = | SynType.Anon _ | SynType.AnonRecd _ | SynType.LongIdent _ + | SynType.LongIdentModule _ | SynType.Var _ | SynType.StaticConstant _ -> None diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index b4739fe73e2..931aa19e29f 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -80,6 +80,9 @@ type CompletionContext = /// or a single case union without a bar (type SomeUnion = Abc|) | TypeAbbreviationOrSingleCaseUnion + /// Completing module in generic type application (e.g. typeof) + | ModuleAsType + type ShortIdent = string type ShortIdents = ShortIdent[] @@ -660,7 +663,8 @@ module ParsedInput = and walkType ty = match ty with - | SynType.LongIdent ident -> + | SynType.LongIdent ident + | SynType.LongIdentModule (ident, _) -> // we protect it with try..with because System.Exception : rangeOfLidwd may raise // at FSharp.Compiler.Syntax.LongIdentWithDots.get_Range() in D:\j\workspace\release_ci_pa---3f142ccc\src\ast.fs: line 156 try @@ -1306,7 +1310,17 @@ module ParsedInput = | SynExpr.Record (None, None, [], _) -> Some(CompletionContext.RecordField RecordContext.Empty) // Unchecked.defaultof - | SynExpr.TypeApp (typeArgsRange = range) when rangeContainsPos range pos -> Some CompletionContext.PatternType + // typeof + | SynExpr.TypeApp (typeArgs = typeArgs; typeArgsRange = range) when rangeContainsPos range pos -> + typeArgs + |> List.tryPick (fun arg -> + match arg with + | SynType.LongIdent lid when rangeContainsPos lid.Range pos -> Some CompletionContext.PatternType + | SynType.LongIdentModule (lid, _) when rangeContainsPos lid.Range pos -> + Some CompletionContext.ModuleAsType + | _ -> None) + |> Option.orElse (Some CompletionContext.PatternType) + | _ -> defaultTraverse expr member _.VisitRecordField(path, copyOpt, field) = @@ -1677,7 +1691,8 @@ module ParsedInput = | SynType.Or (t1, t2, _, _) -> walkType t1 walkType t2 - | SynType.LongIdent ident -> addLongIdentWithDots ident + | SynType.LongIdent ident + | SynType.LongIdentModule (ident, _) -> addLongIdentWithDots ident | SynType.App (ty, _, types, _, _, _, _) -> walkType ty List.iter walkType types diff --git a/src/Compiler/Service/ServiceParsedInputOps.fsi b/src/Compiler/Service/ServiceParsedInputOps.fsi index f0542957759..27fafe81a4a 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fsi +++ b/src/Compiler/Service/ServiceParsedInputOps.fsi @@ -53,6 +53,9 @@ type public CompletionContext = /// or a single case union without a bar (type SomeUnion = Abc|) | TypeAbbreviationOrSingleCaseUnion + /// Completing module in generic type application (e.g. typeof) + | ModuleAsType + type public ModuleKind = { IsAutoOpen: bool HasModuleSuffix: bool } diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index 09f0bafbea0..7b853a88cac 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -779,7 +779,7 @@ type LexFilterImpl ( // 'fun ->' places no limit until we hit a CtxtLetDecl etc... (Recursive) | _, CtxtFun _ :: rest -> undentationLimit false rest - + // 'let ... = f ... begin' limited by 'let' (given RelaxWhitespace2) // 'let (' (pattern match) limited by 'let' (given RelaxWhitespace2) // 'let [' (pattern match) limited by 'let' (given RelaxWhitespace2) @@ -1084,6 +1084,7 @@ type LexFilterImpl ( // f<{| C : int |}>x // fx // fx + // fx | DEFAULT | COLON | COLON_GREATER | STRUCT | NULL | DELEGATE | AND | WHEN | DOT_DOT | NEW @@ -1094,6 +1095,7 @@ type LexFilterImpl ( | INFIX_AT_HAT_OP "^-" | INFIX_STAR_DIV_MOD_OP "/" | MINUS + | MODULE | GLOBAL | CONST | KEYWORD_STRING _ @@ -1350,7 +1352,7 @@ type LexFilterImpl ( | CtxtDo _ | CtxtLetDecl (true, _) -> Some ODECLEND - + | CtxtSeqBlock(_, _, AddBlockEnd) -> Some OBLOCKEND @@ -1923,8 +1925,8 @@ type LexFilterImpl ( pushCtxt tokenTup (CtxtNamespaceHead (tokenStartPos, token)) returnToken tokenLexbufState token - // module ... ~~~> CtxtModuleHead - | MODULE, _ :: _ -> + // module ... ~~~> CtxtModuleHead, unless we're in a type application + | MODULE, _ :: stack when stack |> List.forall (fun x -> match x with CtxtParen (LESS _, _) -> false | _ -> true) -> insertComingSoonTokens("MODULE", MODULE_COMING_SOON, MODULE_IS_HERE) if debug then dprintf "MODULE: entering CtxtModuleHead, awaiting EQUALS to go to CtxtSeqBlock (%a)\n" outputPos tokenStartPos pushCtxt tokenTup (CtxtModuleHead (tokenStartPos, token, NotLexingModuleAttributes)) @@ -2383,7 +2385,7 @@ type LexFilterImpl ( returnToken tokenLexbufState token | _ -> - returnToken tokenLexbufState token + returnToken tokenLexbufState token and insertHighPrecedenceApp (tokenTup: TokenTup) = let dotTokenTup = peekNextTokenTup() diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 1acd2eae680..a019099a8b9 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -393,6 +393,8 @@ type SynType = | LongIdent of longDotId: SynLongIdent + | LongIdentModule of longDotId: SynLongIdent * range: range + | App of typeName: SynType * lessRange: range option * @@ -461,6 +463,7 @@ type SynType = | SynType.SignatureParameter (range = m) | SynType.Or (range = m) -> m | SynType.LongIdent lidwd -> lidwd.Range + | SynType.LongIdentModule (range = m) -> m [] type SynExpr = diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 73040c53243..c9e038db4bd 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -445,6 +445,9 @@ type SynType = /// F# syntax: A.B.C | LongIdent of longDotId: SynLongIdent + /// F# syntax: typeof + | LongIdentModule of longDotId: SynLongIdent * range: range + /// F# syntax: type or type type or (type, ..., type) type /// isPostfix: indicates a postfix type application e.g. "int list" or "(int, string) dict" | App of diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 9e53f78b9d0..0797ba7c2b5 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -5136,6 +5136,12 @@ tupleOrQuotTypeElements: { [ SynTupleTypeSegment.Type $1 ] } appTypeCon: + | moduleKeyword path %prec prec_atomtyp_path + { let mModule = rhs parseState 1 + parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.ModulesInTypeApplication mModule + let mAll = unionRanges mModule $2.Range + SynType.LongIdentModule($2, mAll) } + | path %prec prec_atomtyp_path { SynType.LongIdent($1) } diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index b6ad7c62f3a..f6a59fa2a0c 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -297,6 +297,11 @@ Zahození shody vzoru není povolené pro případ sjednocení, který nepřijímá žádná data. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ reprezentace struktury aktivních vzorů - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Vyvolá upozornění, když se použije „let inline ... =“ společně s atributem [<MethodImpl(MethodImplOptions.NoInlining)>]. Funkce není vkládána. @@ -1005,6 +1007,11 @@ Je třeba inicializovat následující požadované vlastnosti:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later Použití metod s atributem NoEagerConstraintApplicationAttribute vyžaduje /langversion:6.0 nebo novější. @@ -1165,6 +1172,11 @@ Typ {0} nedefinuje pole, konstruktor ani člen {1}. + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. Není definovaný obor názvů {0}. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 52f3d52cf26..238fd036649 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -297,6 +297,11 @@ Das Verwerfen von Musterübereinstimmungen ist für einen Union-Fall, der keine Daten akzeptiert, nicht zulässig. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ Strukturdarstellung für aktive Muster - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Löst Warnungen aus, wenn „let inline ... =“ zusammen mit dem Attribut [<MethodImpl(MethodImplOptions.NoInlining)>] verwendet wird. Die Funktion wird nicht inline gesetzt. @@ -1005,6 +1007,11 @@ Die folgenden erforderlichen Eigenschaften müssen initialisiert werden:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later Die Verwendung von Methoden mit "NoEagerConstraintApplicationAttribute" erfordert /langversion:6.0 oder höher. @@ -1165,6 +1172,11 @@ Der Typ "{0}" definiert nicht das Feld, den Konstruktor oder den Member "{1}". + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. Der Namespace "{0}" ist nicht definiert. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 298deb31137..9edae45db31 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -297,6 +297,11 @@ No se permite el descarte de coincidencia de patrón para un caso de unión que no tome datos. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ representación de struct para modelos activos - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Genera advertencias cuando se usa "let inline ... =" junto con el atributo [<MethodImpl(MethodImplOptions.NoInlining)>]. La función no se está insertando. @@ -1005,6 +1007,11 @@ Se deben inicializar las siguientes propiedades necesarias:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later El uso de métodos con "NoEagerConstraintApplicationAttribute" requiere /langversion:6.0 o posteriores @@ -1165,6 +1172,11 @@ El tipo "{0}" no define el campo, constructor o miembro "{1}". + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. El espacio de nombres "{0}" no está definido. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index d41d7f05761..e3efbf95f0d 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -297,6 +297,11 @@ L’abandon des correspondances de modèle n’est pas autorisé pour un cas d’union qui n’accepte aucune donnée. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ représentation de structure pour les modèles actifs - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Génère des avertissements lorsque « let inline ... = » est utilisé avec l’attribut [<MethodImpl(MethodImplOptions.NoInlining)>]. La fonction n’est pas inlined. @@ -1005,6 +1007,11 @@ Les propriétés requises suivantes doivent être initialisées :{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later L’utilisation de méthodes avec « NoEagerConstraintApplicationAttribute » requiert/langversion:6.0 ou ultérieur @@ -1165,6 +1172,11 @@ Le type '{0}' ne définit pas le champ, le constructeur ou le membre '{1}'. + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. L'espace de noms '{0}' n'est pas défini. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 083f98e4dfa..7c53c7b4a52 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -297,6 +297,11 @@ L'eliminazione della corrispondenza dei criteri non è consentita per case di unione che non accetta dati. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ rappresentazione struct per criteri attivi - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Genera avvisi quando 'let inline ... =' viene usato insieme all'attributo [<MethodImpl(MethodImplOptions.NoInlining)>]. La funzione non viene resa inline. @@ -1005,6 +1007,11 @@ È necessario inizializzare le proprietà obbligatorie seguenti:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later L'utilizzo di metodi con 'NoEagerConstraintApplicationAttribute' richiede /langversion: 6.0 o versione successiva @@ -1165,6 +1172,11 @@ Il tipo '{0}' non definisce il campo, il costruttore o il membro '{1}'. + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. Lo spazio dei nomi '{0}' non è definito. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 85735c3b4e2..290e264702a 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -297,6 +297,11 @@ データを受け取らない共用体ケースでは、パターン一致の破棄は許可されません。 + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ アクティブなパターンの構造体表現 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 'let inline ... =' が [<MethodImpl(MethodImplOptions.NoInlining)>] 属性と一緒に使用されるときに警告を生成します。関数はインライン化されていません。 @@ -1005,6 +1007,11 @@ The following required properties have to be initalized:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later 'NoEagerConstraintApplicationAttribute' を指定してメソッドを使用するには、/langversion:6.0 以降が必要です @@ -1165,6 +1172,11 @@ 型 '{0}' は、フィールド、コンストラクター、またはメンバー '{1}' を定義していません。 + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. 名前空間 '{0}' が定義されていません。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 2b32dd65949..65bf09a500f 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -297,6 +297,11 @@ 데이터를 사용하지 않는 공용 구조체 사례에는 패턴 일치 삭제가 허용되지 않습니다. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ 활성 패턴에 대한 구조체 표현 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 'let inline ... ='을(를) [<MethodImpl(MethodImplOptions.NoInlining)>] 특성과 함께 사용하는 경우 경고를 발생합니다. 함수가 인라인되지 않습니다. @@ -1005,6 +1007,11 @@ 다음 필수 속성을 초기화해야 합니다. {0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later 'NoEagerConstraintApplicationAttribute'와 함께 메서드를 사용하려면 /langversion:6.0 이상이 필요합니다. @@ -1165,6 +1172,11 @@ '{0}' 형식은 '{1}' 필드, 생성자 또는 멤버를 정의하지 않습니다. + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. '{0}' 네임스페이스가 정의되지 않았습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index ee6b6afe9ac..5f34a8f9a44 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -297,6 +297,11 @@ Odrzucenie dopasowania wzorca jest niedozwolone w przypadku unii, która nie pobiera żadnych danych. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ reprezentacja struktury aktywnych wzorców - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Zgłasza ostrzeżenia, gdy element „let inline ... =” jest używany razem z atrybutem [<MethodImpl(MethodImplOptions.NoInlining)>]. Funkcja nie jest wstawiana. @@ -1005,6 +1007,11 @@ Następujące wymagane właściwości muszą zostać zainicjowane:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later Używanie metod z atrybutem "NoEagerConstraintApplicationAttribute" wymaga parametru /langversion:6.0 lub nowszego @@ -1165,6 +1172,11 @@ Typ „{0}” nie definiuje pola, konstruktora lub składowej „{1}”. + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. Nie zdefiniowano przestrzeni nazw „{0}”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 8ad44f41ea6..37f565eda34 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -297,6 +297,11 @@ O descarte de correspondência de padrão não é permitido para casos união que não aceitam dados. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ representação estrutural para padrões ativos - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Gera avisos quando 'let inline ... =' é usado junto com o atributo [<MethodImpl(MethodImplOptions.NoInlining)>]. A função não está sendo embutida. @@ -1005,6 +1007,11 @@ As seguintes propriedades necessárias precisam ser inicializadas:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later Usar métodos com 'NoEagerConstraintApplicationAttribute' requer /langversion:6.0 ou posterior @@ -1165,6 +1172,11 @@ O tipo '{0}' não define o campo, o construtor ou o membro '{1}'. + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. O namespace '{0}' não está definido. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 0cbd637dd4d..6174d2778b1 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -297,6 +297,11 @@ Отмена сопоставления с шаблоном не разрешена для случая объединения, не принимающего данные. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ представление структуры для активных шаблонов - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Выдает предупреждения, когда используется параметр "let inline ... =" вместе с атрибутом [<MethodImpl(MethodImplOptions.NoInlining)>]. Функция не встраивается. @@ -1005,6 +1007,11 @@ Необходимо инициализировать следующие обязательные свойства:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later Для использования методов с "NoEagerConstraintApplicationAttribute" требуется /langversion:6.0 или более поздняя версия @@ -1165,6 +1172,11 @@ Тип "{0}" не определяет поле, конструктор или член "{1}". + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. Пространство имен "{0}" не определено. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index c9713648da3..b4fc5de036b 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -297,6 +297,11 @@ Veri almayan birleşim durumu için desen eşleştirme atma kullanılamaz. + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ etkin desenler için yapı gösterimi - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. [<MethodImpl(MethodImplOptions.NoInlining)>] özniteliği ile birlikte 'let inline ... =' kullanıldığında uyarı verir. İşlev satır içine alınmıyor. @@ -1005,6 +1007,11 @@ Aşağıdaki gerekli özelliklerin başlatılması gerekiyor:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later 'NoEagerConstraintApplicationAttribute' içeren yöntemlerin kullanılması /langversion:6.0 veya üstünü gerektiriyor @@ -1165,6 +1172,11 @@ '{0}' türü; alanı, oluşturucuyu veya '{1}' üyesini tanımlamıyor. + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. '{0}' ad alanı tanımlı değil. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 4072aaad792..4ed19637bcf 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -297,6 +297,11 @@ 不允许将模式匹配丢弃用于不采用数据的联合事例。 + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ 活动模式的结构表示形式 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 当 "let inline ... =" 与 [<MethodImpl(MethodImplOptions.NoInlining)>] 属性一起使用时引发警告。函数未内联。 @@ -1005,6 +1007,11 @@ 必须初始化以下必需属性: {0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later 将方法与 “NoEagerConstraintApplicationAttribute” 配合使用需要 /langversion:6.0 或更高版本 @@ -1165,6 +1172,11 @@ 类型“{0}”未定义字段、构造函数或成员“{1}”。 + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. 未定义命名空间“{0}”。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index bd871bbba49..4e07a69fbbc 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -297,6 +297,11 @@ 不接受資料的聯集案例不允許模式比對捨棄。 + + Allow modules to be used in type application + Allow modules to be used in type application + + nameof nameof @@ -382,19 +387,16 @@ 現用模式的結構表示法 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 當 'let inline ... =' 與 [<MethodImpl(MethodImplOptions.NoInlining)>] 屬性一起使用時引發警告。函數未內嵌。 @@ -1005,6 +1007,11 @@ The following required properties have to be initalized:{0} + + Module references are intended to be used in 'typeof'. + Module references are intended to be used in 'typeof'. + + Using methods with 'NoEagerConstraintApplicationAttribute' requires /langversion:6.0 or later 使用具有 'NoEagerConstraintApplicationAttribute' 的方法需要 /langversion:6.0 或更新版本 @@ -1165,6 +1172,11 @@ 類型 '{0}' 未定義欄位、建構函式或成員 '{1}'。 + + The module '{0}' is not defined. + The module '{0}' is not defined. + + The namespace '{0}' is not defined. 未定義命名空間 '{0}'。 diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 756dbbce130..e0c52cdfe2e 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -181,6 +181,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ModuleAsTypeTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ModuleAsTypeTests.fs new file mode 100644 index 00000000000..ea1643f8c99 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Language/ModuleAsTypeTests.fs @@ -0,0 +1,87 @@ +module FSharp.Compiler.ComponentTests.Language.ModuleAsTypeTests + +open Xunit +open FSharp.Test.Compiler + +[] +[] +[] +let ``Module can be used in typeof in lang preview`` (typeofKeyword: string) = + Fsx $""" +let actual = {typeofKeyword}.Name +let expected = "LanguagePrimitives" +if actual <> expected then failwith $"Expected '{{expected}}', but got '{{actual}}'" + """ + |> asExe + |> withLangVersionPreview + |> compileAndRun + |> shouldSucceed + +[] +let ``Module cannot be used in typeof in lang version70`` () = + Fsx """ +let actual = typeof + """ + |> withLangVersion70 + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3350, Line 2, Col 21, Line 2, Col 27, "Feature 'Allow modules to be used in type application' is not available in F# 7.0. Please use language version 'PREVIEW' or greater.") + ] + +[] +let ``Module cannot be used in type annotation in lang preview`` () = + Fsx """ +let actual: module LanguagePrimitives = Unchecked.defaultof<_> + """ + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3561, Line 2, Col 13, Line 2, Col 38, "Module references are intended to be used in 'typeof'.") + ] + +[] +let ``Module can be used as generic type argument in lang preview`` () = + Fsx """ +let actual = ResizeArray().GetType().FullName +let expected = "System.Collections.Generic.List`1[[Microsoft.FSharp.Core.LanguagePrimitives" +if not (actual.StartsWith expected) then failwith $"Expected to start with '{expected}', but got '{actual}'" + """ + |> asExe + |> withLangVersionPreview + |> compileAndRun + |> shouldSucceed + +[] +let ``Namespaces, types, values and non-existent modules cannot be used as modules in typeof in lang preview`` () = + Fsx """ +module rec Ns.A + +module B = + let value = () + +type R = { F: int } + +let _ = typeof +let _ = typeof +let _ = typeof +let _ = typeof +let _ = typeof +let _ = typeof +let _ = typeof +let _ = typeof + """ + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 39, Line 9, Col 23, Line 9, Col 25, "The module 'Ns' is not defined.") + (Error 39, Line 10, Col 23, Line 10, Col 34, "The module 'Nonexistent' is not defined.") + (Error 39, Line 11, Col 23, Line 11, Col 36, "The namespace or module 'NonexistentNs' is not defined.") + (Error 39, Line 12, Col 26, Line 12, Col 37, "The module 'Nonexistent' is not defined.") + (Error 39, Line 13, Col 26, Line 13, Col 39, "The namespace or module 'NonexistentNs' is not defined.") + (Error 39, Line 14, Col 28, Line 14, Col 39, "The module 'Nonexistent' is not defined.") + (Error 39, Line 15, Col 30, Line 15, Col 35, "The module 'value' is not defined.") + (Error 39, Line 16, Col 23, Line 16, Col 24, "The module 'R' is not defined.") + ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Language/NameofTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/NameofTests.fs index 27e7ca95bec..594519eb33d 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/NameofTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/NameofTests.fs @@ -129,3 +129,16 @@ if not((getData b) = re2.Data) then |> compileAndRun |> shouldSucceed + [] + let ``nameof works for modules`` () = + let source = """ +let actual = nameof(FSharp.Core.LanguagePrimitives) +let expected = "LanguagePrimitives" +if actual <> expected then failwith $"Expected type to be '{expected}', but got '{actual}'" + """ + Fsx source + |> asExe + |> withLangVersionPreview + |> ignoreWarnings + |> compileAndRun + |> shouldSucceed diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 1bce6c61d8d..964800ff258 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -2497,6 +2497,7 @@ FSharp.Compiler.EditorServices.CompletionContext+RecordField: FSharp.Compiler.Ed FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 AttributeApplication FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 Inherit FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 Invalid +FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 ModuleAsType FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 OpenDeclaration FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 ParameterList FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 PatternType @@ -2510,6 +2511,7 @@ FSharp.Compiler.EditorServices.CompletionContext: Boolean Equals(System.Object, FSharp.Compiler.EditorServices.CompletionContext: Boolean IsAttributeApplication FSharp.Compiler.EditorServices.CompletionContext: Boolean IsInherit FSharp.Compiler.EditorServices.CompletionContext: Boolean IsInvalid +FSharp.Compiler.EditorServices.CompletionContext: Boolean IsModuleAsType FSharp.Compiler.EditorServices.CompletionContext: Boolean IsOpenDeclaration FSharp.Compiler.EditorServices.CompletionContext: Boolean IsParameterList FSharp.Compiler.EditorServices.CompletionContext: Boolean IsPatternType @@ -2520,6 +2522,7 @@ FSharp.Compiler.EditorServices.CompletionContext: Boolean IsUnionCaseFieldsDecla FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsAttributeApplication() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsInherit() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsInvalid() +FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsModuleAsType() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsOpenDeclaration() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsParameterList() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsPatternType() @@ -2529,6 +2532,7 @@ FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsTypeAbbreviation FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsUnionCaseFieldsDeclaration() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext AttributeApplication FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext Invalid +FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext ModuleAsType FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext NewInherit(FSharp.Compiler.EditorServices.InheritanceContext, System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]]) FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext NewOpenDeclaration(Boolean) FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext NewParameterList(FSharp.Compiler.Text.Position, System.Collections.Generic.HashSet`1[System.String]) @@ -2539,6 +2543,7 @@ FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext UnionCaseFieldsDeclaration FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_AttributeApplication() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_Invalid() +FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_ModuleAsType() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_PatternType() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_RangeOperator() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_TypeAbbreviationOrSingleCaseUnion() @@ -8393,6 +8398,10 @@ FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption` FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_lessRange() FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] greaterRange FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] lessRange +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Syntax.SynLongIdent longDotId +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynRationalConst exponent FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynRationalConst get_exponent() FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynType baseMeasure @@ -8443,6 +8452,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 Fun FSharp.Compiler.Syntax.SynType+Tags: Int32 HashConstraint FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentApp +FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentModule FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasurePower FSharp.Compiler.Syntax.SynType+Tags: Int32 Or FSharp.Compiler.Syntax.SynType+Tags: Int32 Paren @@ -8477,6 +8487,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsFun FSharp.Compiler.Syntax.SynType: Boolean IsHashConstraint FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentApp +FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentModule FSharp.Compiler.Syntax.SynType: Boolean IsMeasurePower FSharp.Compiler.Syntax.SynType: Boolean IsOr FSharp.Compiler.Syntax.SynType: Boolean IsParen @@ -8495,6 +8506,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsFun() FSharp.Compiler.Syntax.SynType: Boolean get_IsHashConstraint() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentApp() +FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentModule() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasurePower() FSharp.Compiler.Syntax.SynType: Boolean get_IsOr() FSharp.Compiler.Syntax.SynType: Boolean get_IsParen() @@ -8513,6 +8525,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Com FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) 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 NewLongIdentModule(FSharp.Compiler.Syntax.SynLongIdent, 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) @@ -8531,6 +8544,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Fun FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+HashConstraint 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+LongIdentModule 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 diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 1bce6c61d8d..964800ff258 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -2497,6 +2497,7 @@ FSharp.Compiler.EditorServices.CompletionContext+RecordField: FSharp.Compiler.Ed FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 AttributeApplication FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 Inherit FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 Invalid +FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 ModuleAsType FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 OpenDeclaration FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 ParameterList FSharp.Compiler.EditorServices.CompletionContext+Tags: Int32 PatternType @@ -2510,6 +2511,7 @@ FSharp.Compiler.EditorServices.CompletionContext: Boolean Equals(System.Object, FSharp.Compiler.EditorServices.CompletionContext: Boolean IsAttributeApplication FSharp.Compiler.EditorServices.CompletionContext: Boolean IsInherit FSharp.Compiler.EditorServices.CompletionContext: Boolean IsInvalid +FSharp.Compiler.EditorServices.CompletionContext: Boolean IsModuleAsType FSharp.Compiler.EditorServices.CompletionContext: Boolean IsOpenDeclaration FSharp.Compiler.EditorServices.CompletionContext: Boolean IsParameterList FSharp.Compiler.EditorServices.CompletionContext: Boolean IsPatternType @@ -2520,6 +2522,7 @@ FSharp.Compiler.EditorServices.CompletionContext: Boolean IsUnionCaseFieldsDecla FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsAttributeApplication() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsInherit() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsInvalid() +FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsModuleAsType() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsOpenDeclaration() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsParameterList() FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsPatternType() @@ -2529,6 +2532,7 @@ FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsTypeAbbreviation FSharp.Compiler.EditorServices.CompletionContext: Boolean get_IsUnionCaseFieldsDeclaration() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext AttributeApplication FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext Invalid +FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext ModuleAsType FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext NewInherit(FSharp.Compiler.EditorServices.InheritanceContext, System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]]) FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext NewOpenDeclaration(Boolean) FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext NewParameterList(FSharp.Compiler.Text.Position, System.Collections.Generic.HashSet`1[System.String]) @@ -2539,6 +2543,7 @@ FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext UnionCaseFieldsDeclaration FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_AttributeApplication() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_Invalid() +FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_ModuleAsType() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_PatternType() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_RangeOperator() FSharp.Compiler.EditorServices.CompletionContext: FSharp.Compiler.EditorServices.CompletionContext get_TypeAbbreviationOrSingleCaseUnion() @@ -8393,6 +8398,10 @@ FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption` FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_lessRange() FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] greaterRange FSharp.Compiler.Syntax.SynType+LongIdentApp: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] lessRange +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Syntax.SynLongIdent longDotId +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+LongIdentModule: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynRationalConst exponent FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynRationalConst get_exponent() FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynType baseMeasure @@ -8443,6 +8452,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 Fun FSharp.Compiler.Syntax.SynType+Tags: Int32 HashConstraint FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentApp +FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentModule FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasurePower FSharp.Compiler.Syntax.SynType+Tags: Int32 Or FSharp.Compiler.Syntax.SynType+Tags: Int32 Paren @@ -8477,6 +8487,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsFun FSharp.Compiler.Syntax.SynType: Boolean IsHashConstraint FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentApp +FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentModule FSharp.Compiler.Syntax.SynType: Boolean IsMeasurePower FSharp.Compiler.Syntax.SynType: Boolean IsOr FSharp.Compiler.Syntax.SynType: Boolean IsParen @@ -8495,6 +8506,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsFun() FSharp.Compiler.Syntax.SynType: Boolean get_IsHashConstraint() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentApp() +FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentModule() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasurePower() FSharp.Compiler.Syntax.SynType: Boolean get_IsOr() FSharp.Compiler.Syntax.SynType: Boolean get_IsParen() @@ -8513,6 +8525,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Com FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) 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 NewLongIdentModule(FSharp.Compiler.Syntax.SynLongIdent, 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) @@ -8531,6 +8544,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Fun FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+HashConstraint 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+LongIdentModule 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 diff --git a/tests/service/SyntaxTreeTests/SynTypeTests.fs b/tests/service/SyntaxTreeTests/SynTypeTests.fs index 7f18521a995..ffb2910668c 100644 --- a/tests/service/SyntaxTreeTests/SynTypeTests.fs +++ b/tests/service/SyntaxTreeTests/SynTypeTests.fs @@ -205,3 +205,22 @@ let inline f (x: 'T) = ((^T or int) : (static member A: int) ()) assertRange (2,25) (2, 34) mOrType assertRange (2,24) (2, 35) mParen | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.LongIdentModule includes the module keyword in its range`` () = + let parseResults = + getParseResults + """ +let t = typeof + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(expr = + SynExpr.TypeApp(typeArgs = [ SynType.LongIdentModule(synLongIdent, fullRange) ]) + ) + ]) ]) ])) -> + assertRange (2, 15) (2, 40) fullRange + assertRange (2, 22) (2, 40) synLongIdent.Range + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" diff --git a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs index 2be760394f9..9856df5fb3e 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs @@ -1218,6 +1218,19 @@ let emptyMap<'keyType, 'lValueType> () = """ VerifyCompletionList(fileContents, ", l", [ "LanguagePrimitives"; "List"; "lValueType" ], [ "let"; "log" ]) + + [] + let ``Completion list in type application of a module only contains modules and namespaces`` () = + let fileContents = + """ +open System + +let emptyMap<'lValueType> () = + Map.empty +""" + + VerifyCompletionList(fileContents, "module L", [ "LanguagePrimitives"; "Linq" ], [ "let"; "log"; "lValueType"; "Lazy" ]) + VerifyCompletionList(fileContents, "] let ``Completion list for interface with static abstract method type invocation contains static property with residue`` () =