Skip to content

Commit

Permalink
Add typar to member when parent type contains the same letter. (#15445)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
  • Loading branch information
nojaf and T-Gro authored Jun 21, 2023
1 parent 2e9719a commit e82744c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Compiler/Checking/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,8 +1266,21 @@ module PrintTastMemberOrVals =
layoutTyconRef denv vref.MemberApparentEntity ^^ SepL.dot ^^ nameL
else
nameL

let memberHasSameTyparNameAsParentTypeTypars =
let parentTyparNames =
vref.DeclaringEntity.TyparsNoRange
|> Seq.choose (fun tp -> if tp.typar_id.idText = unassignedTyparName then None else Some tp.typar_id.idText)
|> set
niceMethodTypars
|> Seq.exists (fun tp -> parentTyparNames.Contains tp.typar_id.idText)

let typarOrderMismatch = isTyparOrderMismatch niceMethodTypars argInfos
let nameL = if denv.showTyparBinding || typarOrderMismatch then layoutTyparDecls denv nameL true niceMethodTypars else nameL
let nameL =
if denv.showTyparBinding || typarOrderMismatch || memberHasSameTyparNameAsParentTypeTypars then
layoutTyparDecls denv nameL true niceMethodTypars
else
nameL
let nameL = layoutAccessibility denv vref.Accessibility nameL
nameL

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module V

type 'a Foo =
{
Bar: 'a array
D: int
}
member _.Make1<'b> (array: 'a array) : 'a Foo = failwith "meh"
member _.Make2<'a> (array: 'a array) : 'a Foo = failwith "meh"

0 comments on commit e82744c

Please sign in to comment.