Skip to content

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

|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