Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,8 @@ object Types {
if (lsym isSubClass rsym) lsym
else if (rsym isSubClass lsym) rsym
else NoSymbol
case OrType(l, r) => // TODO does not conform to spec
val lsym = l.classSymbol
val rsym = r.classSymbol
if (lsym isSubClass rsym) rsym
else if (rsym isSubClass lsym) lsym
else NoSymbol
case tp: OrType =>
tp.join.classSymbol
case _ =>
NoSymbol
}
Expand Down
12 changes: 12 additions & 0 deletions tests/run/memoTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object Test extends App {

var opCache: Int | Null = null

def foo(x: Int) = {
if (opCache == null) opCache = x
opCache.asInstanceOf[Int] + 1
}

assert(foo(1) + foo(2) == 4)

}