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

Disallow opaque type aliases of context functions #16041

Merged
merged 2 commits into from
Sep 15, 2022

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 14, 2022

We could allow them but they would not do what one probably expects (i.e. create context closures). This is because abstract types upper-bounded by context functions don't do that either (see neg/i16035a.scala), and we have to keep semantic equivalence between the two.

Therefore, it's better to disallow them.

Fixes #16035

We could allow them but they would not do what one probably expects (i.e. create
context closures). This is because abstract types upper-bounded by context functions
don't do that either (see neg/i16035a.scala), and we have to keep semantic equivalence
between the two.

Therefore, it's better to disallow them.

Fixes scala#16035
def recur(tp: Type): Unit = tp.dealias match
case tp: HKTypeLambda => recur(tp.resType)
case tp if defn.isContextFunctionType(tp) =>
report.error(em"context functon type cannot have opaque aliases", tree.srcPos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo function

@@ -1460,6 +1460,15 @@ trait Checking {
|CanThrow capabilities can only be generated $req.""",
pat.srcPos)

/** Check that tree does not define a context fucntion type */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also typo function

@Kordyjan Kordyjan merged commit efb7b6e into scala:main Sep 15, 2022
@Kordyjan Kordyjan deleted the fix-16035 branch September 15, 2022 17:25
@Kordyjan Kordyjan added this to the 3.2.2 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: Opaque types aliasing context functions are crashing the compiler
3 participants