Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better handling of functional types in rendered output #1483

Merged
merged 1 commit into from
Sep 28, 2020

Conversation

BarkingBad
Copy link
Contributor

@BarkingBad BarkingBad commented Sep 17, 2020

260 lines are just tests

val n1: Function1<Int, String> = { _ -> "" }
val n2: (Int) -> String = { _ -> "" }
val n3: Boolean.(Int) -> String = { _ -> "" }
val n4: (param: Int) -> String = { _ -> "" }
val n5: suspend (Int) -> String = { _ -> "" }
val n6: suspend Boolean.(Int) -> String = { _ -> "" }
val n7: suspend (param: Int) -> String = { _ -> "" }
val n8: suspend (param1: suspend Boolean.(param2: List<Int>) -> Boolean) -> String = { _ -> "" }

obraz

@BarkingBad BarkingBad force-pushed the fix-signatures-for-functional-types branch from 6f578f4 to 3e4ab18 Compare September 17, 2020 13:23
@BarkingBad
Copy link
Contributor Author

BarkingBad commented Sep 17, 2020

Also works for Java sources

public class JavaClass {
    public java.util.function.Function<String, Integer> javaFunction = null;
    public kotlin.jvm.functions.Function1<String, Integer> kotlinFunction = null;
}

obraz

@MarcinAman
Copy link
Contributor

why val n1: Function1<Int, String> = { _ -> "" } is represented the same as (Int) -> String = { _ -> "" }? shouldn't we preserve information about the type exactly?

@BarkingBad
Copy link
Contributor Author

@MarcinAman because (Int) -> String and Function1<Int, String> are exactly the same type, former is just syntactic sugar

@MarcinAman
Copy link
Contributor

Oh ok, was just wondering if this was intentional. If so then ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants