mirror of
https://github.com/enso-org/enso.git
synced 2024-11-26 17:06:48 +03:00
Don't propagate warnings on suspended arguments (#6345)
* Don't propagate warnings on suspended arguments In the current implementation, application of arguments with warnings first extracts warnings, does the application and appends the warnings to the result. This process was however too eager if the suspended argument was a literal (we don't know if it will be executed after all). The change modifies method processor to take into account the `@Suspend` annotation and not gather warnings before the application takes place. * PR review
This commit is contained in:
parent
0088672f9b
commit
4c1e73c864
@ -549,11 +549,11 @@ public class MethodDefinition {
|
||||
}
|
||||
|
||||
public boolean shouldCheckErrors() {
|
||||
return isPositional() && !isSelf() && !acceptsError();
|
||||
return isPositional() && !isSelf() && !acceptsError() && !isSuspended();
|
||||
}
|
||||
|
||||
public boolean shouldCheckWarnings() {
|
||||
return isPositional() && !isSelf() && !acceptsWarning();
|
||||
return isPositional() && !isSelf() && !acceptsWarning() && !isSuspended();
|
||||
}
|
||||
|
||||
public boolean isImplicit() {
|
||||
|
@ -1,11 +1,12 @@
|
||||
from Standard.Base import all
|
||||
import Standard.Base.Errors.Unimplemented.Unimplemented
|
||||
import Standard.Base.Errors.Illegal_State.Illegal_State
|
||||
|
||||
polyglot java import java.lang.Long
|
||||
polyglot java import java.util.function.Function as Java_Function
|
||||
polyglot java import org.enso.base_test_helpers.CallbackHelper
|
||||
|
||||
from Standard.Test import Test, Test_Suite
|
||||
from Standard.Test import Test, Test_Suite, Problems
|
||||
import Standard.Test.Extensions
|
||||
|
||||
type My_Warning
|
||||
@ -370,5 +371,22 @@ spec = Test.group "Dataflow Warnings" <|
|
||||
a.remove_warnings . should_equal 42
|
||||
b.remove_warnings . should_equal 42
|
||||
|
||||
Test.specify "should not automatically propagate from suspended arguments" <|
|
||||
x1 = 33
|
||||
x2 = Warning.attach "WARN" 44
|
||||
x3 = Error.throw (Illegal_State.Error "ERR")
|
||||
|
||||
condition_1 x y = if x then y else 42
|
||||
condition_2 x y = if x then y + 100 else 42
|
||||
|
||||
Problems.assume_no_problems <| condition_1 False x1
|
||||
Problems.assume_no_problems <| condition_2 False x1
|
||||
|
||||
Problems.assume_no_problems <| condition_1 False x2
|
||||
Problems.assume_no_problems <| condition_2 False x2
|
||||
|
||||
Problems.assume_no_problems <| condition_1 False x3
|
||||
Problems.assume_no_problems <| condition_2 False x3
|
||||
|
||||
|
||||
main = Test_Suite.run_main spec
|
||||
|
Loading…
Reference in New Issue
Block a user