From b04a07991d8e6e98e20293a845fdce7d1ad5d716 Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 30 May 2019 14:11:07 +0100 Subject: [PATCH] workaround scala-reflect non-threadsafe <:< operation that upstream WONTFIX /~https://github.com/scala/bug/issues/10766 --- .../izumi/fundamentals/reflection/SafeType0.scala | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fundamentals/fundamentals-reflection/src/main/scala/com/github/pshirshov/izumi/fundamentals/reflection/SafeType0.scala b/fundamentals/fundamentals-reflection/src/main/scala/com/github/pshirshov/izumi/fundamentals/reflection/SafeType0.scala index 9f7f8070bc..487df7a194 100644 --- a/fundamentals/fundamentals-reflection/src/main/scala/com/github/pshirshov/izumi/fundamentals/reflection/SafeType0.scala +++ b/fundamentals/fundamentals-reflection/src/main/scala/com/github/pshirshov/izumi/fundamentals/reflection/SafeType0.scala @@ -1,7 +1,6 @@ package com.github.pshirshov.izumi.fundamentals.reflection import com.github.pshirshov.izumi.fundamentals.reflection.ReflectionUtil._ -import com.github.pshirshov.izumi.fundamentals.reflection.SafeType0.globalSubtypeCheckLock import scala.reflect.runtime.{universe => ru} @@ -73,23 +72,21 @@ class SafeType0[U <: SingletonUniverse]( } } + // <:< is not thread-safe and upstream refuses to fix that. + // /~https://github.com/scala/bug/issues/10766 final def <:<(that: SafeType0[U]): Boolean = - globalSubtypeCheckLock.synchronized { + SafeType0.synchronized { dealiased <:< that.dealiased || freeTermPrefixTypeSuffixHeuristicEq(_ <:< _, dealiased, that.dealiased) } final def weak_<:<(that: SafeType0[U]): Boolean = - globalSubtypeCheckLock.synchronized { + SafeType0.synchronized { (dealiased weak_<:< that.dealiased) || freeTermPrefixTypeSuffixHeuristicEq(_ weak_<:< _, dealiased, that.dealiased) } } object SafeType0 { - // <:< is not thread-safe and upstream refuses to fix that. - // /~https://github.com/scala/bug/issues/10766 - private[SafeType0] object globalSubtypeCheckLock - def apply[U <: SingletonUniverse](u: U, tpe: U#Type): SafeType0[U] = new SafeType0[U](u, tpe) def apply(tpe: ru.Type): SafeType0[ru.type] = new SafeType0[ru.type](ru, tpe)