Move LSP semantics into typed analysis
This commit is contained in:
parent
f4cd4f4458
commit
bac1183593
26 changed files with 1232 additions and 637 deletions
22
README.md
22
README.md
|
|
@ -19,6 +19,7 @@ the semantic Type-to-Go mapping turns a class such as `User` into `*User`.
|
|||
- `val` and `var`
|
||||
- `Int`, `Long`, `String`, `Boolean`, `Unit`
|
||||
- function types like `(String) -> Unit`
|
||||
- user generic functions and classes with inferred or explicit type arguments
|
||||
- `if`, `else`, `while`, and `for (item in items)`
|
||||
- function calls
|
||||
- lambdas like `{ x: Int -> println(x) }` and `{ println(it) }`
|
||||
|
|
@ -126,6 +127,27 @@ checked during Gotlin compilation. A match used as an expression also requires
|
|||
every arm to return the same type. Block-style statement matches remain
|
||||
available for side effects.
|
||||
|
||||
## User generics
|
||||
|
||||
Functions and classes may declare type parameters. Calls infer straightforward
|
||||
type bindings from arguments or accept explicit type arguments:
|
||||
|
||||
```kotlin
|
||||
data class Box<T>(var value: T) {
|
||||
fun get(): T { return value }
|
||||
}
|
||||
|
||||
fun identity<T>(value: T): T { return value }
|
||||
|
||||
val number = identity(42)
|
||||
val text = identity<String>("value")
|
||||
val box = Box("boxed")
|
||||
```
|
||||
|
||||
Type parameters currently use an implicit `Any` constraint. Generic methods
|
||||
with their own type parameters are intentionally deferred; place parameters on
|
||||
the enclosing class or a top-level function.
|
||||
|
||||
## Null safety
|
||||
|
||||
Types are non-nullable by default. Add `?` explicitly when `null` is valid:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue