| Commit-Queue | +1 |
Before sending this to Dart Model folks, does this look good to you, Daco?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
Before sending this to Dart Model folks, does this look good to you, Daco?
Yes, pkg/analyzer/test/src/diagnostics/tearoff_with_must_be_const_parameter_test.dart is exactly what I want! 🙏
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
var parent = node.parent;
if (parent is PropertyAccess && parent.propertyName == node) return;
if (parent is PrefixedIdentifier && parent.identifier == node) return;
if (parent is DotShorthandPropertyAccess && parent.propertyName == node) {
return;
}
if (parent is DotShorthandInvocation && parent.memberName == node) return;
if (parent is MethodInvocation && parent.methodName == node) return;Because we have specific `visitX` that do it already?
while (parent is ParenthesizedExpression) {
parent = parent.parent;
}See `unParenthesized`
class TearoffWithMustBeConstParameterTest extends PubPackageResolutionTest {Tests for dot-shorthands?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
var parent = node.parent;
if (parent is PropertyAccess && parent.propertyName == node) return;
if (parent is PrefixedIdentifier && parent.identifier == node) return;
if (parent is DotShorthandPropertyAccess && parent.propertyName == node) {
return;
}
if (parent is DotShorthandInvocation && parent.memberName == node) return;
if (parent is MethodInvocation && parent.methodName == node) return;Because we have specific `visitX` that do it already?
Correct. Let me know if you have a better way of handling this (I can add a comment). But since a SimpleIdentifier can be a tear-off itself (like a top-level function), I do have to visit SimpleIdentifier.
while (parent is ParenthesizedExpression) {
parent = parent.parent;
}Samuel RawlinsSee `unParenthesized`
I like that helper. I wish we had a similar one that unwrapped to the parent.
If this expression is a parenthesized expression, returns the result of unwrapping the expression inside the parentheses. Otherwise, returns this expression.
class TearoffWithMustBeConstParameterTest extends PubPackageResolutionTest {Samuel RawlinsTests for dot-shorthands?
I don't think there is any way for a dot-shorthand to be torn off. This is illegal:
```
class C {}
C c1 = .new(); // OK
C Function() c2 = .new(); // Compile-time error.
C c3 = (.new)(); // Compile-time error.
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
analyzer: Implement "do not tear-off function with @mustBeConst parameter" warning
Fixes https://github.com/dart-lang/sdk/issues/62472
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |