diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index c52fb1cf8aa..2b087095649 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -10779,6 +10779,7 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn let mAttr = synAttr.Range let typath, tyid = List.frontAndBack tycon let tpenv = emptyUnscopedTyparEnv + let ad = env.eAccessRights // if we're checking an attribute that was applied directly to a getter or a setter, then // what we're really checking against is a method, not a property @@ -10787,13 +10788,12 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn let try1 n = let tyid = mkSynId tyid.idRange n let tycon = (typath @ [tyid]) - let ad = env.eAccessRights + match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInAttribute OpenQualified env.eNameResEnv ad tycon TypeNameResolutionStaticArgsInfo.DefiniteEmpty PermitDirectReferenceToGeneratedType.No with | Exception err -> raze err - | _ -> success(TcTypeAndRecover cenv NoNewTypars CheckCxs ItemOccurence.UseInAttribute WarnOnIWSAM.Yes env tpenv (SynType.App(SynType.LongIdent(SynLongIdent(tycon, [], List.replicate tycon.Length None)), None, [], [], None, false, mAttr)) ) - ForceRaise ((try1 (tyid.idText + "Attribute")) |> otherwise (fun () -> (try1 tyid.idText))) + | Result(tinstEnclosing, tcref) -> success(TcTypeApp cenv NoNewTypars CheckCxs ItemOccurence.UseInAttribute env tpenv mAttr tcref tinstEnclosing []) - let ad = env.eAccessRights + ForceRaise ((try1 (tyid.idText + "Attribute")) |> otherwise (fun () -> (try1 tyid.idText))) if not (IsTypeAccessible g cenv.amap mAttr ad ty) then errorR(Error(FSComp.SR.tcTypeIsInaccessible(), mAttr)) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs index d13efc2169a..ce9846a0ee5 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs @@ -165,4 +165,4 @@ let GetAllUsesOfAllSymbols() = traceProvider.ForceFlush() |> ignore traceProvider.Dispose() - Assert.Equal(80, result.Length) + Assert.Equal(79, result.Length) diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 8b495da8865..0c88b9cfbc8 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -781,7 +781,6 @@ type Class1() = su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn)) |> shouldEqual [|("LiteralAttribute", (3, 10, 3, 17)) - ("LiteralAttribute", (3, 10, 3, 17)) ("member .ctor", (3, 10, 3, 17)) ("val ModuleValue", (3, 20, 3, 31)) ("val op_Addition", (6, 26, 6, 27)) @@ -793,11 +792,9 @@ type Class1() = ("Class1", (10, 5, 10, 11)) ("member .ctor", (10, 5, 10, 11)) ("LiteralAttribute", (11, 10, 11, 17)) - ("LiteralAttribute", (11, 10, 11, 17)) ("member .ctor", (11, 10, 11, 17)) ("val ClassValue", (11, 20, 11, 30)) ("LiteralAttribute", (12, 17, 12, 24)) - ("LiteralAttribute", (12, 17, 12, 24)) ("member .ctor", (12, 17, 12, 24)) ("val StaticClassValue", (12, 27, 12, 43)) ("val ClassValue", (14, 12, 14, 22)) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 6fa72b4398f..156b2bd879e 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -2349,7 +2349,6 @@ let ``Test Project14 all symbols`` () = allUsesOfAllSymbols |> shouldEqual [|("StructAttribute", "StructAttribute", "file1", ((4, 2), (4, 8)), ["attribute"]); - ("StructAttribute", "StructAttribute", "file1", ((4, 2), (4, 8)), ["type"]); ("member .ctor", "StructAttribute", "file1", ((4, 2), (4, 8)), []); ("int", "int", "file1", ((5, 9), (5, 12)), ["type"]); ("int", "int", "file1", ((5, 9), (5, 12)), ["type"]); @@ -2504,14 +2503,10 @@ let ``Test Project16 all symbols`` () = allUsesOfAllSymbols |> shouldEqual [|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), ["attribute"], ["class"]); - ("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), ["type"], - ["class"]); ("member .ctor", "ClassAttribute", "sig1", ((8, 6), (8, 11)), [], ["member"]); ("ClassAttribute", "ClassAttribute", "sig1", ((12, 6), (12, 11)), ["attribute"], ["class"]); - ("ClassAttribute", "ClassAttribute", "sig1", ((12, 6), (12, 11)), ["type"], - ["class"]); ("member .ctor", "ClassAttribute", "sig1", ((12, 6), (12, 11)), [], ["member"]); ("int", "int", "sig1", ((16, 19), (16, 22)), ["type"], ["abbrev"]); @@ -5085,7 +5080,6 @@ let ``Test Project40 all symbols`` () = ("IsNone", ((4, 33), (4, 41)), ["member"; "prop"; "funky"]); ("f", ((4, 4), (4, 5)), ["val"]); ("CompilationRepresentationAttribute", ((6, 2), (6, 27)), ["class"]); - ("CompilationRepresentationAttribute", ((6, 2), (6, 27)), ["class"]); ("CompilationRepresentationAttribute", ((6, 2), (6, 27)), ["member"]); ("CompilationRepresentationFlags", ((6, 28), (6, 58)), ["enum"; "valuetype"]);