Comments (4)
It seems like it should infer the type
String
for the initialfinal banana = ...
and then there should be an error when theaugment final banana
inherits that type, and tries to assign a function to it.
Yes, this is how it should work (not sure if it is specified explicitly). In the macro spec we do say this "We don't allow augmentations of existing declarations to contribute to inference, so in phase 3 type inference can be performed.". That should be clarified in the augmentations spec as well though, I don't see it there.
from language.
That's what I expected.
It does mean that var x;
cannot be augmented to have a non-dynamic
type by providing an initializer. Which I guess i fine, you should type your var x
's that shouldn't be dynamic
.
from language.
you should type your var x's that shouldn't be dynamic.
Exactly, without a user-visible initializer at the declaration site I think the explicit type is anyways warranted, even if we could infer types based off of a later provided initializer.
from language.
I think the remaining work here is clarifying in the augmentations spec? Thanks.
from language.
Related Issues (20)
- Support paired-up private and public variables: "Private var, public final" HOT 3
- Let a wildcard as an actual type argument indicate a request for inference HOT 2
- Partial Record destructuring HOT 4
- Is future returned immediatelly from async call? Inconsistency in docs HOT 3
- Allow augmenting member declarations immediately in the same body? HOT 7
- [parts-with-imports] Consider dropping the library name from the library directive HOT 1
- Infer the type of an optional parameter from the default value
- Should digit separators be supported in int.fromEnvironment? HOT 1
- Support for Rust like #[cfg()] attributes HOT 10
- [parts-with-imports] Conditional part directives and the analyzer HOT 20
- Allow all variable augmentations to omit the initializing expression HOT 4
- `Error: Method not found` when running Flutter app with macro class HOT 2
- Allow a variable initializer to be unresolved, following the treatment of abstract members HOT 3
- Allow Iterators To Use The for-in Syntax HOT 5
- Macros: Emit diagnostics inside macro arguments HOT 2
- URI shorthands without internal whitespace.
- URI shorthands, allow reserved words.
- URI shorthands, more permissive HOT 1
- Inheriting a type parameter bound?
- Ordering of augmenting initializers and getters on late variables
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from language.