-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 2091 - D2 final cannot be applied to variable
D2 has `const` ro represent readonly data, therefore the error and suggestion "perhaps you meant const?" is normally legitimate. But, if the `final` attribute comes from a label or block style syntax, it's too restrict against class member layout. To lift the limitation, display the error only when `final` is *directly* applied on a variable. Use same method to `synchrionized`, `abstract`, and `override`.
- Loading branch information
Showing
5 changed files
with
52 additions
and
23 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
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
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
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
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,34 @@ | ||
| // REQUIRED_ARGS: -o- | ||
|
|
||
| /* | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/failattr.d(16): Error: variable failattr.C2901.v1 cannot be synchronized | ||
| fail_compilation/failattr.d(17): Error: variable failattr.C2901.v2 cannot be override | ||
| fail_compilation/failattr.d(18): Error: variable failattr.C2901.v3 cannot be abstract | ||
| fail_compilation/failattr.d(19): Error: variable failattr.C2901.v4 cannot be final, perhaps you meant const? | ||
| fail_compilation/failattr.d(31): Error: variable failattr.C2901.v13 cannot be final abstract synchronized override | ||
| fail_compilation/failattr.d(33): Error: variable failattr.C2901.v14 cannot be final, perhaps you meant const? | ||
| --- | ||
| */ | ||
| class C2901 | ||
| { | ||
| synchronized int v1; // error | ||
| override int v2; // error | ||
| abstract int v3; // error | ||
| final int v4; // error | ||
|
|
||
| synchronized { int v5; } // no error | ||
| override { int v6; } // no error | ||
| abstract { int v7; } // no error | ||
| final { int v8; } // no error | ||
|
|
||
| synchronized: int v9; // no error | ||
| override: int v10; // no error | ||
| abstract: int v11; // no error | ||
| final: int v12; // no error | ||
|
|
||
| synchronized override abstract final int v13; // one line error | ||
|
|
||
| static final int v14; // error, even if static is applied at the same time | ||
| } |