Skip to content

Commit 8d8777e

Browse files
committed
Support multiple type param clauses for extension method
By combining two type param clause into one
1 parent cfa4378 commit 8d8777e

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

compiler/src/dotty/tools/dotc/semanticdb/TypeOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class TypeOps:
152152
paramRefSymtab.getOrErr((pt, paramName), sym)
153153
}
154154
// there shouldn't multiple type params
155-
flatten(pt.resType, paramss, syms)
155+
flatten(pt.resType, paramss, tparams ++ syms)
156156
case other =>
157157
(other, paramss, tparams)
158158
}

tests/semanticdb/expect/Extension.expect.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ trait Read/*<-ext::Read#*/[+T/*<-ext::Read#[T]*/]:
1313

1414
extension (s/*<-ext::Extension$package.readInto().(s)*/: String/*->scala::Predef.String#*/)
1515
def readInto/*<-ext::Extension$package.readInto().*/[T/*<-ext::Extension$package.readInto().[T]*/](using Read/*->ext::Read#*/[T/*->ext::Extension$package.readInto().[T]*/]): Option/*->scala::Option#*/[T/*->ext::Extension$package.readInto().[T]*/] = summon/*->scala::Predef.summon().*/[Read/*->ext::Read#*/[T/*->ext::Extension$package.readInto().[T]*/]]/*->ext::Extension$package.readInto().(x$2)*/.fromString/*->ext::Read#fromString().*/(s/*->ext::Extension$package.readInto().(s)*/)
16+
17+
trait Functor/*<-ext::Functor#*/[F/*<-ext::Functor#[F]*/[_]]:
18+
extension [T/*<-ext::Functor#map().[T]*/](t/*<-ext::Functor#map().(t)*/: F/*->ext::Functor#[F]*/[T/*->ext::Functor#map().[T]*/]) def map/*<-ext::Functor#map().*/[U/*<-ext::Functor#map().[U]*/](f/*<-ext::Functor#map().(f)*/: T/*->ext::Functor#map().[T]*/ => U/*->ext::Functor#map().[U]*/): F/*->ext::Functor#[F]*/[U/*->ext::Functor#map().[U]*/]

tests/semanticdb/expect/Extension.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ trait Read[+T]:
1313

1414
extension (s: String)
1515
def readInto[T](using Read[T]): Option[T] = summon[Read[T]].fromString(s)
16+
17+
trait Functor[F[_]]:
18+
extension [T](t: F[T]) def map[U](f: T => U): F[U]

tests/semanticdb/metac.expect

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,8 @@ Schema => SemanticDB v4
12891289
Uri => Extension.scala
12901290
Text => empty
12911291
Language => Scala
1292-
Symbols => 17 entries
1293-
Occurrences => 40 entries
1292+
Symbols => 25 entries
1293+
Occurrences => 54 entries
12941294

12951295
Symbols:
12961296
ext/Extension$package. => final package object ext extends Object { self: ext.type => +6 decls }
@@ -1305,6 +1305,14 @@ ext/Extension$package.readInto(). => method readInto [typeparam T ](param s: Str
13051305
ext/Extension$package.readInto().(s) => param s: String
13061306
ext/Extension$package.readInto().(x$2) => implicit given param x$2: Read[T]
13071307
ext/Extension$package.readInto().[T] => typeparam T
1308+
ext/Functor# => trait Functor [typeparam F [unknown local0: <?>]] extends Object { self: Functor[F] => +3 decls }
1309+
ext/Functor#[F] => typeparam F [unknown local0: <?>]
1310+
ext/Functor#`<init>`(). => primary ctor <init> [typeparam F [unknown local0: <?>]](): Functor[F]
1311+
ext/Functor#map(). => abstract method map [typeparam T , typeparam U ](param t: F[T])(param f: Function1[T, U]): F[U]
1312+
ext/Functor#map().(f) => param f: Function1[T, U]
1313+
ext/Functor#map().(t) => param t: F[T]
1314+
ext/Functor#map().[T] => typeparam T
1315+
ext/Functor#map().[U] => typeparam U
13081316
ext/Read# => trait Read [covariant typeparam T ] extends Object { self: Read[T] => +3 decls }
13091317
ext/Read#[T] => covariant typeparam T
13101318
ext/Read#`<init>`(). => primary ctor <init> [covariant typeparam T ](): Read[T]
@@ -1352,6 +1360,20 @@ Occurrences:
13521360
[14:61..14:61): -> ext/Extension$package.readInto().(x$2)
13531361
[14:62..14:72): fromString -> ext/Read#fromString().
13541362
[14:73..14:74): s -> ext/Extension$package.readInto().(s)
1363+
[16:6..16:13): Functor <- ext/Functor#
1364+
[16:13..16:13): <- ext/Functor#`<init>`().
1365+
[16:14..16:15): F <- ext/Functor#[F]
1366+
[17:13..17:14): T <- ext/Functor#map().[T]
1367+
[17:16..17:17): t <- ext/Functor#map().(t)
1368+
[17:19..17:20): F -> ext/Functor#[F]
1369+
[17:21..17:22): T -> ext/Functor#map().[T]
1370+
[17:29..17:32): map <- ext/Functor#map().
1371+
[17:33..17:34): U <- ext/Functor#map().[U]
1372+
[17:36..17:37): f <- ext/Functor#map().(f)
1373+
[17:39..17:40): T -> ext/Functor#map().[T]
1374+
[17:44..17:45): U -> ext/Functor#map().[U]
1375+
[17:48..17:49): F -> ext/Functor#[F]
1376+
[17:50..17:51): U -> ext/Functor#map().[U]
13551377

13561378
expect/ForComprehension.scala
13571379
-----------------------------

0 commit comments

Comments
 (0)