-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4297: handle type param reference #4298
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
Conversation
case tp: TypeRef if tp.underlying.isInstanceOf[TypeBounds] => | ||
val lo = this(tp.info.loBound) | ||
val hi = this(tp.info.hiBound) | ||
if (variance == 0) range(lo, hi) |
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.
The range
method already does variance checks like this.
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.
Thanks 👍
test performance with #fast please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/4298/ to see the changes. Benchmarks is based on merging with master (7b91742) |
def apply(tp: Type): Type = tp match { | ||
case tp: TypeRef if tp.underlying.isInstanceOf[TypeBounds] => | ||
val lo = this(tp.info.loBound) | ||
val hi = this(tp.info.hiBound) |
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.
Replace this
by apply
? It makes it clearer that this is a recursive call
case tpe: AppliedType => isClassDetermined(X, tpe)(ctx.fresh.setNewTyperState()) | ||
case tpe: AppliedType => | ||
isClassDetermined(X, tpe)(ctx.fresh.setNewTyperState()) || | ||
isClassDetermined(stripTypeParam.apply(X), tpe)(ctx.fresh.setNewTyperState()) |
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.
Call it as stripTypeParam(X)
instead of stripTypeParam.apply(X)
?
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.
It seems scalac has problem with this syntax, however, I've changed the method so we don't need to call apply
anymore.
@@ -116,7 +130,9 @@ object Checkable { | |||
case defn.ArrayOf(tpE) => recur(tpE, tpT) | |||
case _ => recur(defn.AnyType, tpT) | |||
} | |||
case tpe: AppliedType => isClassDetermined(X, tpe)(ctx.fresh.setNewTyperState()) | |||
case tpe: AppliedType => | |||
isClassDetermined(X, tpe)(ctx.fresh.setNewTyperState()) || |
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.
Here, you first try without stripping type parameters for performance reasons? Maybe add a comment
@@ -88,19 +88,33 @@ object Checkable { | |||
} | |||
} | |||
|
|||
def stripTypeParam(implicit ctx: Context) = new ApproximatingTypeMap { | |||
def apply(tp: Type): Type = tp match { | |||
case tp: TypeRef if tp.underlying.isInstanceOf[TypeBounds] => |
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.
Probably equivalent to case tp: TypeRef if tp.symbol.isTypeParam
. Maybe clearer?
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.
tp.symbol.isTypeParam
doesn't cover the case of type members, so I think it's better to keep the original version here.
@@ -88,19 +88,33 @@ object Checkable { | |||
} | |||
} | |||
|
|||
def stripTypeParam(implicit ctx: Context) = new ApproximatingTypeMap { |
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.
Maybe add a comment: /** Approximate type parameters depending on variance */
Fix #4297: handle type param reference