Skip to content

Change definition of classSymbol for OrType #6884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2019
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)

}