File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -2167,11 +2167,16 @@ object Parsers {
2167
2167
else atSpan((t.span union cbs.head.span).start) { ContextBounds (t, cbs) }
2168
2168
}
2169
2169
2170
+ /** ContextBound ::= Type [`as` id] */
2171
+ def contextBound (pname : TypeName ): Tree =
2172
+ ContextBoundTypeTree (toplevelTyp(), pname)
2173
+
2170
2174
def contextBounds (pname : TypeName ): List [Tree ] =
2171
2175
if in.isColon then
2172
- atSpan(in.skipToken()) {
2173
- ContextBoundTypeTree (toplevelTyp(), pname)
2174
- } :: contextBounds(pname)
2176
+ in.nextToken()
2177
+ if in.token == LBRACE && in.featureEnabled(Feature .modularity)
2178
+ then inBraces(commaSeparated(() => contextBound(pname)))
2179
+ else contextBound(pname) :: contextBounds(pname)
2175
2180
else if in.token == VIEWBOUND then
2176
2181
report.errorOrMigrationWarning(
2177
2182
em " view bounds `<%' are no longer supported, use a context bound `:' instead " ,
Original file line number Diff line number Diff line change
1
+ //> using options -language:experimental.modularity -source future
2
+
3
+ trait FromString :
4
+ type Self
5
+ def fromString (s : String ): Self
6
+
7
+ given Int is FromString = _.toInt
8
+
9
+ given Double is FromString = _.toDouble
10
+
11
+ def add [N : {FromString , Numeric }](a : String , b : String ): N =
12
+ val num = summon[Numeric [N ]]
13
+ num.plus(N .fromString(a), N .fromString(b))
You can’t perform that action at this time.
0 commit comments