-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Account for
AllowNullLiteralAttribute
when checking attribute targe…
…ts (#17583)
- Loading branch information
Showing
5 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...ts/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AllowNullLiteral01.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[<AllowNullLiteral>] | ||
type D() = | ||
member x.P = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ts/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AllowNullLiteral.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module AllowNullLiteralTest = begin | ||
|
||
//[<AllowNullLiteral>] | ||
type I = | ||
interface | ||
abstract P : int | ||
end | ||
|
||
//[<AllowNullLiteral>] | ||
type C() = | ||
member x.P = 1 | ||
|
||
|
||
[<AllowNullLiteral>] | ||
type D() = | ||
inherit C() | ||
interface I with | ||
member x.P = 2 | ||
member x.P = 1 | ||
|
||
let d = (null : D) | ||
|
||
let d2 = ((box null) :?> D) | ||
|
||
|
||
[<AllowNullLiteral>] // expect an error here | ||
type S(c:int) = struct end | ||
|
||
[<AllowNullLiteral>] // expect an error here | ||
type R = { r : int } | ||
|
||
[<AllowNullLiteral>] // expect an error here | ||
type U = A | B of int | ||
|
||
[<AllowNullLiteral>] // expect an error here | ||
type E = A = 1 | B = 2 | ||
|
||
[<AllowNullLiteral>] // expect an error here | ||
type Del = delegate of int -> int | ||
|
||
[<AllowNullLiteral>] // expect an error here | ||
let x = 1 | ||
|
||
[<AllowNullLiteral>] // expect an error here | ||
let f x = 1 | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters