Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.20278.5">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.20301.10">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>77bfd5a60e0691b0cebd180a0fd85eb65fa7f362</Sha>
<Sha>e4cb18bd64d291e5dc34e2f77317c33d5022a6b8</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
12 changes: 12 additions & 0 deletions eng/common/templates/post-build/post-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,15 @@ stages:
transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-transport/nuget/v3/index.json'
shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json'
symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-symbols/nuget/v3/index.json'

- template: \eng\common\templates\post-build\channels\generic-public-channel.yml
parameters:
artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }}
publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }}
symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }}
stageName: 'VS_Master_Publishing'
channelName: 'VS Master'
channelId: 1012
transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-transport/nuget/v3/index.json'
shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json'
symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-symbols/nuget/v3/index.json'
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.20278.5",
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.20301.10",
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2"
}
}
9 changes: 7 additions & 2 deletions src/fsharp/SyntaxTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,11 @@ type SynType =
value: SynType *
range: range

/// Gets the syntax range of this constuct
| Paren of
innerType: SynType *
range: range

/// Gets the syntax range of this construct
member x.Range =
match x with
| SynType.App (range=m)
Expand All @@ -532,7 +536,8 @@ type SynType =
| SynType.StaticConstantNamed (range=m)
| SynType.HashConstraint (range=m)
| SynType.MeasureDivide (range=m)
| SynType.MeasurePower (range=m) -> m
| SynType.MeasurePower (range=m)
| SynType.Paren (range=m) -> m
| SynType.LongIdent lidwd -> lidwd.Range

/// Represents a syntax tree for F# expressions
Expand Down
10 changes: 9 additions & 1 deletion src/fsharp/SyntaxTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ open FSharp.Compiler
open FSharp.Compiler.AbstractIL
open FSharp.Compiler.AbstractIL.Internal.Library
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.Features
open FSharp.Compiler.PrettyNaming
open FSharp.Compiler.Range
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.Range
open FSharp.Compiler.XmlDoc
Expand Down Expand Up @@ -397,6 +397,14 @@ let (|Attributes|) synAttributes =
let rangeOfNonNilAttrs (attrs: SynAttributes) =
(attrs.Head.Range, attrs.Tail) ||> unionRangeWithListBy (fun a -> a.Range)

let rec stripParenTypes synType =
match synType with
| SynType.Paren (innerType, _) -> stripParenTypes innerType
| _ -> synType

let (|StripParenTypes|) synType =
stripParenTypes synType

/// Operations related to the syntactic analysis of arguments of value, function and member definitions and signatures.
module SynInfo =

Expand Down
25 changes: 14 additions & 11 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4657,7 +4657,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: SyntacticUnscope
| _, TyparKind.Type ->
TcTypeApp cenv newOk checkCxs occ env tpenv m tcref [] []

| SynType.App (SynType.LongIdent(LongIdentWithDots(tc, _)), _, args, _commas, _, postfix, m) ->
| SynType.App (StripParenTypes (SynType.LongIdent(LongIdentWithDots(tc, _))), _, args, _commas, _, postfix, m) ->
let ad = env.eAccessRights

let tcref =
Expand Down Expand Up @@ -4793,7 +4793,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: SyntacticUnscope
let ms2, tpenv = TcMeasure cenv newOk checkCxs occ env tpenv typ2 m
TType_measure (Measure.Prod(ms1, Measure.Inv ms2)), tpenv

| SynType.App((SynType.Var(_, m1) | SynType.MeasurePower(_, _, m1)) as arg1, _, args, _commas, _, postfix, m) ->
| SynType.App(StripParenTypes (SynType.Var(_, m1) | (SynType.MeasurePower(_, _, m1))) as arg1, _, args, _commas, _, postfix, m) ->
match optKind, args, postfix with
| (None | Some TyparKind.Measure), [arg2], true ->
let ms1, tpenv = TcMeasure cenv newOk checkCxs occ env tpenv arg1 m1
Expand All @@ -4808,10 +4808,13 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: SyntacticUnscope
errorR(Error(FSComp.SR.tcIllegalSyntaxInTypeExpression(), m))
NewErrorType (), tpenv

| SynType.Paren(innerType, _) ->
TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: SyntacticUnscopedTyparEnv) innerType

and TcType cenv newOk checkCxs occ env (tpenv: SyntacticUnscopedTyparEnv) ty =
TcTypeOrMeasure (Some TyparKind.Type) cenv newOk checkCxs occ env tpenv ty

and TcMeasure cenv newOk checkCxs occ env (tpenv: SyntacticUnscopedTyparEnv) ty m =
and TcMeasure cenv newOk checkCxs occ env (tpenv: SyntacticUnscopedTyparEnv) (StripParenTypes ty) m =
match ty with
| SynType.Anon m ->
error(Error(FSComp.SR.tcAnonymousUnitsOfMeasureCannotBeNested(), m))
Expand Down Expand Up @@ -4869,7 +4872,7 @@ and TcTyparConstraints cenv newOk checkCxs occ env tpenv wcs =
tpenv

#if !NO_EXTENSIONTYPING
and TcStaticConstantParameter cenv (env: TcEnv) tpenv kind (v: SynType) idOpt container =
and TcStaticConstantParameter cenv (env: TcEnv) tpenv kind (StripParenTypes v) idOpt container =
let g = cenv.g
let fail() = error(Error(FSComp.SR.etInvalidStaticArgument(NicePrint.minimalStringOfType env.DisplayEnv kind), v.Range))
let record ttype =
Expand Down Expand Up @@ -4938,7 +4941,7 @@ and TcStaticConstantParameter cenv (env: TcEnv) tpenv kind (v: SynType) idOpt co
and CrackStaticConstantArgs cenv env tpenv (staticParameters: Tainted<ProvidedParameterInfo>[], args: SynType list, container, containerName, m) =
let args =
args |> List.map (function
| SynType.StaticConstantNamed(SynType.LongIdent(LongIdentWithDots([id], _)), v, _) -> Some id, v
| StripParenTypes (SynType.StaticConstantNamed(StripParenTypes (SynType.LongIdent(LongIdentWithDots([id], _))), v, _)) -> Some id, v
| v -> None, v)

let unnamedArgs = args |> Seq.takeWhile (fst >> Option.isNone) |> Seq.toArray |> Array.map snd
Expand Down Expand Up @@ -15343,9 +15346,9 @@ module EstablishTypeDefinitionCores =
k


let private (|TyconCoreAbbrevThatIsReallyAUnion|_|) (hasMeasureAttr, envinner, id: Ident) synTyconRepr =
let private (|TyconCoreAbbrevThatIsReallyAUnion|_|) (hasMeasureAttr, envinner, id: Ident) (synTyconRepr) =
match synTyconRepr with
| SynTypeDefnSimpleRepr.TypeAbbrev(_, SynType.LongIdent(LongIdentWithDots([unionCaseName], _)), m)
| SynTypeDefnSimpleRepr.TypeAbbrev(_, StripParenTypes (SynType.LongIdent(LongIdentWithDots([unionCaseName], _))), m)
when
(not hasMeasureAttr &&
(isNil (LookupTypeNameInEnvNoArity OpenQualified unionCaseName.idText envinner.eNameResEnv) ||
Expand Down Expand Up @@ -15628,11 +15631,11 @@ module EstablishTypeDefinitionCores =

#if !NO_EXTENSIONTYPING
/// Get the items on the r.h.s. of a 'type X = ABC<...>' definition
let private TcTyconDefnCore_GetGenerateDeclaration_Rhs rhsType =
let private TcTyconDefnCore_GetGenerateDeclaration_Rhs (StripParenTypes rhsType) =
match rhsType with
| SynType.App (SynType.LongIdent(LongIdentWithDots(tc, _)), _, args, _commas, _, _postfix, m) -> Some(tc, args, m)
| SynType.App (StripParenTypes (SynType.LongIdent(LongIdentWithDots(tc, _))), _, args, _commas, _, _postfix, m) -> Some(tc, args, m)
| SynType.LongIdent (LongIdentWithDots(tc, _) as lidwd) -> Some(tc, [], lidwd.Range)
| SynType.LongIdentApp (SynType.LongIdent (LongIdentWithDots(tc, _)), LongIdentWithDots(longId, _), _, args, _commas, _, m) -> Some(tc@longId, args, m)
| SynType.LongIdentApp (StripParenTypes (SynType.LongIdent (LongIdentWithDots(tc, _))), LongIdentWithDots(longId, _), _, args, _commas, _, m) -> Some(tc@longId, args, m)
| _ -> None

/// Check whether 'type X = ABC<...>' is a generative provided type definition
Expand Down Expand Up @@ -17147,7 +17150,7 @@ module TcDeclarations =
memberFlags.MemberKind=MemberKind.Constructor &&
// REVIEW: This is a syntactic approximation
(match valSpfn.SynType, valSpfn.SynInfo.ArgInfos with
| SynType.Fun (SynType.LongIdent (LongIdentWithDots([id], _)), _, _), [[_]] when id.idText = "unit" -> true
| StripParenTypes (SynType.Fun (StripParenTypes (SynType.LongIdent (LongIdentWithDots([id], _))), _, _)), [[_]] when id.idText = "unit" -> true
| _ -> false)
| _ -> false)

Expand Down
10 changes: 5 additions & 5 deletions src/fsharp/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -4956,12 +4956,12 @@ atomType:
| UNDERSCORE
{ SynType.Anon (lhs parseState) }

| LPAREN typ rparen
{ $2 }
| LPAREN typ rparen
{ SynType.Paren ($2, lhs parseState) }

| LPAREN typ recover
{ reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen())
$2 }
| LPAREN typ recover
{ reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen ())
SynType.Paren ($2, lhs parseState) }

| STRUCT LPAREN appType STAR tupleOrQuotTypeElements rparen
{ SynType.Tuple(true, (false, $3) :: $5, lhs parseState) }
Expand Down
3 changes: 2 additions & 1 deletion src/fsharp/service/ServiceAssemblyContent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ module ParsedInput =
and walkType = function
| SynType.Array (_, t, _)
| SynType.HashConstraint (t, _)
| SynType.MeasurePower (t, _, _) -> walkType t
| SynType.MeasurePower (t, _, _)
| SynType.Paren (t, _) -> walkType t
| SynType.Fun (t1, t2, _)
| SynType.MeasureDivide (t1, t2, _) -> walkType t1; walkType t2
| SynType.LongIdent ident -> addLongIdentWithDots ident
Expand Down
7 changes: 5 additions & 2 deletions src/fsharp/service/ServiceInterfaceStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ open FSharp.Compiler.AbstractIL.Internal.Library
open FSharp.Compiler.Range
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.SyntaxTreeOps

#if !FX_NO_INDENTED_TEXT_WRITER
[<AutoOpen>]
Expand Down Expand Up @@ -112,8 +113,8 @@ type InterfaceData =
ty.Range
member x.TypeParameters =
match x with
| InterfaceData.Interface(ty, _)
| InterfaceData.ObjExpr(ty, _) ->
| InterfaceData.Interface(StripParenTypes ty, _)
| InterfaceData.ObjExpr(StripParenTypes ty, _) ->
let rec (|RationalConst|) = function
| SynRationalConst.Integer i ->
string i
Expand Down Expand Up @@ -158,6 +159,8 @@ type InterfaceData =
Some (sprintf "%s^%s" typeName power)
| SynType.MeasureDivide(TypeIdent numerator, TypeIdent denominator, _) ->
Some (sprintf "%s/%s" numerator denominator)
| SynType.Paren(TypeIdent typeName, _) ->
Some typeName
| _ ->
None
match ty with
Expand Down
10 changes: 5 additions & 5 deletions src/fsharp/service/ServiceParamInfoLocations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type FSharpNoteworthyParamInfoLocations(longId: string list, longIdRange: range,
[<AutoOpen>]
module internal NoteworthyParamInfoLocationsImpl =

let isStaticArg a =
match a with
let isStaticArg (StripParenTypes synType) =
match synType with
| SynType.StaticConstant _ | SynType.StaticConstantExpr _ | SynType.StaticConstantNamed _ -> true
| SynType.LongIdent _ -> true // NOTE: this is not a static constant, but it is a prefix of incomplete code, e.g. "TP<42, Arg3" is a prefix of "TP<42, Arg3=6>" and Arg3 shows up as a LongId
| _ -> false
Expand All @@ -52,7 +52,7 @@ module internal NoteworthyParamInfoLocationsImpl =
| Found of openParen: pos * commasAndCloseParen: (pos * string option) list * hasClosedParen: bool
| NotFound

let digOutIdentFromStaticArg synType =
let digOutIdentFromStaticArg (StripParenTypes synType) =
match synType with
| SynType.StaticConstantNamed(SynType.LongIdent(LongIdentWithDots([id], _)), _, _) -> Some id.idText
| SynType.LongIdent(LongIdentWithDots([id], _)) -> Some id.idText // NOTE: again, not a static constant, but may be a prefix of a Named in incomplete code
Expand Down Expand Up @@ -145,9 +145,9 @@ module internal NoteworthyParamInfoLocationsImpl =
NotFound, Some inner
| _ -> NotFound, Some inner

let (|StaticParameters|_|) pos synType =
let (|StaticParameters|_|) pos (StripParenTypes synType) =
match synType with
| SynType.App(SynType.LongIdent(LongIdentWithDots(lid, _) as lidwd), Some(openm), args, commas, closemOpt, _pf, wholem) ->
| SynType.App(StripParenTypes (SynType.LongIdent(LongIdentWithDots(lid, _) as lidwd)), Some(openm), args, commas, closemOpt, _pf, wholem) ->
let lidm = lidwd.Range
let betweenTheBrackets = mkRange wholem.FileName openm.Start wholem.End
if AstTraversal.rangeContainsPosEdgesExclusive betweenTheBrackets pos && args |> List.forall isStaticArg then
Expand Down
3 changes: 2 additions & 1 deletion src/fsharp/service/ServiceParseTreeWalk.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace FSharp.Compiler.SourceCodeServices

open FSharp.Compiler.Range
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.SyntaxTreeOps

/// A range of utility functions to assist with traversing an AST
module public AstTraversal =
Expand Down Expand Up @@ -518,7 +519,7 @@ module public AstTraversal =

visitor.VisitPat (defaultTraverse, pat)

and traverseSynType (ty: SynType) =
and traverseSynType (StripParenTypes ty) =
let defaultTraverse ty =
match ty with
| SynType.App (typeName, _, typeArgs, _, _, _, _)
Expand Down
5 changes: 3 additions & 2 deletions src/fsharp/service/ServiceUntypedParse.fs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ type FSharpParseFileResults(errors: FSharpErrorInfo[], input: ParsedInput option
| SynMemberDefn.AutoProperty(_attribs, _isStatic, _id, _tyOpt, _propKind, _, _xmlDoc, _access, synExpr, _, _) -> yield! walkExpr true synExpr
| SynMemberDefn.ImplicitCtor(_, _, _, _, m) -> yield! checkRange m
| SynMemberDefn.Member(bind, _) -> yield! walkBind bind
| SynMemberDefn.Interface(_synty, Some membs, _) -> for m in membs do yield! walkMember m
| SynMemberDefn.Interface(_, Some membs, _) -> for m in membs do yield! walkMember m
| SynMemberDefn.Inherit(_, _, m) ->
// can break on the "inherit" clause
yield! checkRange m
Expand Down Expand Up @@ -810,6 +810,7 @@ module UntypedParseImpl =
| SynType.HashConstraint(t, _) -> walkType t
| SynType.MeasureDivide(t1, t2, _) -> walkType t1 |> Option.orElse (walkType t2)
| SynType.MeasurePower(t, _, _) -> walkType t
| SynType.Paren(t, _) -> walkType t
| _ -> None

and walkClause (Clause(pat, e1, e2, _, _)) =
Expand Down Expand Up @@ -1140,7 +1141,7 @@ module UntypedParseImpl =
| (SynExpr.New (_, SynType.LongIdent typeName, arg, _)) ->
// new A()
Some (endOfLastIdent typeName, findSetters arg)
| (SynExpr.New (_, SynType.App(SynType.LongIdent typeName, _, _, _, mGreaterThan, _, _), arg, _)) ->
| (SynExpr.New (_, SynType.App(StripParenTypes (SynType.LongIdent typeName), _, _, _, mGreaterThan, _, _), arg, _)) ->
// new A<_>()
Some (endOfClosingTokenOrLastIdent mGreaterThan typeName, findSetters arg)
| (SynExpr.App (_, false, SynExpr.Ident id, arg, _)) ->
Expand Down
4 changes: 2 additions & 2 deletions tests/fsharp/typecheck/sigs/neg04.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ is not compatible with type
'IBar'


neg04.fs(144,10,144,25): typecheck error FS0193: Type constraint mismatch. The type
neg04.fs(144,10,144,26): typecheck error FS0193: Type constraint mismatch. The type
'int * int'
is not compatible with type
'IBar'
Expand All @@ -122,7 +122,7 @@ is not compatible with type
'IBar'


neg04.fs(150,10,150,26): typecheck error FS0193: Type constraint mismatch. The type
neg04.fs(150,10,150,27): typecheck error FS0193: Type constraint mismatch. The type
'int -> int'
is not compatible with type
'IBar'
Expand Down
3 changes: 3 additions & 0 deletions tests/service/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ let assertHasSymbolUsages (names: string list) (results: FSharpCheckFileResults)
for name in names do
Assert.That(Set.contains name symbolNames, name)

let getRangeCoords (r: range) =
(r.StartLine, r.StartColumn), (r.EndLine, r.EndColumn)

let coreLibAssemblyName =
#if NETCOREAPP
"System.Runtime"
Expand Down
Loading