-
Notifications
You must be signed in to change notification settings - Fork 324
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
Low-hanging perf improvements #10462
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ import org.enso.compiler.core.{CompilerError, IR, Identifier} | |
import org.enso.compiler.core.ir.ProcessingPass | ||
import org.enso.compiler.core.ir.Module | ||
import org.enso.compiler.core.ir.Expression | ||
import shapeless.=:!= | ||
|
||
import java.util.UUID | ||
import scala.annotation.unused | ||
|
@@ -129,7 +128,7 @@ object IRPass { | |
* @return `ev`, cast to `T` if it is a `T` | ||
*/ | ||
def as[T <: Metadata: ClassTag](implicit | ||
@unused ev: T =:!= Metadata | ||
@unused ev: T =!= Metadata | ||
): Option[T] = { | ||
this match { | ||
case p: T => Some(p) | ||
|
@@ -146,7 +145,7 @@ object IRPass { | |
*/ | ||
@throws[CompilerError] | ||
def unsafeAs[T <: Metadata: ClassTag](implicit | ||
@unused ev: T =:!= Metadata | ||
@unused ev: T =!= Metadata | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a Scala way of doing Kotlin's reified classes? Wouldn't it be simpler to just delete the method implicit magic altogether and just pass in the argument explicitly? Btw. Why is the method called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sole purpose of this logic is to ensure at compile time that neither type inferencer nor explicit type argument result in T being I don't think providing explicit argument to every usage site is better, plus it doesn't prevent incorrect usage this implicit prevents from. |
||
): T = { | ||
this | ||
.as[T] | ||
|
@@ -183,4 +182,18 @@ object IRPass { | |
override def duplicate(): Option[Metadata] = Some(this) | ||
} | ||
} | ||
|
||
// https://stackoverflow.com/questions/6909053/enforce-type-difference | ||
|
||
sealed class =!=[A, B] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that copying this code into our repository would simplify the magic... |
||
|
||
trait LowerPriorityImplicits { | ||
implicit def equal[A]: =!=[A, A] = sys.error("should not be called") | ||
} | ||
object =!= extends LowerPriorityImplicits { | ||
implicit def nequal[A, B](implicit same: A =:= B = null): =!=[A, B] = | ||
if (same != null) | ||
sys.error("should not be called explicitly with same type") | ||
else new =!=[A, B] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any other usages of
shapelessVersion
. I guess:should also be removed then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks