Skip to content

Commit a276ec0

Browse files
committed
Workaround symbol not found for higher kinded type param
1 parent 17c06dc commit a276ec0

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,13 @@ class TypeOps:
156156
// for `type X[T] = T` is equivalent to `[T] =>> T`
157157
def tparams(tpe: Type): (Type, List[Symbol]) = tpe match {
158158
case lambda: HKTypeLambda =>
159-
val paramSyms = lambda.paramNames.flatMap { paramName =>
160-
paramRefSymtab.get((lambda, paramName))
159+
val paramSyms = lambda.paramNames.zip(lambda.paramInfos).flatMap { (paramName, bounds) =>
160+
// def x[T[_]] = ???
161+
if paramName.isWildcard then
162+
val wildcardSym = newSymbol(NoSymbol, tpnme.WILDCARD, Flags.EmptyFlags, bounds)
163+
Some(wildcardSym)
164+
else
165+
paramRefSymtab.getOrErr((lambda, paramName))
161166
}
162167
(lambda.resType, paramSyms)
163168
case _ => (tpe, Nil)

tests/semanticdb/expect/Anonymous.expect.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Anonymous/*<-example::Anonymous#*/ {
1212
???/*->scala::Predef.`???`().*/ match { case _: List/*->scala::package.List#*/[_] => }
1313
}
1414
locally/*->example::Anonymous#locally().*/ {
15-
val x/*<-local2*/: Int/*->scala::Int#*/ => Int/*->scala::Int#*/ = _ => ???/*->scala::Predef.`???`().*/
15+
val x/*<-local3*/: Int/*->scala::Int#*/ => Int/*->scala::Int#*/ = _ => ???/*->scala::Predef.`???`().*/
1616
}
1717

1818
trait Foo/*<-example::Anonymous#Foo#*/

tests/semanticdb/expect/semanticdb-Types.expect.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ object Test/*<-types::Test.*/ {
7474
val existentialType4/*<-types::Test.C#existentialType4.*/ = Class/*->java::lang::Class#*/.forName/*->java::lang::Class#forName().*/("foo.Bar")
7575

7676
def typeLambda1/*<-types::Test.C#typeLambda1().*/[M/*<-types::Test.C#typeLambda1().[M]*/[_]] = ???/*->scala::Predef.`???`().*/
77-
typeLambda1/*->types::Test.C#typeLambda1().*/[({ type L/*<-local14*/[T/*<-local13*/] = List/*->scala::package.List#*/[T/*->local13*/] })#L]
77+
typeLambda1/*->types::Test.C#typeLambda1().*/[({ type L/*<-local15*/[T/*<-local14*/] = List/*->scala::package.List#*/[T/*->local14*/] })#L]
7878

7979
object ClassInfoType1/*<-types::Test.C#ClassInfoType1.*/
8080
class ClassInfoType2/*<-types::Test.C#ClassInfoType2#*/ extends B/*->types::B#*/ { def x/*<-types::Test.C#ClassInfoType2#x().*/ = 42 }

tests/semanticdb/metac.expect

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ example/Anonymous#foo. => val method foo Foo
303303
example/Anonymous#locally(). => method locally [typeparam A ](param x: A): A
304304
example/Anonymous#locally().(x) => param x: A
305305
example/Anonymous#locally().[A] => typeparam A
306-
example/Anonymous#m1(). => method m1 [typeparam T ]: Nothing
307-
example/Anonymous#m1().[T] => typeparam T
306+
example/Anonymous#m1(). => method m1 [typeparam T [unknown local0: <?>]]: Nothing
307+
example/Anonymous#m1().[T] => typeparam T [unknown local0: <?>]
308308
example/Anonymous#m2(). => method m2 => Map[_, List[_] forSome { type _ }] forSome { type _ }
309-
local2 => val local x: Function1[Int, Int]
310-
local3 => final class $anon extends Object with Foo { self: $anon => +1 decls }
309+
local3 => val local x: Function1[Int, Int]
310+
local4 => final class $anon extends Object with Foo { self: $anon => +1 decls }
311311

312312
Occurrences:
313313
[0:8..0:15): example <- example/
@@ -334,7 +334,7 @@ Occurrences:
334334
[11:4..11:7): ??? -> scala/Predef.`???`().
335335
[11:24..11:28): List -> scala/package.List#
336336
[13:2..13:9): locally -> example/Anonymous#locally().
337-
[14:8..14:9): x <- local2
337+
[14:8..14:9): x <- local3
338338
[14:11..14:14): Int -> scala/Int#
339339
[14:18..14:21): Int -> scala/Int#
340340
[14:29..14:32): ??? -> scala/Predef.`???`().
@@ -4165,8 +4165,8 @@ local3 => final class $anon extends Object { self: $anon => +2 decls }
41654165
local5 => final class $anon extends M with N { self: $anon => +1 decls }
41664166
local7 => method k => Int
41674167
local8 => final class $anon extends M with N { self: $anon => +2 decls }
4168-
local13 => typeparam T
4169-
local14 => type L [typeparam T ] = List[T]
4168+
local14 => typeparam T
4169+
local15 => type L [typeparam T ] = List[T]
41704170
types/B# => class B extends Object { self: B => +1 decls }
41714171
types/B#`<init>`(). => primary ctor <init> (): B
41724172
types/C# => class C extends Object { self: C => +1 decls }
@@ -4244,8 +4244,8 @@ types/Test.C#TypeType.T5# => type T5 [typeparam U ] = U
42444244
types/Test.C#TypeType.T5#[U] => typeparam U
42454245
types/Test.C#TypeType.m2(). => method m2 [typeparam T2 = C]: Nothing
42464246
types/Test.C#TypeType.m2().[T2] => typeparam T2 = C
4247-
types/Test.C#TypeType.m3(). => method m3 [typeparam M3 ]: Nothing
4248-
types/Test.C#TypeType.m3().[M3] => typeparam M3
4247+
types/Test.C#TypeType.m3(). => method m3 [typeparam M3 [unknown local16: <?>]]: Nothing
4248+
types/Test.C#TypeType.m3().[M3] => typeparam M3 [unknown local16: <?>]
42494249
types/Test.C#`<init>`(). => primary ctor <init> (): C
42504250
types/Test.C#annType1. => val method annType1 T @ann[T]
42514251
types/Test.C#annType2. => val method annType2 T @ann1 @ann2
@@ -4266,8 +4266,8 @@ types/Test.C#superType2. => val method superType2 Int
42664266
types/Test.C#superType3. => val method superType3 Int
42674267
types/Test.C#thisType1. => val method thisType1 C.this.type
42684268
types/Test.C#thisType2. => val method thisType2 C.this.type
4269-
types/Test.C#typeLambda1(). => method typeLambda1 [typeparam M ]: Nothing
4270-
types/Test.C#typeLambda1().[M] => typeparam M
4269+
types/Test.C#typeLambda1(). => method typeLambda1 [typeparam M [unknown local13: <?>]]: Nothing
4270+
types/Test.C#typeLambda1().[M] => typeparam M [unknown local13: <?>]
42714271
types/Test.C#typeRef1. => val method typeRef1 C
42724272
types/Test.C#typeRef2. => val method typeRef2 p.C
42734273
types/Test.C#typeRef3. => val method typeRef3 T#C
@@ -4464,10 +4464,10 @@ Occurrences:
44644464
[75:20..75:21): M <- types/Test.C#typeLambda1().[M]
44654465
[75:28..75:31): ??? -> scala/Predef.`???`().
44664466
[76:4..76:15): typeLambda1 -> types/Test.C#typeLambda1().
4467-
[76:24..76:25): L <- local14
4468-
[76:26..76:27): T <- local13
4467+
[76:24..76:25): L <- local15
4468+
[76:26..76:27): T <- local14
44694469
[76:31..76:35): List -> scala/package.List#
4470-
[76:36..76:37): T -> local13
4470+
[76:36..76:37): T -> local14
44714471
[78:11..78:25): ClassInfoType1 <- types/Test.C#ClassInfoType1.
44724472
[79:10..79:24): ClassInfoType2 <- types/Test.C#ClassInfoType2#
44734473
[79:33..79:34): B -> types/B#

0 commit comments

Comments
 (0)