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

A strawman for aggregate literals #21993

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

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 20, 2024

A test case that shows that we can have an "inline type class" that allows to use a typeclass-based scheme for sequence literals where instances can be created with macros.

@odersky odersky marked this pull request as draft November 25, 2024 11:09
A test case that shows that we can have an "inline type class" that allows
to use a typeclass-based scheme for sequence literals where instances can
be created with macros.
Also: Move test to run
We now don't try to instantiate selected type variables. Instead, we use a default as fallback if
the expected type is underspecified according to the definition in Implicits. This is
simpler and more expressive.
@soronpo
Copy link
Contributor

soronpo commented Nov 25, 2024

From the doc I understand that implicit conversions are not applicable. Is weak conformance applicable?
What is expected for val oneTwoThreeDbl: Seq[Double] = [1, 2, 3]?

@odersky
Copy link
Contributor Author

odersky commented Nov 25, 2024

The successor of weak conformance (int literal widening) is usually applicable. That follows from the fact that SeqLiterals expand to varargs and varargs do perform that widening.

@@ -278,6 +278,7 @@ SimpleExpr ::= SimpleRef
| ‘new’ ConstrApp {‘with’ ConstrApp} [TemplateBody] New(constr | templ)
| ‘new’ TemplateBody
| ‘(’ ExprsInParens ‘)’ Parens(exprs)
| ‘[’ ExprInBrackets ‘)’ SeqLiteral(exprs, TypeTree())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| ‘[’ ExprInBrackets ‘)’ SeqLiteral(exprs, TypeTree())
| ‘[’ ExprInBrackets ‘]’ SeqLiteral(exprs, TypeTree())

just noticed while having a look

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.

3 participants