Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer should report issues with @literal #34259

Closed
srawlins opened this issue Aug 25, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@srawlins
Copy link
Member

commented Aug 25, 2018

As per literal's docs, the analyzer should report (Hints) when:

  • the annotation is associated with something other than a const constructor,
  • an invocation of a constructor annotated with @literal is not const.

dart-bot pushed a commit that referenced this issue Jan 3, 2019

Impl of INVALID_LITERAL_ANNOTATION
Bug: #34259
Change-Id: Ia5ca627a89dcb3f0fcd5ce74048df8fdf9dd9c9c
Reviewed-on: https://dart-review.googlesource.com/c/88283
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

dart-bot pushed a commit that referenced this issue Jan 8, 2019

Add a Hint enforcing contract of @literal
Example code:

```dart
import 'package:meta/meta.dart';

class A {
  @literal
  const A();

  @literal
  const A.named();
}

var a = A();
var b = const A();
const c = A();
var d = new A();

var e = new A.named();
```

Produces:

Analyzing b.dart...
  hint • This instance creation must be 'const', because the A constructor is marked as '@literal' at b.dart:11:9 • non_const_call_to_literal_constructor
  hint • This instance creation must be 'const', because the A constructor is marked as '@literal' at b.dart:14:9 • non_const_call_to_literal_constructor
  hint • This instance creation must be 'const', because the A.named constructor is marked as '@literal' at b.dart:16:9 • non_const_call_to_literal_constructor
3 hints found.

Bug: #34259
Change-Id: Iba10e5e0a0b2d0f7e99556cd6c201cea229ad675
Reviewed-on: https://dart-review.googlesource.com/c/88422
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>

@srawlins srawlins closed this Jan 8, 2019

dart-bot pushed a commit that referenced this issue Jan 8, 2019

Add note about new Literal codes
Bug: #34259
Change-Id: I0efd1c750f453b76e7e91482abc5843196c5b8ad
Reviewed-on: https://dart-review.googlesource.com/c/88761
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.