File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
compiler/src/dotty/tools/dotc/sbt
sbt-dotty/sbt-test/source-dependencies/inline-inherited Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -632,16 +632,30 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
632
632
end positionedHash
633
633
634
634
def iteratorHash (it : Iterator [Any ], initHash : Int ): Int =
635
+ import core .Constants ._
635
636
var h = initHash
636
637
while it.hasNext do
637
638
it.next() match
638
639
case p : Positioned =>
639
640
h = positionedHash(p, h)
640
641
case xs : List [? ] =>
641
642
h = iteratorHash(xs.iterator, h)
642
- case c : core. Constants . Constant =>
643
+ case c : Constant =>
643
644
h = MurmurHash3 .mix(h, c.tag)
644
- h = MurmurHash3 .mix(h, c.value.## ) // We can't use `value.hashCode` since value might be null
645
+ c.tag match
646
+ case NullTag =>
647
+ // No value to hash, the tag is enough.
648
+ case ClazzTag =>
649
+ // Go through `apiType` to get a value with a stable hash, it'd
650
+ // be better to use Murmur here too instead of relying on
651
+ // `hashCode`, but that would essentially mean duplicating
652
+ // https://github.com/sbt/zinc/blob/develop/internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala
653
+ // and at that point we might as well do type hashing on our own
654
+ // representation.
655
+ val apiValue = apiType(c.typeValue)
656
+ h = MurmurHash3 .mix(h, apiValue.hashCode)
657
+ case _ =>
658
+ h = MurmurHash3 .mix(h, c.value.hashCode)
645
659
case n : Name =>
646
660
// The hashCode of the name itself is not stable across compiler instances
647
661
h = MurmurHash3 .mix(h, n.toString.hashCode)
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ class A {
3
3
class Local {
4
4
private val y : Int = 1
5
5
}
6
+ val a = scala.reflect.classTag[Integer ]
6
7
println(new Local )
7
8
val x = 1
8
9
x.toString
You can’t perform that action at this time.
0 commit comments