-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Less eager dealiasing of type aliases #14586
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
base: main
Are you sure you want to change the base?
Changes from all commits
8816aaf
cd38aa2
732ad27
24463aa
569e4b9
a4b11d1
11af161
d264a0c
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 |
---|---|---|
|
@@ -57,8 +57,7 @@ object TypeApplications { | |
|
||
def unapply(tp: Type)(using Context): Option[Type] = tp match | ||
case tp @ HKTypeLambda(tparams, AppliedType(fn: Type, args)) | ||
if fn.typeSymbol.isClass | ||
&& tparams.hasSameLengthAs(args) | ||
if tparams.hasSameLengthAs(args) | ||
&& args.lazyZip(tparams).forall((arg, tparam) => arg == tparam.paramRef) | ||
&& weakerBounds(tp, fn.typeParams) => Some(fn) | ||
case _ => None | ||
|
@@ -330,7 +329,7 @@ class TypeApplications(val self: Type) extends AnyVal { | |
case dealiased: HKTypeLambda => | ||
def tryReduce = | ||
if (!args.exists(isBounds)) { | ||
val followAlias = Config.simplifyApplications && { | ||
val followAlias = (Config.simplifyApplications || self.typeSymbol.isPrivate) && { | ||
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. We still need to simplify type applications if they are type aliases that are declared 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.
Depends on where the private type alias appears: https://github.com/lampepfl/dotty/blob/e05af52bcf9f5cfcbda532c6dfaee4deac9928ac/compiler/src/dotty/tools/dotc/typer/Checking.scala#L565-L585 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. Ah, I see. I wasn't aware of that but this makes sense. |
||
dealiased.resType match { | ||
case AppliedType(tyconBody, dealiasedArgs) => | ||
// Reduction should not affect type inference when it's | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ package xml | |
|
||
import Utility._ | ||
import util.Chars.SU | ||
import scala.collection.BufferedIterator | ||
|
||
|
||
|
||
|
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.
Seems wrong that
EmptyTupleType
andEmptyTupleModule
are obtained by different means.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'm not sure I get the problem. Could you elaborate? This seems very similar to me to how
CanThrow
and the relatedCanThrow
alias are obtained: https://github.com/lampepfl/dotty/blob/3.1.1/compiler/src/dotty/tools/dotc/core/Definitions.scala#L836-L837If there is a better way, I suppose this can be changed and shouldn't be a fundamental issue.