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
I was thinking about possible extra possibilities for the Contract annotation.
I have this example already; I will add more as I stumble upon them:
Consider this method:
The method should do the following things; as described by the contract:
Throw an NPE, if the parameter is null
Wrap the parameter Reference (if not instanceof CacheReference, else see next) into a CacheReference
Return first parameter if the first parameter is instanceof CacheReference (which is already imported due to return type; return types should be validated by paramN)
Now, obviously this contract won't work, because it doesn't know about more things than nulls; really. Given other capabilities of IntelliJ, it should be fairly easy coming up with a simple, standalone concept for advanced Contract syntax.
The text was updated successfully, but these errors were encountered:
where after a method calls isOnline() and checks whether it returns true (e.g. by throwing when its false), the analyzer would know that mod.getPlayers().get(playerId) will not return null when invoked with the same playerId parameter.
I was thinking about possible extra possibilities for the
Contract
annotation.I have this example already; I will add more as I stumble upon them:
Consider this method:
The method should do the following things; as described by the contract:
null
Reference
(if notinstanceof CacheReference
, else see next) into aCacheReference
instanceof CacheReference
(which is already imported due to return type; return types should be validated byparamN
)Now, obviously this contract won't work, because it doesn't know about more things than nulls; really. Given other capabilities of IntelliJ, it should be fairly easy coming up with a simple, standalone concept for advanced
Contract
syntax.The text was updated successfully, but these errors were encountered: