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

Experiment: restrict allowed trees in annotations #21840

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Oct 23, 2024

Non-basic trees in type annotations currently cause compiler crashes. This experiment introduces restrictions on the trees allowed in annotations, similar to those in Java (§9.7. Annotations).

@mbovel mbovel force-pushed the mb/restrict-type-annotations branch from 009c2a4 to a1d0910 Compare October 23, 2024 18:35
@mbovel mbovel changed the title Experiment: restrict allowed trees in type annotations Experiment: restrict allowed trees in annotations Oct 24, 2024
@mbovel mbovel force-pushed the mb/restrict-type-annotations branch 3 times, most recently from f2779a0 to 5455c5d Compare November 5, 2024 22:08
@mbovel
Copy link
Member Author

mbovel commented Nov 6, 2024

def compose1[A, B, C](f: A => B, g: B => C): A ->{f, g} C =
z => g(f(z))

In this test, Ident(f) has type Function1[A, A], and is therefore not considered valid with the current rules. Why doesn't f have a singleton type?

f also does not have a symbol.

@mbovel
Copy link
Member Author

mbovel commented Nov 6, 2024

val value: Expr[Int] = '{ 42 }
'{ new Quoted[T @Annot($value)] }

Another question is what to do with splices, such as in the example above. Type splices are not valid anyway, so it might be okay to also refuse splices in type annotations?

mbovel and others added 3 commits November 6, 2024 14:33
@mbovel mbovel force-pushed the mb/restrict-type-annotations branch from 5455c5d to 2cc6ea4 Compare November 6, 2024 13:58
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.

1 participant