-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Variable-arity returns and function contracts. (#6568)
* Add function contracts. * Use contract in place of reference. * Add permissible single return support. * Provide contract in signature during verification. * Allow contract in function creation. * No longer defer basic use to contract. * Add contract to clamp function. * Add tests for singular clamping. * Update src/test/skript/tests/syntaxes/functions/clamp.sk Co-authored-by: Patrick Miller <[email protected]> * Sorry nice annotation, you're going to a "better" place :( * Move stuff around in circles. * Sovde made me change the assertions. :( * Move everything (again) * Add null annotation. --------- Co-authored-by: Patrick Miller <[email protected]> Co-authored-by: sovdee <[email protected]>
- Loading branch information
1 parent
524dc18
commit 389dbf9
Showing
9 changed files
with
163 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* This file is part of Skript. | ||
* | ||
* Skript is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Skript is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Skript. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright Peter Güttinger, SkriptLang team and contributors | ||
*/ | ||
package ch.njol.skript.util; | ||
|
||
import ch.njol.skript.lang.Expression; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
/** | ||
* The 'contract' of a function or another callable. | ||
* This is a non-exhaustive helper for type hints, singularity, etc. that may change based on the arguments | ||
* passed to a callable, in order for it to make better judgements on correct use at parse time. | ||
*/ | ||
public interface Contract { | ||
|
||
/** | ||
* @return Whether, given these parameters, this will return a single value | ||
* @see Expression#isSingle() | ||
*/ | ||
boolean isSingle(Expression<?>... arguments); | ||
|
||
/** | ||
* @return What this will return, given these parameters | ||
* @see Expression#getReturnType() | ||
*/ | ||
@Nullable | ||
Class<?> getReturnType(Expression<?>... arguments); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters