Skip to content

Commit 10721e9

Browse files
committed
Fix #6518: Add type parameters to class type before asking for members
1 parent 0e66a88 commit 10721e9

File tree

4 files changed

+215
-1
lines changed

4 files changed

+215
-1
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,8 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
15561556
}
15571557

15581558
def ClassDefSymbol_methods(self: Symbol)(implicit ctx: Context): List[DefDefSymbol] = {
1559-
self.typeRef.allMembers.iterator.map(_.symbol).collect {
1559+
val classTpe = self.typeRef.appliedTo(self.typeParams.map(_.info.hiBound))
1560+
classTpe.allMembers.iterator.map(_.symbol).collect {
15601561
case sym if isMethod(sym) => sym.asTerm
15611562
}.toList
15621563
}

tests/run-macros/i6518.check

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
!=
2+
##
3+
$asInstanceOf$
4+
$isInstanceOf$
5+
++
6+
++:
7+
++:
8+
+:
9+
/:
10+
:+
11+
::
12+
:::
13+
:\
14+
==
15+
addString
16+
addString
17+
addString
18+
aggregate
19+
andThen
20+
apply
21+
applyOrElse
22+
asInstanceOf
23+
canEqual
24+
clone
25+
collect
26+
collectFirst
27+
combinations
28+
companion
29+
compose
30+
contains
31+
containsSlice
32+
copyToArray
33+
copyToArray
34+
copyToArray
35+
copyToBuffer
36+
corresponds
37+
count
38+
diff
39+
distinct
40+
drop
41+
dropRight
42+
dropWhile
43+
endsWith
44+
eq
45+
equals
46+
exists
47+
filter
48+
filterImpl
49+
filterNot
50+
finalize
51+
find
52+
flatMap
53+
flatten
54+
fold
55+
foldLeft
56+
foldRight
57+
forall
58+
foreach
59+
genericBuilder
60+
getClass
61+
groupBy
62+
grouped
63+
hasDefiniteSize
64+
hashCode
65+
head
66+
headOption
67+
indexOf
68+
indexOf
69+
indexOfSlice
70+
indexOfSlice
71+
indexWhere
72+
indexWhere
73+
indices
74+
init
75+
inits
76+
intersect
77+
isDefinedAt
78+
isEmpty
79+
isInstanceOf
80+
isTraversableAgain
81+
iterator
82+
last
83+
lastIndexOf
84+
lastIndexOf
85+
lastIndexOfSlice
86+
lastIndexOfSlice
87+
lastIndexWhere
88+
lastIndexWhere
89+
lastOption
90+
length
91+
lengthCompare
92+
lift
93+
map
94+
mapConserve
95+
max
96+
maxBy
97+
min
98+
minBy
99+
mkString
100+
mkString
101+
mkString
102+
ne
103+
newBuilder
104+
nonEmpty
105+
notify
106+
notifyAll
107+
orElse
108+
padTo
109+
par
110+
parCombiner
111+
partition
112+
patch
113+
permutations
114+
prefixLength
115+
product
116+
productArity
117+
productElement
118+
productIterator
119+
productPrefix
120+
reduce
121+
reduceLeft
122+
reduceLeftOption
123+
reduceOption
124+
reduceRight
125+
reduceRightOption
126+
repr
127+
reverse
128+
reverseIterator
129+
reverseMap
130+
reverse_:::
131+
reversed
132+
runWith
133+
sameElements
134+
scan
135+
scanLeft
136+
scanRight
137+
segmentLength
138+
seq
139+
size
140+
sizeHintIfCheap
141+
slice
142+
sliceWithKnownBound
143+
sliceWithKnownDelta
144+
sliding
145+
sliding
146+
sortBy
147+
sortWith
148+
sorted
149+
span
150+
splitAt
151+
startsWith
152+
startsWith
153+
stringPrefix
154+
sum
155+
synchronized
156+
tail
157+
tails
158+
take
159+
takeRight
160+
takeWhile
161+
thisCollection
162+
to
163+
toArray
164+
toBuffer
165+
toCollection
166+
toIndexedSeq
167+
toIterable
168+
toIterator
169+
toList
170+
toMap
171+
toSeq
172+
toSet
173+
toStream
174+
toString
175+
toTraversable
176+
toVector
177+
transpose
178+
union
179+
unzip
180+
unzip3
181+
updated
182+
view
183+
view
184+
wait
185+
wait
186+
wait
187+
withFilter
188+
writeReplace
189+
zip
190+
zipAll
191+
zipWithIndex

tests/run-macros/i6518/Macro_1.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import scala.quoted._
2+
import scala.quoted.autolift._
3+
import scala.tasty._
4+
5+
object Macros {
6+
7+
inline def test(): String = ${ testImpl }
8+
9+
private def testImpl(implicit reflect: Reflection): Expr[String] = {
10+
import reflect._
11+
typeOf[List[_]].classSymbol.get.methods.map(_.name).sorted.mkString("\n")
12+
}
13+
14+
}

tests/run-macros/i6518/Test_2.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
object Test {
3+
4+
def main(args: Array[String]): Unit = {
5+
println(Macros.test())
6+
}
7+
8+
}

0 commit comments

Comments
 (0)