Skip to content

Commit eee7567

Browse files
forkibaronfel
authored andcommitted
Inline isRecdTy (#8274)
1 parent 49428d6 commit eee7567

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/fsharp/NameResolution.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,11 +3214,12 @@ let ResolveFieldPrim sink (ncenv: NameResolver) nenv ad ty (mp, id: Ident) allFi
32143214
|> ListSet.setify (fun fref1 fref2 -> tyconRefEq g fref1.TyconRef fref2.TyconRef)
32153215
|> List.map (fun x -> ResolutionInfo.Empty, FieldResolution(x, false))
32163216

3217-
if isAppTy g ty then
3217+
match tryDestAppTy g ty with
3218+
| ValueSome tcref ->
32183219
match ncenv.InfoReader.TryFindRecdOrClassFieldInfoOfType(id.idText, m, ty) with
32193220
| ValueSome (RecdFieldInfo(_, rfref)) -> [ResolutionInfo.Empty, FieldResolution(rfref, false)]
32203221
| _ ->
3221-
if isRecdTy g ty then
3222+
if tcref.IsRecordTycon then
32223223
// record label doesn't belong to record type -> suggest other labels of same record
32233224
let suggestLabels (addToBuffer: string -> unit) =
32243225
for label in SuggestOtherLabelsOfSameRecordType g nenv ty id allFields do
@@ -3229,7 +3230,7 @@ let ResolveFieldPrim sink (ncenv: NameResolver) nenv ad ty (mp, id: Ident) allFi
32293230
error(ErrorWithSuggestions(errorText, m, id.idText, suggestLabels))
32303231
else
32313232
lookup()
3232-
else
3233+
| _ ->
32333234
lookup()
32343235
| _ ->
32353236
let lid = (mp@[id])

src/fsharp/TypeChecker.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6876,7 +6876,7 @@ and TcObjectExpr cenv overallTy env tpenv (synObjTy, argopt, binds, extraImpls,
68766876
match tryDestAppTy cenv.g objTy with
68776877
| ValueNone -> error(Error(FSComp.SR.tcNewMustBeUsedWithNamedType(), mNewExpr))
68786878
| ValueSome tcref ->
6879-
let isRecordTy = isRecdTy cenv.g objTy
6879+
let isRecordTy = tcref.IsRecordTycon
68806880
if not isRecordTy && not (isInterfaceTy cenv.g objTy) && isSealedTy cenv.g objTy then errorR(Error(FSComp.SR.tcCannotCreateExtensionOfSealedType(), mNewExpr))
68816881

68826882
CheckSuperType cenv objTy synObjTy.Range
@@ -7265,12 +7265,12 @@ and TcAnonRecdExpr cenv overallTy env tpenv (isStruct, optOrigSynExpr, unsortedF
72657265
for (i, id) in Array.indexed anonInfo.SortedIds do
72667266
yield id, Choice2Of2 (mkAnonRecdFieldGetViaExprAddr (anonInfo, oldveaddr, tinst, i, mOrigExpr))
72677267
| ValueNone ->
7268-
if isRecdTy cenv.g origExprTy then
7269-
let tcref, tinst = destAppTy cenv.g origExprTy
7268+
match tryAppTy cenv.g origExprTy with
7269+
| ValueSome(tcref, tinst) when tcref.IsRecordTycon ->
72707270
let fspecs = tcref.Deref.TrueInstanceFieldsAsList
72717271
for fspec in fspecs do
72727272
yield fspec.Id, Choice2Of2 (mkRecdFieldGetViaExprAddr (oldveaddr, tcref.MakeNestedRecdFieldRef fspec, tinst, mOrigExpr))
7273-
else
7273+
| _ ->
72747274
error (Error (FSComp.SR.tcCopyAndUpdateNeedsRecordType(), mOrigExpr)) |]
72757275
|> Array.distinctBy (fst >> textOfId)
72767276

0 commit comments

Comments
 (0)