-
Notifications
You must be signed in to change notification settings - Fork 1.1k
A strawman for aggregate literals #21993
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
Conversation
a728906
to
6e904fb
Compare
From the doc I understand that implicit conversions are not applicable. Is weak conformance applicable? |
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. |
docs/_docs/internals/syntax.md
Outdated
@@ -278,6 +278,7 @@ SimpleExpr ::= SimpleRef | |||
| ‘new’ ConstrApp {‘with’ ConstrApp} [TemplateBody] New(constr | templ) | |||
| ‘new’ TemplateBody | |||
| ‘(’ ExprsInParens ‘)’ Parens(exprs) | |||
| ‘[’ ExprInBrackets ‘)’ SeqLiteral(exprs, TypeTree()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ‘[’ ExprInBrackets ‘)’ SeqLiteral(exprs, TypeTree()) | |
| ‘[’ ExprInBrackets ‘]’ SeqLiteral(exprs, TypeTree()) |
just noticed while having a look
3830475
to
599d51c
Compare
I got a crash in the repl by just having |
Also, maybe this is expected as its just for testing, but some of the instances for scala> val m: Set[Int] = [1,2,3]
1 warning found
-- Warning: --------------------------------------------------------------------
1 |val m: Set[Int] = [1,2,3]
| ^
|Given search preference for scala.compiletime.ExpressibleAsCollectionLiteral[Set[Int]] between alternatives
| scala.compiletime.ExpressibleAsCollectionLiteral.bitsetFromLiteral.type
|and
| (scala.compiletime.ExpressibleAsCollectionLiteral.setFromLiteral :
| [T]: scala.compiletime.ExpressibleAsCollectionLiteral.setFromLiteral[T])
|will change.
|Current choice : the first alternative
|New choice from Scala 3.7: none - it's ambiguous
val m: Set[Int] = BitSet(1, 2, 3) |
@bishabosha In fact, the given instances are set up so that it works properly only from 3.7 onwards. |
Does that mean the warning is a false positive? |
No, the warning is real. The given instances are set up so that they work properly only from 3.7. |
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.
Also, test infix operations taking [...] as a right operand.
28700de
to
4b8a832
Compare
See https://contributors.scala-lang.org/t/pre-sip-a-syntax-for-collection-literals/6990/186 for the Pre SIP discussion. |
Closing to relieve the PR queue. We can come back to this later. |
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.