You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit de966e2
Browse filesBrowse the repository at this point in the historyBrowse files
Address review: check instance signatures, abstract bounds and invalid bounds
Instance methods were matched by name only, so an implementation with the wrong
parameter types, parameter count or return type was accepted and emitted, leaving
the error to pjass. Compare against the requirement with the interface's type
parameter replaced by the instance type, and report the expected signature.
A type argument which is itself a type parameter was accepted unconditionally.
That let a generic without the bound pass its parameter to one that needs it: the
call type checked but had no instance to dispatch to at runtime. Such an argument
now has to declare the bound itself.
Bounds which do not name a usable type class were silently dropped, so a bound on
a class or an applied interface became a no-op. They are reported at the bound.
Interfaces which extend another interface are rejected as bounds, at the bound and
at the instance: the requirements of a bound are the interface's own functions, so
allowing inheritance would silently omit the inherited ones.
Copy file name to clipboardExpand all lines: de.peeeq.wurstscript/src/main/resources/agent-docs/WURST_LANGUAGE.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,6 +184,18 @@ Unlike an interface used as a supertype, a bound works for `int`, `real`, `strin
184
184
185
185
Instances are unique and must be declared next to what they relate. An instance of `I` for type `X` may only live in the package declaring `I` or the package declaring `X`, and there may be only one. This makes `I` for `X` mean the same thing everywhere, independent of imports. Instances have no type parameters of their own in this version, so there is no way to write "every `List<T>` is `Indexable` when `T` is".
186
186
187
+
An instance must implement each requirement with the signature it has after the interface's type parameter is replaced by the instance type; a matching name is not enough. An interface used as a bound must not extend another interface, because the requirements of a bound are the interface's own functions.
188
+
189
+
A generic which passes its own type parameter to another bounded generic must declare that bound itself:
190
+
191
+
```wurst
192
+
function inner<Q: Show>(Q x) returns string
193
+
return Q.show(x)
194
+
195
+
function outer<R: Show>(R x) returns string // <R:> alone would not compile
196
+
return inner(x)
197
+
```
198
+
187
199
## Lua and Jass targets
188
200
189
201
The target is selected by the project `wurst.build``scriptMode` field. `wc3Patch` separately selects the compatible core Jass and standard-library era.
0 commit comments