Skip to content

Commit 358a348

Browse files
authored
Merge pull request #6884 from dotty-staging/fix-primitive-conversion
Change definition of classSymbol for OrType
2 parents 5a1a4f0 + 7cde70a commit 358a348

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,8 @@ object Types {
431431
if (lsym isSubClass rsym) lsym
432432
else if (rsym isSubClass lsym) rsym
433433
else NoSymbol
434-
case OrType(l, r) => // TODO does not conform to spec
435-
val lsym = l.classSymbol
436-
val rsym = r.classSymbol
437-
if (lsym isSubClass rsym) rsym
438-
else if (rsym isSubClass lsym) lsym
439-
else NoSymbol
434+
case tp: OrType =>
435+
tp.join.classSymbol
440436
case _ =>
441437
NoSymbol
442438
}

tests/run/memoTest.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
object Test extends App {
2+
3+
var opCache: Int | Null = null
4+
5+
def foo(x: Int) = {
6+
if (opCache == null) opCache = x
7+
opCache.asInstanceOf[Int] + 1
8+
}
9+
10+
assert(foo(1) + foo(2) == 4)
11+
12+
}

0 commit comments

Comments
 (0)