Commit baa7da3
Elements. Fix method top-merge reuse and default constructor flag
Correct two issues in element handling:
* In `InheritanceManager3._topMerge`, when merging methods, check for
an existing `MethodElementImpl` at `@method/<name>` (not a setter).
If present, reuse it; otherwise assert the slot is empty before
synthesizing. Similar assertions are added to getter/setter paths to
guard against accidental reuse of a wrong-kind element.
* In `SubstitutedConstructorElementImpl`, fix
`isDefaultConstructor` to forward to
`baseElement.isDefaultConstructor` (it previously forwarded to
`isConst`).
These changes prevent creating fresh synthetic methods when a correct
method already exists, preserving element identity and avoiding
wrong-kind lookups. The constructor fix restores accurate default
constructor detection, which can affect downstream diagnostics and
presentation.
Additional tests cover method top-merge in both “existing” and
“synthetic” scenarios, aligning method coverage with existing
getter/setter cases.
Change-Id: I09c3aaa7cb89f216d6d3101bbad835567df5b213
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447961
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>1 parent 51b7329 commit baa7da3
File tree
3 files changed
+26
-3
lines changed- pkg/analyzer
- lib/src/dart/element
- test/src/dart/element
3 files changed
+26
-3
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1069 | 1069 | | |
1070 | 1070 | | |
1071 | 1071 | | |
1072 | | - | |
| 1072 | + | |
1073 | 1073 | | |
1074 | 1074 | | |
| 1075 | + | |
1075 | 1076 | | |
1076 | 1077 | | |
1077 | 1078 | | |
| |||
1106 | 1107 | | |
1107 | 1108 | | |
1108 | 1109 | | |
| 1110 | + | |
1109 | 1111 | | |
1110 | 1112 | | |
1111 | 1113 | | |
| |||
1120 | 1122 | | |
1121 | 1123 | | |
1122 | 1124 | | |
| 1125 | + | |
1123 | 1126 | | |
1124 | 1127 | | |
1125 | 1128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1216 | 1216 | | |
1217 | 1217 | | |
1218 | 1218 | | |
1219 | | - | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1220 | 1240 | | |
1221 | 1241 | | |
1222 | 1242 | | |
| |||
0 commit comments