Distinguish between pure and impure function types by odersky · Pull Request #14134 · scala/scala3

1 min read Original article ↗

@odersky odersky changed the title Generate "Impure" function aliases Distinguish between pure and impure function types

Dec 19, 2021

@odersky

 1. Allow `->` and `?->` and function operators, treated like `=>` and `?=>`.
 2. under -Ycc treat `->` and `?->` as immutable function types, whereas `A => B`
    is an alias of `{*} A -> B` and `A ?=> B` is an alias of `{*} A ?-> B`.

Closures are unaffected, we still use `=>` for all closures where they are pure or not.
Improve printing of capturing types

Avoid explicit retains annotations also outside phase cc
Generate "Impure" function aliases

For every (possibly erased and/or context) function class
XFunctionN, generate an alias ImpureXFunctionN in the Scala package defined as

    type ImpureXFunctionN[...] = {*} XFunctionN[...]

Also:

 - Fix a bug in TypeComparer: glb has to test subCapture in a frozen state
 - Harden EventuallyCapturingType extractor to not crash on illegal capture sets
 - Cleanup transformation of inferred types